@samva/vite 0.11.4 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,20 +14,22 @@ Error generating stack: `+e.message+`
14
14
 
15
15
  `)},"dynamic-definition":{summary:`A definition field is spread or computed instead of written out.`,fix:`Write each field as name: value.`},"invalid-template-id":{summary:`The template id is not a lowercase kebab-case string literal.`,fix:`Write id: "order-shipped".`},"missing-schema":{summary:`The template declares no input schema.`,fix:`Add schema: jsonSchema<Input>({ ... }).`},"schema-not-static":{summary:`The schema cannot be read without running code.`,fix:`Write the schema as a literal jsonSchema<Input>({ type: 'object', ... }).`},"invalid-schema":{summary:`The schema uses JSON Schema keywords the compiler cannot validate against.`,fix:`Use only the JSON Schema keywords the package README lists.`},"missing-fixtures":{summary:`The template declares no fixtures.`,fix:`Add fixtures: { default: { ... } } with at least one valid payload.`},"fixtures-not-static":{summary:`A fixture is computed instead of written as data.`,fix:`Write each fixture as a literal object; an imported asset is allowed.`},"invalid-fixture-name":{summary:`A fixture key is not a single path segment.`,fix:`Use letters, digits, '.', '_' and '-', starting with a letter or digit.`},"fixture-invalid":{summary:`A fixture does not match the schema.`,fix:`Change the fixture, or the schema, so every fixture is a payload a send could carry.`},"invalid-locale":{summary:`The template's default locale is not a string literal.`,fix:`Write locale: "en-US".`},"no-channel":{summary:`The template declares no channel body.`,fix:`Add an email body.`},"invalid-channel":{summary:`A channel field is not shaped as the channel requires.`,fix:`Write email: { subject, preheader?, body } with each a function of the input.`},"not-a-function":{summary:`A channel field is not a function of the input.`,fix:`Write (input) => ... in place or declare the function in the project.`},"missing-subject":{summary:`The email channel has no subject.`,fix:`Add subject: (input) => ....`},"missing-body":{summary:`The email channel has no body.`,fix:`Add body: (input) => (<Email>...</Email>).`},"multiple-roots":{summary:`The body renders nothing or more than one root.`,fix:`Wrap the body in a single element such as <Email>.`},"preheader-without-shell":{summary:`A preheader is set but the body has no <Email> shell to hold it.`,fix:`Wrap the body in <Email>.`},"wrong-channel":{summary:`A channel body does not return its own channel component.`,fix:`Return one element imported from the channel package.`,channelOnly:!0},"syntax-error":{summary:`A project file does not parse as TSX.`,fix:`Fix the syntax at the reported location.`},"non-project-import":{summary:`The file imports something other than @samva/markup or a project file.`,fix:`Remove the import, or copy the code you need into a project file.`},"moved-import":{summary:`The file imports an @samva/markup entry that moved.`,fix:`Import email components from "@samva/markup/email".`,upgrade:[`Replace every import from "@samva/markup/email/components" with "@samva/markup/email" in every project file, templates and partials alike. The imported names are unchanged; change only the specifier.`,`Compile each entry and render every declared fixture to confirm the output is unchanged. Resolve errors before requesting one saved version for the whole project, approved by the user; do not publish.`].join(`
16
16
 
17
- `)},"unresolved-import":{summary:`An import names no file in the project.`,fix:`Check the path and the file extension.`},"recursive-partial":{summary:`A partial renders itself; partials are inlined at compile time.`,fix:`Flatten the recursion, or repeat the structure with .map.`},"nesting-limit":{summary:`The template nests deeper than the compiler reads.`,fix:`Flatten the structure.`},"dynamic-expression":{summary:`An expression outside the static profile: a call other than fmt.* and .map, a computed value, or a spread.`,fix:`Compute the value where the message is sent and bind it from the payload.`},"statement-in-body":{summary:`A body contains a statement (const, if, a loop); a body is one expression.`,fix:`Use cond && <X />, cond ? <A /> : <B /> and .map, or send the computed value in the payload.`},"unsupported-pattern":{summary:`A parameter pattern or default value the profile cannot bind.`,fix:`Use plain names or destructuring without defaults; declare the field required or guard it.`},"hook-call":{summary:`A hook was called; templates have no state, effects or context.`,fix:`Read the input through the function's parameter and send anything else in the payload.`},"unknown-formatter":{summary:`fmt.<name> is not a formatter.`,fix:`Use fmt.money, number, date, time, plural or list.`},"formatter-arguments":{summary:`A formatter got the wrong number of arguments.`,fix:`Match the formatter's signature in the contract.`},"reserved-character":{summary:`Text contains a private-use character the compiler reserves.`,fix:`Remove the characters U+E000 to U+E003.`},"reserved-url":{summary:`A URL is the unsubscribe placeholder only BrandFooter can write.`,fix:`Render <BrandFooter /> instead.`},"reserved-attribute":{summary:`An attribute is written only by a brand component.`,fix:`Render BrandFooter from the brand import instead of marking an element as the footer.`},"dynamic-class":{summary:`A class name is built at run time, and Tailwind cannot see it.`,fix:`Write classes literally, or choose between literal lists: input.vip ? "bg-amber-100" : "bg-white".`},"too-many-class-variants":{summary:`A class list chooses between more literal lists than the compiler resolves.`,fix:`Split the choice into fewer conditions, or move part of it to a partial.`},"invalid-style":{summary:`A style prop is not a static property object.`,fix:`Write style={{ backgroundColor: "#fff" }} with literal values, or use classes.`},"unknown-field":{summary:`A binding names a field the schema does not declare.`,fix:`Add the field to the schema, or bind a field it declares (the message suggests the nearest).`},"unguarded-optional":{summary:`An optional field is read outside a guard, so a send without it would render a blank.`,fix:`Guard it with {input.field && ...}, or make the field required.`},"invalid-binding-type":{summary:`A binding has the wrong type for where it is used.`,fix:`Bind a field of the type the position needs, or send it in that type.`},"unknown-component":{summary:`A component the profile cannot read.`,fix:`Import components from @samva/markup/email, the brand import, or the project.`},"dynamic-numeric-prop":{summary:`A prop that sizes layout at compile time is not a number literal.`,fix:`Write the number literally, for example height={44}.`},"button-dynamic-label":{summary:`A Button label is read at render time, so classic Outlook cannot size it.`,fix:`Give the button a width: <Button width={200}>.`},"invalid-columns-each":{summary:`<Columns each> is not a list from the input.`,fix:`Write each={input.items} with a callback returning <Column>.`},"invalid-columns-per":{summary:`<Columns per> is not a positive integer literal.`,fix:`Write per={2}.`},"invalid-button-number":{summary:`A Button size prop is not a finite number.`,fix:`Pass a finite number.`},"unsupported-element":{summary:`An element outside the supported email vocabulary.`,fix:`Use an element from the contract's element table.`},"unsupported-attribute":{summary:`An attribute the element does not support.`,fix:`Use a supported attribute, or data-* and aria-*.`},"missing-attribute":{summary:`An element is missing a required attribute.`,fix:`Add the attribute, for example alt on img.`},"invalid-attribute-value":{summary:`An attribute value is not a string or number, or contains control characters.`,fix:`Pass plain text.`},"duplicate-attribute":{summary:`An attribute is written twice.`,fix:`Keep one.`},"invalid-content":{summary:`An element holds content its content model does not allow.`,fix:`Move the child to a parent that accepts it.`},"void-element-children":{summary:`A void element has children.`,fix:`Remove the children.`},"event-handler":{summary:`An event handler; email clients strip scripting.`,fix:`Remove the handler; use a link for interaction.`},"dangerous-html":{summary:`dangerouslySetInnerHTML; there is no raw-HTML escape hatch.`,fix:`Write the markup as JSX.`},"unsafe-url":{summary:`A URL uses a scheme email cannot send safely.`,fix:`Use an https URL, a mailto: or tel: link, or a bound URL.`},"unsafe-raw-text":{summary:`Raw text content contains markup that could end its element.`,fix:`Remove the offending sequence.`},"unsupported-style-property":{summary:`A style property name is not a CSS property.`,fix:`Write camelCase (backgroundColor) or a custom property (--brand).`},"invalid-style-value":{summary:`A style value is not a string or number.`,fix:`Pass a string or number.`},"unsafe-style-value":{summary:`A style value contains CSS that could break out of its declaration.`,fix:`Remove the offending characters.`},"missing-head":{summary:`Styles that cannot be inlined need a <head> to live in.`,fix:`Wrap the message in <Email>, or write those declarations inline.`},"invalid-subject":{summary:`The subject is not one line of text.`,fix:`Return a single-line string.`},"invalid-preheader":{summary:`The preheader is not a string.`,fix:`Return a string.`},"invalid-text":{summary:`The plain-text body is not a string.`,fix:`Return a string.`},"button-outlook-fallback":{summary:`Classic Outlook needs a height and a plain string label to draw the button.`,fix:`Give <Button> a height and a string label.`},"unmatched-class":{summary:`A class produced no styles.`,fix:`Use a class the theme or Tailwind defines, or write the style inline.`},"tailwind-dynamic-class":{summary:`A class list is assembled at run time.`,fix:`Write the classes literally.`},"css-parse-error":{summary:`A stylesheet does not parse.`,fix:`Fix the CSS at the reported location.`},"css-import-unresolved":{summary:`A stylesheet @import cannot be resolved.`,fix:`Import the stylesheet from the template module, or use the theme.css layers.`},"css-unsupported-at-rule":{summary:`An at-rule is not applied to email output.`,fix:`Remove it or move the declarations into a class rule.`},"css-conditional-variable":{summary:`A custom property is redefined inside a conditional at-rule.`,fix:`Keep the override on a class rule.`},"email-font-fallback":{summary:`A font stack names a project font without a generic fallback.`,fix:`End the stack with sans-serif, serif or monospace.`},"email-font-family":{summary:`@font-face declares no font-family.`,fix:`Add font-family.`},"email-font-src":{summary:`@font-face declares no usable url() src.`,fix:`Add a url() pointing at a .woff2 file.`},"email-font-format":{summary:`@font-face uses a format other than WOFF2.`,fix:`Convert the file to .woff2.`},"email-font-missing":{summary:`@font-face names a file the project does not hold.`,fix:`Add the file; paths resolve from the stylesheet's directory.`},"invalid-asset-base":{summary:`The asset base is not an https URL or a path.`,fix:`Use an https URL, an absolute path, or a relative path.`},"brand-unavailable":{summary:`The build has no brand to resolve a brand import.`,fix:`Create or select the brand the import names.`},"brand-import-conflict":{summary:`The project imports two different brands.`,fix:`Import one brand specifier everywhere.`},"caniemail/unknown-coverage":{summary:`A feature has no client-support data.`,fix:`Verify it in the target clients.`},"invalid-attribute":{summary:`A channel component attribute has a value the channel does not accept.`,fix:`Use one of the listed values.`,channelOnly:!0},"unknown-attribute":{summary:`A channel component attribute the component does not have.`,fix:`Use one of the listed attributes.`,channelOnly:!0},"sms-markup":{summary:`An SMS body contains an element; SMS is plain text.`,fix:`Write text and bindings, with a newline for a line break.`,channelOnly:!0},"whatsapp-structure":{summary:`WhatsApp content sits outside Header, Body, Footer or Buttons.`,fix:`Move it into <WhatsApp.Body>.`,channelOnly:!0},"whatsapp-body-required":{summary:`A WhatsApp template has no body.`,fix:`Add <WhatsApp.Body>...</WhatsApp.Body>.`,channelOnly:!0},"whatsapp-conditional":{summary:`A WhatsApp part branches or contains elements; Meta registers its text once.`,fix:`Choose the wording in the payload, or write separate templates.`,channelOnly:!0},"whatsapp-header-media":{summary:`A WhatsApp media header is not exactly one URL.`,fix:`Write the URL as the only child: a literal or one binding.`,channelOnly:!0},"whatsapp-header-variables":{summary:`A WhatsApp header text takes more than one variable.`,fix:`Keep one binding in the header and move the rest to the body.`,channelOnly:!0},"whatsapp-length":{summary:`A WhatsApp part exceeds Meta's length limit.`,fix:`Shorten the text.`,channelOnly:!0},"whatsapp-button-text":{summary:`A WhatsApp button has no label or value between its tags.`,fix:`Write the label or value as text between the tags.`,channelOnly:!0},"whatsapp-button-limit":{summary:`The conditions can produce more buttons of a kind than Meta allows.`,fix:`Remove buttons, or split the template.`,channelOnly:!0}}),Cs=e=>Object.entries(Ss).some(([t,n])=>t===e&&`upgrade`in n);function ws(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!ws(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!ws(e[r],t[r]))return!1;return!0}return e===t}function Ts(e){return encodeURI(Es(e))}function Es(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}var Ds={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},Os={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},ks={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},As=typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);function js(e,t=Object.create(null),n=As,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:js(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(ks[i])continue;let a=`${r}/${Ts(i)}`,o=e[i];if(Array.isArray(o)){if(Ds[i]){let e=o.length;for(let r=0;r<e;r++)js(o[r],t,n,`${a}/${r}`)}}else if(Os[i])for(let e in o)js(o[e],t,n,`${a}/${Ts(e)}`);else js(o,t,n,a)}return t}var Ms=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Ns=[0,31,28,31,30,31,30,31,31,30,31,30,31],Ps=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Fs=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,Is=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,Ls=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Rs=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,zs=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Bs=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Vs=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Hs=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Us=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},Ws=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Gs=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Ks=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function qs(e){return e.test.bind(e)}var Js={date:Xs,time:Zs.bind(void 0,!1),"date-time":$s,duration:Ks,uri:nc,"uri-reference":qs(Is),"uri-template":qs(Ls),url:qs(Rs),email:Us,hostname:qs(Fs),ipv4:qs(Ws),ipv6:qs(Gs),regex:ic,uuid:qs(zs),"json-pointer":qs(Bs),"json-pointer-uri-fragment":qs(Vs),"relative-json-pointer":qs(Hs)};function Ys(e){return e%4==0&&(e%100!=0||e%400==0)}function Xs(e){let t=e.match(Ms);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&Ys(n)?29:Ns[r])}function Zs(e,t){let n=t.match(Ps);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var Qs=/t|\s/i;function $s(e){let t=e.split(Qs);return t.length==2&&Xs(t[0])&&Zs(!0,t[1])}var ec=/\/|:/,tc=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function nc(e){return ec.test(e)&&tc.test(e)}var rc=/[^\\]\\Z/;function ic(e){if(rc.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function ac(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function oc(e,t,n=`2019-09`,r=js(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,u;switch(l){case`boolean`:case`number`:case`string`:u=l;break;case`object`:u=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:g,required:_,not:v,anyOf:y,allOf:b,oneOf:x,if:S,then:C,else:w,format:T,properties:E,patternProperties:D,additionalProperties:O,unevaluatedProperties:k,minProperties:A,maxProperties:j,propertyNames:M,dependentRequired:N,dependentSchemas:P,dependencies:F,prefixItems:I,items:L,additionalItems:R,unevaluatedItems:ee,contains:z,minContains:te,maxContains:ne,minItems:re,maxItems:B,uniqueItems:ie,minimum:ae,maximum:oe,exclusiveMinimum:se,exclusiveMaximum:ce,multipleOf:le,minLength:V,maxLength:H,pattern:ue,__absolute_ref__:de,__absolute_recursive_ref__:fe}=t,U=[];if(p===!0&&a===null&&(a=t),f===`#`){let l=a===null?r[fe]:a,u=`${s}/$recursiveRef`,d=oc(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||U.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(d!==void 0){let t=r[de||d];if(t===void 0){let e=`Unresolved $ref "${d}".`;throw de&&de!==d&&(e+=` Absolute URI "${de}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
17
+ `)},"unresolved-import":{summary:`An import names no file in the project.`,fix:`Check the path and the file extension.`},"recursive-partial":{summary:`A partial renders itself; partials are inlined at compile time.`,fix:`Flatten the recursion, or repeat the structure with .map.`},"nesting-limit":{summary:`The template nests deeper than the compiler reads.`,fix:`Flatten the structure.`},"dynamic-expression":{summary:`An expression outside the static profile: a call other than fmt.* and .map, a computed value, or a spread.`,fix:`Compute the value where the message is sent and bind it from the payload.`},"statement-in-body":{summary:`A body contains a statement (const, if, a loop); a body is one expression.`,fix:`Use cond && <X />, cond ? <A /> : <B /> and .map, or send the computed value in the payload.`},"unsupported-pattern":{summary:`A parameter pattern or default value the profile cannot bind.`,fix:`Use plain names or destructuring without defaults; declare the field required or guard it.`},"hook-call":{summary:`A hook was called; templates have no state, effects or context.`,fix:`Read the input through the function's parameter and send anything else in the payload.`},"unknown-formatter":{summary:`fmt.<name> is not a formatter.`,fix:`Use fmt.money, number, date, time, plural or list.`},"formatter-arguments":{summary:`A formatter got the wrong number of arguments.`,fix:`Match the formatter's signature in the contract.`},"reserved-character":{summary:`Text contains a private-use character the compiler reserves.`,fix:`Remove the characters U+E000 to U+E003.`},"reserved-url":{summary:`A URL is the unsubscribe placeholder only BrandFooter can write.`,fix:`Render <BrandFooter /> instead.`},"reserved-attribute":{summary:`An attribute is written only by a brand component.`,fix:`Render BrandFooter from the brand import instead of marking an element as the footer.`},"dynamic-class":{summary:`A class name is built at run time, and Tailwind cannot see it.`,fix:`Write classes literally, or choose between literal lists: input.vip ? "bg-amber-100" : "bg-white".`},"too-many-class-variants":{summary:`A class list chooses between more literal lists than the compiler resolves.`,fix:`Split the choice into fewer conditions, or move part of it to a partial.`},"invalid-style":{summary:`A style prop is not a static property object.`,fix:`Write style={{ backgroundColor: "#fff" }} with literal values, or use classes.`},"unknown-field":{summary:`A binding names a field the schema does not declare.`,fix:`Add the field to the schema, or bind a field it declares (the message suggests the nearest).`},"unguarded-optional":{summary:`An optional field is read outside a guard, so a send without it would render a blank.`,fix:`Guard it with {input.field && ...}, or make the field required.`},"invalid-binding-type":{summary:`A binding has the wrong type for where it is used.`,fix:`Bind a field of the type the position needs, or send it in that type.`},"unknown-component":{summary:`A component the profile cannot read.`,fix:`Import components from @samva/markup/email, the brand import, or the project.`},"dynamic-numeric-prop":{summary:`A prop that sizes layout at compile time is not a number literal.`,fix:`Write the number literally, for example height={44}.`},"button-dynamic-label":{summary:`A Button label is read at render time, so classic Outlook cannot size it.`,fix:`Give the button a width: <Button width={200}>.`},"invalid-columns-each":{summary:`<Columns each> is not a list from the input.`,fix:`Write each={input.items} with a callback returning <Column>.`},"invalid-columns-per":{summary:`<Columns per> is not a positive integer literal.`,fix:`Write per={2}.`},"invalid-button-number":{summary:`A Button size prop is not a finite number.`,fix:`Pass a finite number.`},"unsupported-element":{summary:`An element outside the supported email vocabulary.`,fix:`Use an element from the contract's element table.`},"unsupported-attribute":{summary:`An attribute the element does not support.`,fix:`Use a supported attribute, or data-* and aria-*.`},"missing-attribute":{summary:`An element is missing a required attribute.`,fix:`Add the attribute, for example alt on img.`},"invalid-attribute-value":{summary:`An attribute value is not a string or number, or contains control characters.`,fix:`Pass plain text.`},"duplicate-attribute":{summary:`An attribute is written twice.`,fix:`Keep one.`},"invalid-content":{summary:`An element holds content its content model does not allow.`,fix:`Move the child to a parent that accepts it.`},"void-element-children":{summary:`A void element has children.`,fix:`Remove the children.`},"event-handler":{summary:`An event handler; email clients strip scripting.`,fix:`Remove the handler; use a link for interaction.`},"dangerous-html":{summary:`dangerouslySetInnerHTML; there is no raw-HTML escape hatch.`,fix:`Write the markup as JSX.`},"unsafe-url":{summary:`A URL uses a scheme email cannot send safely.`,fix:`Use an https URL, a mailto: or tel: link, or a bound URL.`},"unsafe-raw-text":{summary:`Raw text content contains markup that could end its element.`,fix:`Remove the offending sequence.`},"unsupported-style-property":{summary:`A style property name is not a CSS property.`,fix:`Write camelCase (backgroundColor) or a custom property (--brand).`},"invalid-style-value":{summary:`A style value is not a string or number.`,fix:`Pass a string or number.`},"unsafe-style-value":{summary:`A style value contains CSS that could break out of its declaration.`,fix:`Remove the offending characters.`},"missing-head":{summary:`Styles that cannot be inlined need a <head> to live in.`,fix:`Wrap the message in <Email>, or write those declarations inline.`},"invalid-subject":{summary:`The subject is not one line of text.`,fix:`Return a single-line string.`},"invalid-preheader":{summary:`The preheader is not a string.`,fix:`Return a string.`},"invalid-text":{summary:`The plain-text body is not a string.`,fix:`Return a string.`},"button-outlook-fallback":{summary:`Classic Outlook needs a height and a plain string label to draw the button.`,fix:`Give <Button> a height and a string label.`},"unmatched-class":{summary:`A class produced no styles.`,fix:`Use a class the theme or Tailwind defines, or write the style inline.`},"tailwind-dynamic-class":{summary:`A class list is assembled at run time.`,fix:`Write the classes literally.`},"css-parse-error":{summary:`A stylesheet does not parse.`,fix:`Fix the CSS at the reported location.`},"css-import-unresolved":{summary:`A stylesheet @import cannot be resolved.`,fix:`Import the stylesheet from the template module, or use the theme.css layers.`},"css-unsupported-at-rule":{summary:`An at-rule is not applied to email output.`,fix:`Remove it or move the declarations into a class rule.`},"css-conditional-variable":{summary:`A custom property is redefined inside a conditional at-rule.`,fix:`Keep the override on a class rule.`},"email-font-fallback":{summary:`A font stack names a project font without a generic fallback.`,fix:`End the stack with sans-serif, serif or monospace.`},"email-font-family":{summary:`@font-face declares no font-family.`,fix:`Add font-family.`},"email-font-src":{summary:`@font-face declares no usable url() src.`,fix:`Add a url() pointing at a .woff2 file.`},"email-font-format":{summary:`@font-face uses a format other than WOFF2.`,fix:`Convert the file to .woff2.`},"email-font-missing":{summary:`@font-face names a file the project does not hold.`,fix:`Add the file; paths resolve from the stylesheet's directory.`},"invalid-asset-base":{summary:`The asset base is not an https URL or a path.`,fix:`Use an https URL, an absolute path, or a relative path.`},"brand-unavailable":{summary:`The build has no brand to resolve a brand import.`,fix:`Create or select the brand the import names.`},"brand-import-conflict":{summary:`The project imports two different brands.`,fix:`Import one brand specifier everywhere.`},"caniemail/unknown-coverage":{summary:`A feature has no client-support data.`,fix:`Verify it in the target clients.`},"invalid-attribute":{summary:`A channel component attribute has a value the channel does not accept.`,fix:`Use one of the listed values.`,channelOnly:!0},"unknown-attribute":{summary:`A channel component attribute the component does not have.`,fix:`Use one of the listed attributes.`,channelOnly:!0},"sms-markup":{summary:`An SMS body contains an element; SMS is plain text.`,fix:`Write text and bindings, with a newline for a line break.`,channelOnly:!0},"whatsapp-template-name":{summary:`A <WhatsApp> names its Meta template; the name comes from the template's handle.`,fix:"Remove `name` from <WhatsApp>.",upgrade:["Remove the `name` attribute from every <WhatsApp> element in the project, templates and partials alike. Samva registers each WhatsApp template with Meta under its handle, with hyphens as underscores, so the attribute has no replacement. Change nothing else.",`If an authored name differs from the name the handle produces and the template is already registered with Meta under it, tell the user: keeping that Meta name means renaming the template's handle, which you do not do yourself.`,`Compile each entry and render every declared fixture to confirm the WhatsApp output is otherwise unchanged. Resolve errors before requesting one saved version for the whole project, approved by the user; do not publish.`].join(`
18
+
19
+ `),channelOnly:!0},"whatsapp-structure":{summary:`WhatsApp content sits outside Header, Body, Footer or Buttons.`,fix:`Move it into <WhatsApp.Body>.`,channelOnly:!0},"whatsapp-body-required":{summary:`A WhatsApp template has no body.`,fix:`Add <WhatsApp.Body>...</WhatsApp.Body>.`,channelOnly:!0},"whatsapp-conditional":{summary:`A WhatsApp part branches or contains elements; Meta registers its text once.`,fix:`Choose the wording in the payload, or write separate templates.`,channelOnly:!0},"whatsapp-header-media":{summary:`A WhatsApp media header is not exactly one URL.`,fix:`Write the URL as the only child: a literal or one binding.`,channelOnly:!0},"whatsapp-header-variables":{summary:`A WhatsApp header text takes more than one variable.`,fix:`Keep one binding in the header and move the rest to the body.`,channelOnly:!0},"whatsapp-length":{summary:`A WhatsApp part exceeds Meta's length limit.`,fix:`Shorten the text.`,channelOnly:!0},"whatsapp-button-text":{summary:`A WhatsApp button has no label or value between its tags.`,fix:`Write the label or value as text between the tags.`,channelOnly:!0},"whatsapp-button-limit":{summary:`The conditions can produce more buttons of a kind than Meta allows.`,fix:`Remove buttons, or split the template.`,channelOnly:!0}}),Cs=e=>Object.entries(Ss).some(([t,n])=>t===e&&`upgrade`in n);function ws(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!ws(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!ws(e[r],t[r]))return!1;return!0}return e===t}function Ts(e){return encodeURI(Es(e))}function Es(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}var Ds={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},Os={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},ks={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},As=typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);function js(e,t=Object.create(null),n=As,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:js(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(ks[i])continue;let a=`${r}/${Ts(i)}`,o=e[i];if(Array.isArray(o)){if(Ds[i]){let e=o.length;for(let r=0;r<e;r++)js(o[r],t,n,`${a}/${r}`)}}else if(Os[i])for(let e in o)js(o[e],t,n,`${a}/${Ts(e)}`);else js(o,t,n,a)}return t}var Ms=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Ns=[0,31,28,31,30,31,30,31,31,30,31,30,31],Ps=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Fs=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,Is=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,Ls=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Rs=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,zs=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Bs=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Vs=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Hs=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Us=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},Ws=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Gs=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Ks=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function qs(e){return e.test.bind(e)}var Js={date:Xs,time:Zs.bind(void 0,!1),"date-time":$s,duration:Ks,uri:nc,"uri-reference":qs(Is),"uri-template":qs(Ls),url:qs(Rs),email:Us,hostname:qs(Fs),ipv4:qs(Ws),ipv6:qs(Gs),regex:ic,uuid:qs(zs),"json-pointer":qs(Bs),"json-pointer-uri-fragment":qs(Vs),"relative-json-pointer":qs(Hs)};function Ys(e){return e%4==0&&(e%100!=0||e%400==0)}function Xs(e){let t=e.match(Ms);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&Ys(n)?29:Ns[r])}function Zs(e,t){let n=t.match(Ps);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var Qs=/t|\s/i;function $s(e){let t=e.split(Qs);return t.length==2&&Xs(t[0])&&Zs(!0,t[1])}var ec=/\/|:/,tc=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function nc(e){return ec.test(e)&&tc.test(e)}var rc=/[^\\]\\Z/;function ic(e){if(rc.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function ac(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function oc(e,t,n=`2019-09`,r=js(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,u;switch(l){case`boolean`:case`number`:case`string`:u=l;break;case`object`:u=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:g,required:_,not:v,anyOf:y,allOf:b,oneOf:x,if:S,then:C,else:w,format:T,properties:E,patternProperties:D,additionalProperties:O,unevaluatedProperties:k,minProperties:A,maxProperties:j,propertyNames:M,dependentRequired:N,dependentSchemas:P,dependencies:F,prefixItems:I,items:L,additionalItems:R,unevaluatedItems:ee,contains:z,minContains:te,maxContains:ne,minItems:re,maxItems:B,uniqueItems:ie,minimum:ae,maximum:oe,exclusiveMinimum:se,exclusiveMaximum:ce,multipleOf:le,minLength:V,maxLength:H,pattern:ue,__absolute_ref__:de,__absolute_recursive_ref__:fe}=t,U=[];if(p===!0&&a===null&&(a=t),f===`#`){let l=a===null?r[fe]:a,u=`${s}/$recursiveRef`,d=oc(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||U.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(d!==void 0){let t=r[de||d];if(t===void 0){let e=`Unresolved $ref "${d}".`;throw de&&de!==d&&(e+=` Absolute URI "${de}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
18
20
  - `)}`,Error(e)}let l=`${s}/$ref`,u=oc(e,t,n,r,i,a,o,l,c);if(u.valid||U.push({instanceLocation:o,keyword:`$ref`,keywordLocation:l,error:`A subschema had errors.`},...u.errors),n===`4`||n===`7`)return{valid:U.length===0,errors:U}}if(Array.isArray(m)){let t=m.length,n=!1;for(let r=0;r<t;r++)if(u===m[r]||m[r]===`integer`&&u===`number`&&e%1==0&&e===e){n=!0;break}n||U.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m.join(`", "`)}".`})}else m===`integer`?(u!==`number`||e%1||e!==e)&&U.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`}):m!==void 0&&u!==m&&U.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`});if(h!==void 0&&(u===`object`||u===`array`?ws(e,h)||U.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&U.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),g!==void 0&&(u===`object`||u===`array`?g.some(t=>ws(e,t))||U.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`}):g.some(t=>e===t)||U.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`})),v!==void 0){let t=`${s}/not`;oc(e,v,n,r,i,a,o,t).valid&&U.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let pe=[];if(y!==void 0){let t=`${s}/anyOf`,l=U.length,u=!1;for(let s=0;s<y.length;s++){let l=y[s],d=Object.create(c),f=oc(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);U.push(...f.errors),u||=f.valid,f.valid&&pe.push(d)}u?U.length=l:U.splice(l,0,{instanceLocation:o,keyword:`anyOf`,keywordLocation:t,error:`Instance does not match any subschemas.`})}if(b!==void 0){let t=`${s}/allOf`,l=U.length,u=!0;for(let s=0;s<b.length;s++){let l=b[s],d=Object.create(c),f=oc(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);U.push(...f.errors),u&&=f.valid,f.valid&&pe.push(d)}u?U.length=l:U.splice(l,0,{instanceLocation:o,keyword:`allOf`,keywordLocation:t,error:`Instance does not match every subschema.`})}if(x!==void 0){let t=`${s}/oneOf`,l=U.length,u=x.filter((s,l)=>{let u=Object.create(c),d=oc(e,s,n,r,i,p===!0?a:null,o,`${t}/${l}`,u);return U.push(...d.errors),d.valid&&pe.push(u),d.valid}).length;u===1?U.length=l:U.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((u===`object`||u===`array`)&&Object.assign(c,...pe),S!==void 0){let t=`${s}/if`;if(oc(e,S,n,r,i,a,o,t,c).valid){if(C!==void 0){let l=oc(e,C,n,r,i,a,o,`${s}/then`,c);l.valid||U.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(w!==void 0){let l=oc(e,w,n,r,i,a,o,`${s}/else`,c);l.valid||U.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(u===`object`){if(_!==void 0)for(let t of _)t in e||U.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(A!==void 0&&t.length<A&&U.push({instanceLocation:o,keyword:`minProperties`,keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${A} properties.`}),j!==void 0&&t.length>j&&U.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${j} properties.`}),M!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${Ts(s)}`,c=oc(s,M,n,r,i,a,e,t);c.valid||U.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(N!==void 0){let t=`${s}/dependantRequired`;for(let n in N)if(n in e){let r=N[n];for(let i of r)i in e||U.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(P!==void 0)for(let t in P){let l=`${s}/dependentSchemas`;if(t in e){let s=oc(e,P[t],n,r,i,a,o,`${l}/${Ts(t)}`,c);s.valid||U.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(F!==void 0){let t=`${s}/dependencies`;for(let s in F)if(s in e){let c=F[s];if(Array.isArray(c))for(let n of c)n in e||U.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=oc(e,c,n,r,i,a,o,`${t}/${Ts(s)}`);l.valid||U.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(E!==void 0){let t=`${s}/properties`;for(let s in E){if(!(s in e))continue;let d=`${o}/${Ts(s)}`,f=oc(e[s],E[s],n,r,i,a,d,`${t}/${Ts(s)}`);if(f.valid)c[s]=l[s]=!0;else if(u=i,U.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),u)break}}if(!u&&D!==void 0){let t=`${s}/patternProperties`;for(let s in D){let d=new RegExp(s,`u`),f=D[s];for(let p in e){if(!d.test(p))continue;let m=`${o}/${Ts(p)}`,h=oc(e[p],f,n,r,i,a,m,`${t}/${Ts(s)}`);h.valid?c[p]=l[p]=!0:(u=i,U.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...h.errors))}}}if(!u&&O!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let d=`${o}/${Ts(s)}`,f=oc(e[s],O,n,r,i,a,d,t);f.valid?c[s]=!0:(u=i,U.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}else if(!u&&k!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${Ts(s)}`,u=oc(e[s],k,n,r,i,a,l,t);u.valid?c[s]=!0:U.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(u===`array`){B!==void 0&&e.length>B&&U.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${B}).`}),re!==void 0&&e.length<re&&U.push({instanceLocation:o,keyword:`minItems`,keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${re}).`});let t=e.length,l=0,u=!1;if(I!==void 0){let d=`${s}/prefixItems`,f=Math.min(I.length,t);for(;l<f;l++){let t=oc(e[l],I[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,U.push({instanceLocation:o,keyword:`prefixItems`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}if(L!==void 0){let d=`${s}/items`;if(Array.isArray(L)){let s=Math.min(L.length,t);for(;l<s;l++){let t=oc(e[l],L[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,U.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}else for(;l<t;l++){let t=oc(e[l],L,n,r,i,a,`${o}/${l}`,d);if(c[l]=!0,!t.valid&&(u=i,U.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}if(!u&&R!==void 0){let d=`${s}/additionalItems`;for(;l<t;l++){let t=oc(e[l],R,n,r,i,a,`${o}/${l}`,d);c[l]=!0,t.valid||(u=i,U.push({instanceLocation:o,keyword:`additionalItems`,keywordLocation:d,error:`Items did not match additional items schema.`},...t.errors))}}}if(z!==void 0){if(t===0&&te===void 0)U.push({instanceLocation:o,keyword:`contains`,keywordLocation:`${s}/contains`,error:`Array is empty. It must contain at least one item matching the schema.`});else if(te!==void 0&&t<te)U.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${te}).`});else{let l=`${s}/contains`,u=U.length,d=0;for(let s=0;s<t;s++){let t=oc(e[s],z,n,r,i,a,`${o}/${s}`,l);t.valid?(c[s]=!0,d++):U.push(...t.errors)}d>=(te||0)&&(U.length=u),te===void 0&&ne===void 0&&d===0?U.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):te!==void 0&&d<te?U.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array must contain at least ${te} items matching schema. Only ${d} items were found.`}):ne!==void 0&&d>ne&&U.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${ne} items matching schema. ${d} items were found.`})}}if(!u&&ee!==void 0){let u=`${s}/unevaluatedItems`;for(;l<t;l++){if(c[l])continue;let t=oc(e[l],ee,n,r,i,a,`${o}/${l}`,u);c[l]=!0,t.valid||U.push({instanceLocation:o,keyword:`unevaluatedItems`,keywordLocation:u,error:`Items did not match unevaluated items schema.`},...t.errors)}}if(ie)for(let n=0;n<t;n++){let r=e[n],i=typeof r==`object`&&!!r;for(let a=0;a<t;a++){if(n===a)continue;let t=e[a];(r===t||i&&typeof t==`object`&&t&&ws(r,t))&&(U.push({instanceLocation:o,keyword:`uniqueItems`,keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${n} and ${a}.`}),n=2**53-1,a=2**53-1)}}}else if(u===`number`){if(n===`4`?(ae!==void 0&&(se===!0&&e<=ae||e<ae)&&U.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${se?`or equal to `:``} ${ae}.`}),oe!==void 0&&(ce===!0&&e>=oe||e>oe)&&U.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${ce?`or equal to `:``} ${oe}.`})):(ae!==void 0&&e<ae&&U.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${ae}.`}),oe!==void 0&&e>oe&&U.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${oe}.`}),se!==void 0&&e<=se&&U.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${se}.`}),ce!==void 0&&e>=ce&&U.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${ce}.`})),le!==void 0){let t=e%le;Math.abs(0-t)>=1.1920929e-7&&Math.abs(le-t)>=1.1920929e-7&&U.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${le}.`})}}else if(u===`string`){let t=V===void 0&&H===void 0?0:ac(e);V!==void 0&&t<V&&U.push({instanceLocation:o,keyword:`minLength`,keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${V}).`}),H!==void 0&&t>H&&U.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${H}).`}),ue!==void 0&&!new RegExp(ue,`u`).test(e)&&U.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),T!==void 0&&Js[T]&&!Js[T](e)&&U.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${T}".`})}return{valid:U.length===0,errors:U}}var sc=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=js(e)}validate(e){return oc(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),js(e,this.lookup)}},cc={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/applicator`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:`meta`,title:`Applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{prefixItems:{$ref:`#/$defs/schemaArray`},items:{$dynamicRef:`#meta`},contains:{$dynamicRef:`#meta`},additionalProperties:{$dynamicRef:`#meta`},properties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},patternProperties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},propertyNames:{$dynamicRef:`#meta`},if:{$dynamicRef:`#meta`},then:{$dynamicRef:`#meta`},else:{$dynamicRef:`#meta`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$dynamicRef:`#meta`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$dynamicRef:`#meta`}}}},lc={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/content`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Content vocabulary meta-schema`,type:[`object`,`boolean`],properties:{contentEncoding:{type:`string`},contentMediaType:{type:`string`},contentSchema:{$dynamicRef:`#meta`}}},uc={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/core`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:`meta`,title:`Core vocabulary meta-schema`,type:[`object`,`boolean`],properties:{$id:{$ref:`#/$defs/uriReferenceString`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{$ref:`#/$defs/uriString`},$ref:{$ref:`#/$defs/uriReferenceString`},$anchor:{$ref:`#/$defs/anchorString`},$dynamicRef:{$ref:`#/$defs/uriReferenceString`},$dynamicAnchor:{$ref:`#/$defs/anchorString`},$vocabulary:{type:`object`,propertyNames:{$ref:`#/$defs/uriString`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$dynamicRef:`#meta`}}},$defs:{anchorString:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},uriString:{type:`string`,format:`uri`},uriReferenceString:{type:`string`,format:`uri-reference`}}},dc={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/format-annotation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:`meta`,title:`Format vocabulary meta-schema for annotation results`,type:[`object`,`boolean`],properties:{format:{type:`string`}}},fc={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/meta-data`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:`meta`,title:`Meta-data vocabulary meta-schema`,type:[`object`,`boolean`],properties:{title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}}},pc={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/unevaluated`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:`meta`,title:`Unevaluated applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{unevaluatedItems:{$dynamicRef:`#meta`},unevaluatedProperties:{$dynamicRef:`#meta`}}},mc={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/validation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:`meta`,title:`Validation vocabulary meta-schema`,type:[`object`,`boolean`],properties:{type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}}},$defs:{nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}},hc=new sc({$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/schema`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Core and Validation specifications meta-schema`,allOf:[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/unevaluated`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format-annotation`},{$ref:`meta/content`}],type:[`object`,`boolean`],$comment:`This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.`,properties:{definitions:{$comment:`"definitions" has been replaced by "$defs".`,type:`object`,additionalProperties:{$dynamicRef:`#meta`},deprecated:!0,default:{}},dependencies:{$comment:`"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.`,type:`object`,additionalProperties:{anyOf:[{$dynamicRef:`#meta`},{$ref:`meta/validation#/$defs/stringArray`}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:`"$recursiveAnchor" has been replaced by "$dynamicAnchor".`,$ref:`meta/core#/$defs/anchorString`,deprecated:!0},$recursiveRef:{$comment:`"$recursiveRef" has been replaced by "$dynamicRef".`,$ref:`meta/core#/$defs/uriReferenceString`,deprecated:!0}}},`2020-12`,!1);for(let e of[cc,lc,uc,dc,fc,pc,mc])hc.addSchema(e);var gc=e=>Array.isArray(e)?e.map(gc):is(e)?Object.fromEntries(Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>[e,gc(t)])):e,_c=new Set([`title`,`description`,`default`,`examples`,`deprecated`,`readOnly`,`writeOnly`,`$comment`]),vc=new Set([`$schema`,`$ref`,`type`,`enum`,`const`,`required`,`minProperties`,`maxProperties`,`minItems`,`maxItems`,`uniqueItems`,`minLength`,`maxLength`,`pattern`,`minimum`,`maximum`,`exclusiveMinimum`,`exclusiveMaximum`,`multipleOf`]),yc=new Set([`properties`,`$defs`,`patternProperties`,`dependentSchemas`]),bc=new Set([`additionalProperties`,`items`,`contains`,`not`,`if`,`then`,`else`,`propertyNames`]),xc=new Set([`allOf`,`anyOf`,`oneOf`,`prefixItems`]),Sc=(e,t=`#`)=>{if(typeof e==`boolean`)return e;if(!is(e))throw TypeError(`Invalid schema at ${t}`);let n=hc.validate(e);if(!n.valid)throw TypeError(`Invalid JSON Schema at ${t}: ${JSON.stringify(n.errors)}`);let r={};for(let[n,i]of Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t)))if(!_c.has(n)){if(yc.has(n)){if(!is(i))throw TypeError(`Invalid ${t}/${n}`);r[n]=Object.fromEntries(Object.entries(i).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,r])=>[e,Sc(r,`${t}/${n}/${e}`)]))}else if(bc.has(n))r[n]=Sc(i,`${t}/${n}`);else if(xc.has(n)){if(!Array.isArray(i))throw TypeError(`Invalid ${t}/${n}`);r[n]=i.map((e,r)=>Sc(e,`${t}/${n}/${r}`))}else if(vc.has(n)){if(n===`$ref`&&(typeof i!=`string`||!(i===`#`||i.startsWith(`#/`))))throw TypeError(`Only local JSON Pointer references are supported at ${t}/$ref`);if(n===`$schema`&&i!==`https://json-schema.org/draft/2020-12/schema`)throw TypeError(`Expected JSON Schema 2020-12 at ${t}`);r[n]=gc(i)}else throw TypeError(`Unsupported input schema keyword ${t}/${n}`)}return r},Cc=e=>({"~standard":{version:1,vendor:`samva-json-schema`,jsonSchema:{input:()=>e,output:()=>e}}}),wc=e=>{let t=e[`~standard`].vendor;if(t!==`effect`&&t!==`zod`)return;let n=new WeakSet,r=e=>{if(Array.isArray(e)){for(let t of e)r(t);return}if(is(e)&&!n.has(e)){if(n.add(e),t===`zod`&&is(e._zod)){r(e._zod.def);return}if(t===`effect`&&e.encoding!==void 0)throw TypeError(`Nonportable Effect transform; use a JSON input schema without decoding transforms`);if(t===`effect`&&e._tag===`Suspend`)throw TypeError(`Unsupported suspended Effect converter; use local JSON Schema references`);if(t===`zod`&&e.type===`lazy`)throw TypeError(`Unsupported lazy Zod converter; author recursive input with local JSON Schema references`);if(t===`zod`&&(e.check===`custom`||e.check===`overwrite`||[`transform`,`default`,`prefault`,`catch`].includes(String(e.type))))throw TypeError(`Nonportable Zod refinement/transform; express constraints in JSON Schema`);if(t===`effect`&&e._tag===`Filter`&&(!is(e.annotations)||typeof e.annotations.toJsonSchema!=`function`))throw TypeError(`Nonportable Effect refinement; provide a JSON Schema constraint`);for(let[t,n]of Object.entries(e))t!==`~standard`&&t!==`annotations`&&r(n)}};t===`effect`&&as(e,`ast`)?r(e.ast):r(e)},Tc=e=>{wc(e);let t=e[`~standard`].jsonSchema,n=structuredClone(t.input({target:`draft-2020-12`})),r=Sc(n),i=Sc(t.output({target:`draft-2020-12`}));if(JSON.stringify(r)!==JSON.stringify(i))throw TypeError(`Template schemas must preserve JSON input; input/output conversion differs`);let a=new sc(n,`2020-12`,!1),o=e=>{let t=a.validate(e);return o.errors=t.errors,t.valid};return o.errors=[],{schema:n,validationIdentity:JSON.stringify(r),validate:o}},Ec=/^[A-Za-z0-9_][A-Za-z0-9._-]*$/,Dc=/^(?=.{1,100}$)[a-z0-9]+(?:-[a-z0-9]+)*$/,Oc=[`money`,`number`,`date`,`time`,`plural`,`list`],kc=Symbol(`samva.unsubscribe-link`),Ac=Symbol(`samva.brand-footer-marker`),jc={specifier:`samva:brand`,footerAttribute:`data-samva-footer`,unsubscribeRowAttribute:`data-samva-unsubscribe`,unsubscribeUrlPlaceholder:`%samva:unsubscribe-url%`,noTrackAttribute:`data-samva-no-track`},Mc=`[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?`,Nc=e=>e.replace(/[.*+?^${}()|[\]\\/]/g,`\\$&`),Pc=(e,t=jc)=>{let n=RegExp(`^${Nc(t.specifier)}(?:\\/(${Mc}))?$`).exec(e);return n===null?void 0:{slug:n[1]}},Fc=e=>new Set([e.footerAttribute,e.unsubscribeRowAttribute,e.noTrackAttribute]),Ic={id:{type:`string`},title:{type:`string`},lang:{type:`string`},dir:{type:`string`,values:[`ltr`,`rtl`,`auto`]},role:{type:`string`}},Lc={type:`string`,values:[`left`,`center`,`right`]},Rc={type:`string`,values:[`top`,`middle`,`bottom`]},zc={align:Lc},Bc={align:Lc,valign:Rc,width:{type:`measure`},height:{type:`measure`},bgcolor:{type:`string`},colspan:{type:`number`},rowspan:{type:`number`}},Vc=e=>({content:`flow`,layout:`block`,attributes:e}),Hc=()=>({content:`flow`,layout:`inline`,attributes:{}}),Uc={html:{content:`flow`,layout:`document`,attributes:{xmlns:{type:`string`},"xmlns:o":{type:`string`},"xmlns:v":{type:`string`},"xmlns:w":{type:`string`}},childElements:[`head`,`body`]},head:{content:`flow`,layout:`metadata`,attributes:{},childElements:[`title`,`meta`,`style`]},title:{content:`text`,layout:`metadata`,attributes:{}},style:{content:`raw`,layout:`metadata`,attributes:{type:{type:`string`}}},meta:{content:`void`,layout:`metadata`,attributes:{name:{type:`string`},content:{type:`string`},charset:{type:`string`},"http-equiv":{type:`string`}}},body:{content:`flow`,layout:`block`,attributes:{bgcolor:{type:`string`}}},div:Vc(zc),section:Vc(zc),article:Vc(zc),header:Vc(zc),footer:Vc(zc),main:Vc(zc),center:Vc({}),p:Vc(zc),blockquote:Vc(zc),pre:{content:`flow`,layout:`preformatted`,attributes:{}},h1:Vc(zc),h2:Vc(zc),h3:Vc(zc),h4:Vc(zc),h5:Vc(zc),h6:Vc(zc),span:Hc(),strong:Hc(),b:Hc(),em:Hc(),i:Hc(),u:Hc(),s:Hc(),small:Hc(),code:Hc(),a:{content:`flow`,layout:`link`,attributes:{href:{type:`url`,required:!0},target:{type:`string`},rel:{type:`string`},name:{type:`string`}}},img:{content:`void`,layout:`image`,attributes:{src:{type:`url`,required:!0},alt:{type:`string`,required:!0},width:{type:`measure`},height:{type:`measure`},border:{type:`measure`},align:Lc}},table:{content:`flow`,layout:`table`,attributes:{width:{type:`measure`},height:{type:`measure`},border:{type:`measure`},cellpadding:{type:`measure`},cellspacing:{type:`measure`},align:Lc,bgcolor:{type:`string`}},childElements:[`caption`,`colgroup`,`thead`,`tbody`,`tfoot`,`tr`]},caption:{content:`flow`,layout:`block`,attributes:zc},colgroup:{content:`flow`,layout:`table-section`,attributes:{span:{type:`number`},width:{type:`measure`}},childElements:[`col`]},col:{content:`void`,layout:`table-section`,attributes:{span:{type:`number`},width:{type:`measure`}}},thead:{content:`flow`,layout:`table-section`,attributes:{align:Lc,valign:Rc,bgcolor:{type:`string`}},childElements:[`tr`]},tbody:{content:`flow`,layout:`table-section`,attributes:{align:Lc,valign:Rc,bgcolor:{type:`string`}},childElements:[`tr`]},tfoot:{content:`flow`,layout:`table-section`,attributes:{align:Lc,valign:Rc,bgcolor:{type:`string`}},childElements:[`tr`]},tr:{content:`flow`,layout:`row`,attributes:{align:Lc,valign:Rc,bgcolor:{type:`string`},height:{type:`measure`}},childElements:[`td`,`th`]},td:{content:`flow`,layout:`cell`,attributes:Bc},th:{content:`flow`,layout:`cell`,attributes:Bc},ul:{content:`flow`,layout:`list`,attributes:{},childElements:[`li`]},ol:{content:`flow`,layout:`list`,attributes:{start:{type:`number`},type:{type:`string`}},childElements:[`li`]},li:{content:`flow`,layout:`list-item`,attributes:{}},br:{content:`void`,layout:`break`,attributes:{}},hr:{content:`void`,layout:`rule`,attributes:{width:{type:`measure`},size:{type:`number`},align:Lc}}},Wc=e=>Object.hasOwn(Uc,e)?Uc[e]:void 0,Gc=`data-samva-instance`,Kc=e=>`${e.fileName}:${e.lineNumber}:${e.columnNumber}`,qc=e=>`${e.tag}\u0000${e.origins.map(Kc).join(`\0`)}`,Jc=e=>new Map(e.map(e=>[e.instancePath,e])),Yc=(e,t)=>{let n=qc(t);return e.filter(e=>qc(e)===n)},Xc=(e,t)=>{let n=t.origins[0],r=`${t.tag}\u0000${n===void 0?``:Kc(n)}`;return e.filter(e=>{let t=e.origins[0];return`${e.tag}\u0000${t===void 0?``:Kc(t)}`===r})},Zc=e=>e.replace(/[&<>]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`})[e]??e),Qc=e=>e.replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]??e),$c=/[\u0000-\u001f\u007f]/,el=/^(https:\/\/|mailto:|tel:|cid:|#)/i,tl=/^(\.{1,2}\/|\/(?!\/))/,nl=(e,t)=>!/^[\u0000-\u0020]/.test(e)&&!$c.test(e)&&!e.includes(`\\`)&&(el.test(e)||t&&tl.test(e)),rl=/^(--[a-zA-Z0-9-]+|[a-zA-Z][a-zA-Z0-9-]*)$/,il=/[;{}<>\\]|expression\s*\(|@import|\/\*/i,al=/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi,ol=e=>e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),sl=new Set([`opacity`,`zIndex`,`fontWeight`,`lineHeight`,`order`,`flexGrow`,`flexShrink`,`columnCount`,`orphans`,`widows`,`zoom`,`fillOpacity`,`strokeOpacity`]),cl=(e,t)=>typeof t==`number`&&t!==0&&!sl.has(e)&&!e.startsWith(`--`)?`${t}px`:String(t),ll=(e,t,n,r,i=`error`)=>{e.diagnostics.push({code:t,severity:i,message:n,origins:r})},ul=(e,t,n)=>{let r=[];for(let[i,a]of Object.entries(t)){if(a==null)continue;if(!rl.test(i)){ll(e,`unsupported-style-property`,`Style property ${JSON.stringify(i)} is not a CSS property name; write it in camelCase (backgroundColor) or as a custom property (--brand).`,n);continue}if(typeof a!=`string`&&typeof a!=`number`){ll(e,`invalid-style-value`,`Style ${i} must be a string or number, not ${typeof a}.`,n);continue}let t=cl(i,a);if(il.test(t)||$c.test(t)){ll(e,`unsafe-style-value`,`Style ${i} contains CSS that could break out of the declaration; remove ${JSON.stringify(t)}.`,n);continue}let o;for(let n of t.matchAll(al))nl(n[2]??``,e.relativeUrls)||(o=n[2]??``);if(o!==void 0){ll(e,`unsafe-url`,`Style ${i} points at ${JSON.stringify(o)}; email URLs must use https:, mailto:, tel:, cid: or a fragment${e.relativeUrls?`, or a relative path`:``}.`,n);continue}r.push(`${ol(i)}:${t}`)}return r.join(`;`)},dl=(e,t,n,r,i,a)=>{if(i==null||i===!1)return;if(i===!0)return``;if(typeof i!=`string`&&typeof i!=`number`){ll(e,`invalid-attribute-value`,`<${t} ${n}> must be a string or number, not ${typeof i}.`,a);return}let o=String(i);if($c.test(o)){ll(e,`invalid-attribute-value`,`<${t} ${n}> contains control characters.`,a);return}if(r.values!==void 0&&!r.values.includes(o)){ll(e,`invalid-attribute-value`,`<${t} ${n}> accepts ${r.values.join(`, `)}; received ${JSON.stringify(o)}.`,a);return}if(r.type===`number`&&!/^-?\d+$/.test(o)){ll(e,`invalid-attribute-value`,`<${t} ${n}> must be an integer.`,a);return}if(r.type===`measure`&&!/^\d+(\.\d+)?%?$/.test(o)){ll(e,`invalid-attribute-value`,`<${t} ${n}> must be a pixel count or a percentage.`,a);return}if(r.type===`url`&&!nl(o,e.relativeUrls)){ll(e,`unsafe-url`,e.relativeUrls?`<${t} ${n}> must use https:, mailto:, tel:, cid:, a fragment, or a relative path; received ${JSON.stringify(o)}.`:`<${t} ${n}> must use https:, mailto:, tel:, cid: or a fragment; received ${JSON.stringify(o)}. A relative path resolves only in an export, never in a delivered message.`,a);return}return o},fl=e=>{let t=e.brandPlugin??jc;return{diagnostics:[],positions:[],written:0,relativeUrls:e.relativeUrls===!0,instancePaths:e.instancePaths===!0,brandPlugin:t,reservedAttributes:Fc(t)}},pl=(e,t)=>{let n=fl({});return{css:ul(n,e,t),diagnostics:n.diagnostics}},ml=(e,t,n,r)=>{let i=fl({}),a=Wc(e),o=Ic,s=(()=>{if(/^(data|aria)-[a-z0-9-]+$/.test(t))return{type:`string`};if(Object.hasOwn(o,t))return o[t];if(a!==void 0&&Object.hasOwn(a.attributes,t))return a.attributes[t]})();return s===void 0?{text:void 0,diagnostics:i.diagnostics}:{text:dl(i,e,t,s,n,r),diagnostics:i.diagnostics}},hl=(e,t,n={})=>ys(`table`,{role:`presentation`,border:0,cellpadding:0,cellspacing:0,...e,children:ys(`tbody`,{children:ys(`tr`,{...n,children:t})})}),gl=({className:e,lang:t=`en`,dir:n=`ltr`,title:r,backgroundColor:i,style:a,children:o})=>ys(`html`,{lang:t,dir:n,xmlns:`http://www.w3.org/1999/xhtml`,"xmlns:o":`urn:schemas-microsoft-com:office:office`,children:[ys(`head`,{children:[ys(`meta`,{charset:`utf-8`}),ys(`meta`,{"http-equiv":`Content-Type`,content:`text/html; charset=UTF-8`}),ys(`meta`,{name:`viewport`,content:`width=device-width, initial-scale=1`}),ys(`meta`,{name:`x-apple-disable-message-reformatting`}),ys(`meta`,{name:`color-scheme`,content:`light dark`}),ys(`meta`,{name:`supported-color-schemes`,content:`light dark`}),r===void 0?null:ys(`title`,{children:r}),vs(`<!--[if mso]><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]-->`)]}),ys(`body`,{style:{margin:0,padding:0,...i===void 0?{}:{backgroundColor:i}},children:[hl({align:`center`,width:`100%`,...i===void 0?{}:{bgcolor:i}},ys(`td`,{className:e,...a===void 0?{}:{style:a},children:o}))]})]}),_l=({className:e,align:t=`center`,width:n=`100%`,bgcolor:r,style:i,tableStyle:a,children:o})=>hl({align:t,width:n,...r===void 0?{}:{bgcolor:r},...a===void 0?{}:{style:a}},ys(`td`,{className:e,...i===void 0?{}:{style:i},children:o})),vl=e=>`${Math.floor(100/e)}%`,yl=(e,t)=>{if(e.type===`Fragment`)return cs.Fragment({children:e.children.map(e=>yl(e,t))});if(e.type!==`Element`||e.tag!==`td`||e.props.width!==void 0)return e;let n={};for(let[r,i]of Object.entries(e.props))r===`style`&&(n.width=t),n[r]=i;return n.width===void 0&&(n.width=t),cs.Element({...e,props:n})},bl=({className:e,align:t=`center`,width:n=`100%`,style:r,each:i,per:a,children:o})=>{let s={className:e,align:t,width:n,...r===void 0?{}:{style:r}};if(i===void 0||typeof o!=`function`)return hl(s,o,{style:{width:`100%`}});a!==void 0&&(!Number.isInteger(a)||a<1)&&hs({code:`invalid-columns-per`,severity:`error`,message:`<Columns per> must be a positive integer.`});let c=a!==void 0&&Number.isInteger(a)&&a>=1?a:void 0,l=[];if(c===void 0)l.push(i);else for(let e=0;e<i.length;e+=c)l.push(i.slice(e,e+c));let u=vl(c??Math.max(i.length,1));return ys(ds,{children:l.map(e=>hl(s,e.flatMap((e,t)=>_s(o(e,t)).map(e=>yl(e,u))),{style:{width:`100%`}}))})},xl=({className:e,align:t,valign:n,width:r,style:i,children:a})=>ys(`td`,{className:e,...t===void 0?{}:{align:t},...n===void 0?{}:{valign:n},...r===void 0?{}:{width:r},...i===void 0?{}:{style:i},children:a}),Sl=`Helvetica, Arial, sans-serif`,Cl=.6,wl=e=>hs({code:`invalid-button-number`,severity:`error`,message:`<Button ${e}> must be a finite number.`}),Tl=(e,t,n)=>typeof t==`number`&&Number.isFinite(t)?t:(wl(e),n),El=(e,t)=>{if(t!==void 0){if(typeof t==`number`&&Number.isFinite(t))return t;wl(e)}},Dl=(e,t)=>{if(t!==void 0){if(typeof t==`number`&&Number.isFinite(t)&&t>0)return t;hs({code:`invalid-button-number`,severity:`error`,message:`<Button ${e}> must be a positive finite number.`})}},Ol=({className:e,href:t,width:n,height:r,paddingX:i=16,backgroundColor:a=`#000000`,color:o=`#ffffff`,borderRadius:s=0,borderColor:c,borderWidth:l=0,fontSize:u=16,fontFamily:d=Sl,align:f=`left`,style:p,children:m})=>{let h=El(`width`,n),g=Dl(`height`,r),_=Tl(`paddingX`,i,16),v=Tl(`borderRadius`,s,0),y=Tl(`borderWidth`,l,0),b=Tl(`fontSize`,u,16),x=typeof m==`string`?m:void 0,S=g!==void 0&&x!==void 0;S||hs({code:`button-outlook-fallback`,severity:`warning`,message:`<Button> draws its classic Outlook shape from VML, which needs a height and a plain string label. Without both, classic Windows Outlook shows an unstyled link.`,clients:[`outlook-windows`]});let C=g===void 0?0:Math.round(v/g*100),w=h??Math.ceil((x?.length??0)*b*Cl)+2*_;return hl({width:`100%`,style:{borderCollapse:`collapse`}},ys(`td`,{align:f,children:[S?vs(`<!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="${Qc(t)}" style="height:${g}px;v-text-anchor:middle;width:${w}px;" arcsize="${C}%" ${c===void 0?`stroke="false"`:`strokecolor="${Qc(c)}" strokeweight="${y}px"`} fillcolor="${Qc(a)}"><w:anchorlock/><center style="color:${Qc(o)};font-family:${Qc(d)};font-size:${b}px;font-weight:bold;">${Zc(x)}</center></v:roundrect><![endif]-->`):null,ys(`a`,{className:e,href:t,target:`_blank`,rel:`noopener noreferrer`,style:{backgroundColor:a,color:o,borderRadius:`${v}px`,display:`inline-block`,fontFamily:d,fontSize:`${b}px`,fontWeight:`bold`,lineHeight:g===void 0?`120%`:`${g-2*y}px`,textAlign:`center`,textDecoration:`none`,...h===void 0?{padding:`0 ${_}px`}:{width:`${h}px`,maxWidth:`100%`},...c===void 0?{}:{border:`${y}px solid ${c}`},...S?{msoHide:`all`}:{},...p},children:m})]}))},kl=({height:e})=>hl({width:`100%`},ys(`td`,{height:e,style:{height:`${e}px`,lineHeight:`${e}px`,fontSize:`1px`},children:`​`})),Al=({className:e,color:t=`#e5e7eb`,thickness:n=1,style:r})=>hl({width:`100%`},ys(`td`,{className:e,style:{borderTop:`${n}px solid ${t}`,fontSize:`1px`,lineHeight:`1px`,...r},children:`​`})),jl=({className:e,src:t,alt:n,width:r,height:i,align:a,style:o})=>ys(`img`,{className:e,src:t,alt:n,border:0,...r===void 0?{}:{width:r},...i===void 0?{}:{height:i},...a===void 0?{}:{align:a},style:{display:`block`,outline:`none`,border:`none`,textDecoration:`none`,maxWidth:`100%`,...o}}),Ml=({className:e,href:t,target:n=`_blank`,rel:r=`noopener noreferrer`,style:i,children:a})=>ys(`a`,{className:e,href:t,target:n,rel:r,style:{color:`#067df7`,textDecoration:`none`,...i},children:a}),Nl=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`]),Pl=e=>{let t=e.trim(),n=t[0];return(n===`"`||n===`'`)&&t.endsWith(n)&&t.length>=2?t.slice(1,-1):t.replace(/\s+/g,` `)},Fl=e=>{let t=[],n=0,r;for(let i=0;i<e.length;i++){let a=e[i];r===void 0?a===`'`||a===`"`?r=a:a===`,`&&(t.push(Pl(e.slice(n,i))),n=i+1):a===r&&(r=void 0)}return t.push(Pl(e.slice(n))),t.filter(e=>e!==``)},Il=/^(?:xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large|larger|smaller|[+-]?(?:\d+\.?\d*|\.\d+)(?:[a-z]+|%)|(?:calc|clamp|min|max|var)\(.*\))$/i,Ll=e=>{let t=[],n=``,r=0,i;for(let a of e.trim()){if(i!==void 0)a===i&&(i=void 0);else if(a===`'`||a===`"`)i=a;else if(a===`(`)r++;else if(a===`)`)r--;else if(/\s/.test(a)&&r===0){n!==``&&t.push(n),n=``;continue}n+=a}return n!==``&&t.push(n),t},Rl=e=>{let t=Ll(e),n=t.findIndex(e=>Il.test(e.replace(/\/.*$/,``)));if(n<0)return;let r=n+1,i=t[n];i.endsWith(`/`)?r+=1:!i.includes(`/`)&&t[r]?.startsWith(`/`)&&(r+=t[r]===`/`?2:1);let a=t.slice(r).join(` `);return a===``?void 0:a},zl=(e,t)=>{let n=e.replace(/\s*!important\s*$/i,``);if(!Fl(n).some(e=>t.has(e.toLowerCase())))return!1;let r=n.slice(n.lastIndexOf(`,`)+1).trim();return!Nl.has(r.toLowerCase())},Bl=e=>({code:`email-font-fallback`,severity:`error`,message:`font-family ${JSON.stringify(e)} uses a project font without a generic fallback. Clients that drop webfonts (Gmail, classic Outlook) render this stack as written, so end it with sans-serif, serif or monospace.`}),Vl=65536,Hl=262144,Ul=(e,t,n,r,i)=>{if(e.length>i.remaining||(i.remaining-=e.length,e.length>r))return;if(n>8||!e.includes(`var(`))return e;let a=[],o=0,s=e=>(o+=e.length,o>r?!1:(a.push(e),!0)),c=0;for(;c<e.length;){let a=e.indexOf(`var(`,c);if(a<0){if(!s(e.slice(c)))return;break}if(!s(e.slice(c,a)))return;let l=0,u=-1;for(let t=a+3;t<e.length;t++)if(e[t]===`(`)l+=1;else if(e[t]===`)`&&(--l,l===0)){u=t;break}if(u<0){if(!s(e.slice(a)))return;break}let d=e.slice(a+4,u),f=d.indexOf(`,`),p=(f<0?d:d.slice(0,f)).trim(),m=f<0?void 0:d.slice(f+1).trim(),h=t[p]??m,g=h===void 0?e.slice(a,u+1):Ul(h,t,n+1,r-o,i);if(g===void 0||!s(g))return;c=u+1}return a.join(``)},Wl=(e,t,n=0)=>Ul(e,t,n,Vl,{remaining:Hl})??e,Gl=e=>{if(!e.includes(`calc(`))return e;let t=``,n=e;for(;n.length>0;){let e=n.indexOf(`calc(`);if(e<0){t+=n;break}t+=n.slice(0,e);let r=0,i=-1;for(let t=e+4;t<n.length;t++)if(n[t]===`(`)r+=1;else if(n[t]===`)`&&(--r,r===0)){i=t;break}if(i<0){t+=n.slice(e);break}let a=ql(n.slice(e+5,i));t+=a===void 0?n.slice(e,i+1):Kl(a),n=n.slice(i+1)}return t},Kl=e=>`${Math.round(e.n*1e6)/1e6}${e.n===0&&e.unit!==`%`?``:e.unit}`,ql=e=>{let t=e.match(/\(|\)|[+-]\s|[*/]|[^\s()*/]+/g);if(t===null)return;let n=0,r=()=>t[n]?.trim(),i=()=>{let e=a();for(;e!==void 0&&(r()===`+`||r()===`-`);){let t=r();n+=1;let i=a();if(i===void 0||e.unit!==i.unit)return;e={n:t===`+`?e.n+i.n:e.n-i.n,unit:e.unit}}return e},a=()=>{let e=o();for(;e!==void 0&&(r()===`*`||r()===`/`);){let t=r();n+=1;let i=o();if(i===void 0)return;if(t===`*`){if(e.unit!==``&&i.unit!==``)return;e={n:e.n*i.n,unit:e.unit===``?i.unit:e.unit}}else{if(i.unit!==``||i.n===0)return;e={n:e.n/i.n,unit:e.unit}}}return e},o=()=>{let e=t[n];if(e===void 0)return;if(e===`(`){n+=1;let e=i();return r()===`)`?(n+=1,e):void 0}let a=/^(-?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i.exec(e.trim());if(a!==null)return n+=1,{n:Number.parseFloat(a[1]),unit:(a[2]??``).toLowerCase()}},s=i();return n===t.length?s:void 0},Jl=(e,t)=>Gl(Wl(e,t)),Yl=/\(\s*([a-z-]+)\s*(<=|>=|<|>)\s*([^)]+?)\s*\)/gi,Xl=e=>e.replace(Yl,(e,t,n,r)=>`(${n.startsWith(`>`)?`min-`:`max-`}${t}:${r})`),Zl=(e,t,n)=>{let r=[...t],i=new Map;for(let t of e){let e=t.conditions.map(Xl),n=e.join(`\0`),r=i.get(n);r===void 0?i.set(n,{conditions:e,rules:[t]}):r.rules.push(t)}for(let{conditions:e,rules:t}of i.values()){let i=t.map(e=>{let t=e.declarations.filter(e=>!e.property.startsWith(`--`)).map(e=>`${e.property}:${Jl(e.value,n)}!important`).join(`;`);return t===``?``:`${e.selector}{${t}}`}).filter(e=>e!==``).join(``);i!==``&&r.push(e.reduceRight((e,t)=>`${t}{${e}}`,i))}return r.join(``)},Ql=e=>{let t=e.props.class??e.props.className;return typeof t==`string`?t.split(/\s+/).filter(e=>e!==``):[]},$l=(e,t)=>{let n=e.props[t];if(n!=null&&n!==!1)return n===!0?``:typeof n==`string`||typeof n==`number`?String(n):void 0},eu=(e,t)=>{let n=t.name===`class`?Ql(e).join(` `):$l(e,t.name);if(n===void 0)return!1;if(t.operator===void 0||t.value===void 0)return!0;switch(t.operator){case`=`:return n===t.value;case`~=`:return n.split(/\s+/).includes(t.value);case`^=`:return n.startsWith(t.value);case`$=`:return n.endsWith(t.value);case`*=`:return n.includes(t.value);case`|=`:return n===t.value||n.startsWith(`${t.value}-`);default:return!1}},tu=(e,t)=>{if(t.opaque||t.tag!==void 0&&t.tag!==e.tag||t.id!==void 0&&$l(e,`id`)!==t.id)return!1;if(t.classes.length>0){let n=Ql(e);if(!t.classes.every(e=>n.includes(e)))return!1}return t.attributes.every(t=>eu(e,t))},nu=(e,t,n)=>{if(n===void 0)return!1;let r=e.parts[t];if(r===void 0||!tu(n.element,r.compound))return!1;let i=e.parts[t-1];if(i===void 0)return!0;switch(i.after??`descendant`){case`child`:return nu(e,t-1,n.parent);case`descendant`:for(let r=n.parent;r!==void 0;r=r.parent)if(nu(e,t-1,r))return!0;return!1;case`adjacent`:{let r=n.previous.at(-1);return r!==void 0&&nu(e,t-1,{element:r,parent:n.parent,previous:n.previous.slice(0,-1)})}case`sibling`:for(let r=n.previous.length-1;r>=0;r--)if(nu(e,t-1,{element:n.previous[r],parent:n.parent,previous:n.previous.slice(0,r)}))return!0;return!1}},ru=(e,t)=>e===void 0||e.parts.length===0?!1:nu(e,e.parts.length-1,t),iu=/var\(\s*--[\w-]+\s*(?:,[^()]*)?\)/g,au=(e,t)=>e.replace(iu,e=>{let n=Jl(e,t);return n===e?e:Qc(n)}),ou=(e,t,n,r,i,a)=>[+!!e,+!!t,e?-n:n,r[0],r[1],r[2],i,a],su=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=e[n]??0,i=t[n]??0;if(r!==i)return r-i}return 0},cu=(e,t)=>su(e,t)>=0,lu=e=>{if(!is(e)||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e)){if(r==null||typeof r!=`string`&&typeof r!=`number`)continue;let e=cl(n,r),i=/!important\s*$/i.test(e);t.push({property:ol(n),value:i?e.replace(/\s*!important\s*$/i,``):e,important:i})}return t},uu={direction:`ltr`,writingMode:`horizontal-tb`},du=e=>{let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?n++:a===`)`?n--:/\s/.test(a)&&n===0&&(i>r&&t.push(e.slice(r,i)),r=i+1)}return r<e.length&&t.push(e.slice(r)),t},fu=(e,t,n)=>{let r=[[e,t]],i=/^padding-(inline|block)(?:-(start|end))?$/.exec(e);if(i===null||n.writingMode!==`horizontal-tb`||![`ltr`,`rtl`].includes(n.direction)||/^(inherit|revert|revert-layer)$/.test(t)||t.includes(`var(`))return r;let a=du(t.trim());if(a.length<1||a.length>(i[2]===void 0?2:1))return r;let o=i[1]===`block`?[`top`,`bottom`]:n.direction===`rtl`?[`right`,`left`]:[`left`,`right`];return i[2]===void 0?[[`padding-${o[0]}`,a[0]],[`padding-${o[1]}`,a[1]??a[0]]]:[[`padding-${o[i[2]===`start`?0:1]}`,a[0]]]},pu=(e,t,n={})=>{let r=[...t.diagnostics],i=[],a=[],o=new Set;for(let e of t.rules){(e.inlinable?i:a).push(e);for(let t of e.classes)o.add(t)}let s=a.filter(e=>e.declarations.some(e=>e.property===`direction`||e.property===`writing-mode`||e.property===`all`)),c=new Map,l=new Set(t.fontFaces.map(e=>e.family.toLowerCase())),u=new Map,d=(e,t,n)=>{if(l.size===0)return;let r=e===`font-family`?t:e===`font`?Rl(t):void 0;r===void 0||u.has(r)||zl(r,l)&&u.set(r,n)},f=(e,t,n,r)=>{let i=[],a=e=>e.map(e=>{if(e.type===`Element`){let a=p(e,{element:e,parent:t,previous:[...i]},n,r);return i.push(e),a}return e.type===`Fragment`?cs.Fragment({children:a(e.children)}):e.type===`Raw`&&e.html.includes(`var(`)?cs.Raw({...e,html:au(e.html,n)}):e});return a(e)},p=(e,t,r,a)=>{let l=s.some(e=>{if(e.matcher===void 0||e.matcher.parts.length===0||e.matcher.parts.some(e=>e.compound.opaque))return!0;for(let n=t;n!==void 0;n=n.parent)if(ru(e.matcher,n))return!0;return!1}),u=new Map,p=(e,t)=>{let n=u.get(e.property);(n===void 0||cu(t,n.key))&&u.set(e.property,{value:e.value,key:t})};for(let e of i)if(ru(e.matcher,t))for(let[t,n]of e.declarations.entries())p(n,ou(n.important,!1,e.layer,e.specificity,e.order,t));for(let[t,n]of lu(e.props.style).entries())p(n,ou(n.important,!0,0,[0,0,0],0,t));for(let t of Ql(e))!o.has(t)&&n.knownClasses?.has(t)!==!0&&c.set(t,[...c.get(t)??[],...e.origins]);let m={};for(let[e,t]of u)e.startsWith(`--`)&&(m[e]=t.value);let h=Object.keys(m).length===0?r:{...r,...m},g=(e,t,n,r=t)=>{let i=u.get(e)?.value;if(i===void 0)return r;let a=Jl(i,h);return a===`inherit`||a===`unset`?t:a===`initial`?n:a},_={direction:g(`direction`,a.direction,`ltr`,typeof e.props.dir==`string`?e.props.dir:e.tag===`bdi`?`auto`:a.direction),writingMode:u.has(`all`)?`unknown`:g(`writing-mode`,a.writingMode,`horizontal-tb`)},v=[...u].filter(([e])=>!e.startsWith(`--`)).sort(([,e],[,t])=>su(e.key,t.key)).map(([e,t])=>[e,Jl(t.value,h)]);for(let[t,n]of v)d(t,n,e.origins.slice(0,1));let y=new Map;for(let[e,t]of v)for(let[n,r]of l?[[e,t]]:fu(e,t,_))y.delete(n),y.set(n,r);let b=e.props.bgcolor,x=typeof b==`string`&&b.includes(`var(`)?{...e.props,bgcolor:Jl(b,h)}:e.props;return cs.Element({...e,props:v.length===0?x:{...x,style:Object.fromEntries(y)},children:f(e.children,t,h,_)})},m=e.type===`Element`?p(e,{element:e,parent:void 0,previous:[]},t.variables,uu):e.type===`Fragment`?cs.Fragment({children:f(e.children,void 0,t.variables,uu)}):e;for(let e of a)for(let n of e.declarations)d(n.property,Jl(n.value,t.variables),[]);for(let[e,t]of u)r.push({...Bl(e),origins:t});for(let[e,t]of c)r.push({code:`unmatched-class`,severity:`warning`,message:`Class ${JSON.stringify(e)} produced no styles. If it is composed at run time, the compiler cannot discover it; list it in the template's declared classes or write the style inline.`,origins:t.slice(0,1)});return{tree:m,headCss:Zl(a,t.headAtRules,t.variables),fontFaceCss:t.fontFaces.map(e=>e.css).join(``),diagnostics:r}},mu={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".avif":`image/avif`,".svg":`image/svg+xml`,".ico":`image/x-icon`,".woff":`font/woff`,".woff2":`font/woff2`,".ttf":`font/ttf`,".otf":`font/otf`,".pdf":`application/pdf`,".txt":`text/plain`},hu=e=>{let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()},gu=e=>Object.hasOwn(mu,hu(e)),_u=e=>[e.street1,e.street2,[e.city,e.region,e.postalCode].filter(e=>e.trim()!==``).join(`, `),e.country].filter(e=>e!==void 0&&e.trim()!==``),vu=(...e)=>{let t=e.filter(e=>e!==void 0&&e!==``).join(` `);return t===``?void 0:t},yu=(e,t={})=>ys(`tr`,{...t,children:ys(`td`,{style:{padding:`0 0 8px 0`},children:e})}),bu=(e,t=jc)=>{let n=e.assets??{},r=e.footer??{};return{BrandLogo:({width:e=120,alt:t,align:i,className:a})=>{if(n.logoUrl===void 0)return null;let o=t??r.companyName??``,s=(t,n,r)=>ys(`img`,{src:t,alt:r,width:e,border:0,...i===void 0?{}:{align:i},className:vu(n,a),style:{display:`block`,outline:`none`,border:`none`,height:`auto`}});return n.logoDarkUrl===void 0?s(n.logoUrl,void 0,o):ys(ds,{children:[s(n.logoUrl,`dark:hidden!`,o),ys(`div`,{className:`hidden dark:block!`,style:{msoHide:`all`,maxHeight:0,overflow:`hidden`},children:s(n.logoDarkUrl,void 0,``)})]})},BrandFooter:({unsubscribeLabel:e=`Unsubscribe`,className:n})=>{let i=[];if(r.companyName!==void 0&&r.companyName.trim()!==``&&i.push(yu(ys(`span`,{className:`font-semibold`,children:r.companyName}))),r.address!==void 0){let e=_u(r.address);e.length>0&&i.push(yu(e.flatMap((e,t)=>t===0?[e]:[ys(`br`,{}),e])))}let a=r.socialLinks??[];return a.length>0&&i.push(yu(a.flatMap((e,t)=>[...t===0?[]:[` · `],ys(`a`,{href:e.url,className:`text-gray-500 underline`,children:e.label})]))),i.push(yu(xu(e,t),{[t.unsubscribeRowAttribute]:``,[Ac]:!0})),ys(`table`,{role:`presentation`,width:`100%`,border:0,cellpadding:0,cellspacing:0,[t.footerAttribute]:``,[Ac]:!0,children:ys(`tbody`,{children:ys(`tr`,{children:ys(`td`,{align:`center`,className:vu(`text-xs text-gray-500 text-center`,n),style:{padding:`32px 16px`},children:ys(`table`,{role:`presentation`,border:0,cellpadding:0,cellspacing:0,children:ys(`tbody`,{children:i})})})})})})}}},xu=(e,t)=>ys(`a`,{href:t.unsubscribeUrlPlaceholder,className:`text-gray-500 underline`,[kc]:!0,children:e}),Su=class{constructor(e,t,n){this.line=void 0,this.column=void 0,n!==void 0&&(this.index=void 0),this.line=e,this.column=t,n!==void 0&&(this.index=n)}},Cu=class{start;end;filename;identifierName;constructor(e,t){this.start=e,this.end=t}};function wu(e,t){let{line:n,column:r,index:i}=e;return new Su(n,r+t,i+t)}var Tu=`BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED`,Eu={ImportMetaOutsideModule:{message:`import.meta may appear only with 'sourceType: "module"'`,code:Tu},ImportOutsideModule:{message:`'import' and 'export' may appear only with 'sourceType: "module"'`,code:Tu}},Du={ArrayPattern:`array destructuring pattern`,AssignmentExpression:`assignment expression`,AssignmentPattern:`assignment expression`,ArrowFunctionExpression:`arrow function expression`,ConditionalExpression:`conditional expression`,CatchClause:`catch clause`,ForOfStatement:`for-of statement`,ForInStatement:`for-in statement`,ForStatement:`for-loop`,FormalParameters:`function parameter list`,Identifier:`identifier`,ImportSpecifier:`import specifier`,ImportDefaultSpecifier:`import default specifier`,ImportNamespaceSpecifier:`import namespace specifier`,ObjectPattern:`object destructuring pattern`,ParenthesizedExpression:`parenthesized expression`,RestElement:`rest element`,UpdateExpression:{true:`prefix operation`,false:`postfix operation`},VariableDeclarator:`variable declaration`,YieldExpression:`yield expression`},Ou=e=>e.type===`UpdateExpression`?Du.UpdateExpression[`${e.prefix}`]:Du[e.type],ku={AccessorIsGenerator:({kind:e})=>`A ${e}ter cannot be a generator.`,ArgumentsInClass:`'arguments' is only allowed in functions and class methods.`,AsyncFunctionInSingleStatementContext:`Async functions can only be declared at the top level or inside a block.`,AwaitBindingIdentifier:`Can not use 'await' as identifier inside an async function.`,AwaitBindingIdentifierInStaticBlock:`Can not use 'await' as identifier inside a static block.`,AwaitExpressionFormalParameter:`'await' is not allowed in async function parameters.`,AwaitUsingNotInAsyncContext:`'await using' is only allowed within async functions and at the top levels of modules.`,AwaitNotInAsyncContext:`'await' is only allowed within async functions and at the top levels of modules.`,BadGetterArity:`A 'get' accessor must not have any formal parameters.`,BadSetterArity:`A 'set' accessor must have exactly one formal parameter.`,BadSetterRestParameter:`A 'set' accessor function argument must not be a rest parameter.`,ConstructorClassField:`Classes may not have a field named 'constructor'.`,ConstructorClassPrivateField:`Classes may not have a private field named '#constructor'.`,ConstructorIsAccessor:`Class constructor may not be an accessor.`,ConstructorIsAsync:`Constructor can't be an async function.`,ConstructorIsGenerator:`Constructor can't be a generator.`,DeclarationMissingInitializer:({kind:e})=>`Missing initializer in ${e} declaration.`,DecoratorArgumentsOutsideParentheses:`Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.`,DecoratorsBeforeAfterExport:`Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.`,DecoratorConstructor:`Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?`,DecoratorSemicolon:`Decorators must not be followed by a semicolon.`,DecoratorStaticBlock:`Decorators can't be used with a static block.`,DeferImportRequiresNamespace:'Only `import defer * as x from "./module"` is valid.',DeletePrivateField:`Deleting a private field is not allowed.`,DestructureNamedImport:`ES2015 named imports do not destructure. Use another statement for destructuring after the import.`,DuplicateConstructor:`Duplicate constructor in the same class.`,DuplicateDefaultExport:`Only one default export allowed per module.`,DuplicateExport:({exportName:e})=>`\`${e}\` has already been exported. Exported identifiers must be unique.`,DuplicateProto:`Redefinition of __proto__ property.`,DuplicateRegExpFlags:`Duplicate regular expression flag.`,ElementAfterRest:`Rest element must be last element.`,EscapedCharNotAnIdentifier:`Invalid Unicode escape.`,ExportBindingIsString:({localName:e,exportName:t})=>`A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${e}' as '${t}' } from 'some-module'\`?`,ExportDefaultFromAsIdentifier:`'from' is not allowed as an identifier after 'export default'.`,ForInOfLoopInitializer:({type:e})=>`'${e===`ForInStatement`?`for-in`:`for-of`}' loop variable declaration may not have an initializer.`,ForInUsing:`For-in loop may not start with 'using' declaration.`,ForOfAsync:`The left-hand side of a for-of loop may not be 'async'.`,ForOfLet:`The left-hand side of a for-of loop may not start with 'let'.`,GeneratorInSingleStatementContext:`Generators can only be declared at the top level or inside a block.`,IllegalBreakContinue:({type:e})=>`Unsyntactic ${e===`BreakStatement`?`break`:`continue`}.`,IllegalLanguageModeDirective:`Illegal 'use strict' directive in function with non-simple parameter list.`,IllegalReturn:`'return' outside of function.`,ImportBindingIsString:({importName:e})=>`A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${e}" as foo }\`?`,ImportCallArity:({phase:e})=>`\`import${e?`.${e}`:``}()\` requires exactly one or two arguments.`,ImportCallNotNewExpression:({phase:e})=>`Cannot use new with import${e?`.${e}`:``}().`,ImportCallSpreadArgument:({phase:e})=>`\`...\` is not allowed in \`import${e?`.${e}`:``}()\`.`,IncompatibleRegExpUVFlags:`The 'u' and 'v' regular expression flags cannot be enabled at the same time.`,InvalidBigIntLiteral:`Invalid BigIntLiteral.`,InvalidCodePoint:`Code point out of bounds.`,InvalidCoverDiscardElement:`'void' must be followed by an expression when not used in a binding position.`,InvalidCoverInitializedName:`Invalid shorthand property initializer.`,InvalidDigit:({radix:e})=>`Expected number in radix ${e}.`,InvalidEscapeSequence:`Bad character escape sequence.`,InvalidEscapeSequenceTemplate:`Invalid escape sequence in template.`,InvalidEscapedReservedWord:({reservedWord:e})=>`Escape sequence in keyword ${e}.`,InvalidIdentifier:({identifierName:e})=>`Invalid identifier ${e}.`,InvalidLhs:({ancestor:e})=>`Invalid left-hand side in ${Ou(e)}.`,InvalidLhsBinding:({ancestor:e})=>`Binding invalid left-hand side in ${Ou(e)}.`,InvalidLhsOptionalChaining:({ancestor:e})=>`Invalid optional chaining in the left-hand side of ${Ou(e)}.`,InvalidNumber:`Invalid number.`,InvalidOrMissingExponent:`Floating-point numbers require a valid exponent after the 'e'.`,InvalidOrUnexpectedToken:({unexpected:e})=>`Unexpected character '${e}'.`,InvalidParenthesizedAssignment:`Invalid parenthesized assignment pattern.`,InvalidPrivateFieldResolution:({identifierName:e})=>`Private name #${e} is not defined.`,InvalidPropertyBindingPattern:`Binding member expression.`,InvalidRestAssignmentPattern:`Invalid rest operator's argument.`,LabelRedeclaration:({labelName:e})=>`Label '${e}' is already declared.`,LetInLexicalBinding:`'let' is disallowed as a lexically bound name.`,LineTerminatorBeforeArrow:`No line break is allowed before '=>'.`,MalformedRegExpFlags:`Invalid regular expression flag.`,MissingClassName:`A class name is required.`,MissingEqInAssignment:`Only '=' operator can be used for specifying default value.`,MissingSemicolon:`Missing semicolon.`,MissingPlugin:({missingPlugin:e})=>`This experimental syntax requires enabling the parser plugin: ${e.map(e=>JSON.stringify(e)).join(`, `)}.`,MissingOneOfPlugins:({missingPlugin:e})=>`This experimental syntax requires enabling one of the following parser plugin(s): ${e.map(e=>JSON.stringify(e)).join(`, `)}.`,MissingUnicodeEscape:`Expecting Unicode escape sequence \\uXXXX.`,MixingCoalesceWithLogical:`Nullish coalescing operator(??) requires parens when mixing with logical operators.`,ModuleAttributeInvalidValue:`Only string literals are allowed as module attribute values.`,ModuleAttributesWithDuplicateKeys:({key:e})=>`Duplicate key "${e}" is not allowed in module attributes.`,ModuleExportNameHasLoneSurrogate:({surrogateCharCode:e})=>`An export name cannot include a lone surrogate, found '\\u${e.toString(16)}'.`,ModuleExportUndefined:({localName:e})=>`Export '${e}' is not defined.`,MultipleDefaultsInSwitch:`Multiple default clauses.`,NewlineAfterThrow:`Illegal newline after throw.`,NoCatchOrFinally:`Missing catch or finally clause.`,NumberIdentifier:`Identifier directly after number.`,NumericSeparatorInEscapeSequence:`Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.`,ObsoleteAwaitStar:`'await*' has been removed from the async functions proposal. Use Promise.all() instead.`,OptionalChainingNoNew:`Constructors in/after an Optional Chain are not allowed.`,OptionalChainingNoTemplate:`Tagged Template Literals are not allowed in optionalChain.`,OverrideOnConstructor:`'override' modifier cannot appear on a constructor declaration.`,ParamDupe:`Argument name clash.`,PatternHasAccessor:`Object pattern can't contain getter or setter.`,PatternHasMethod:`Object pattern can't contain methods.`,PrivateInExpectedIn:({identifierName:e})=>`Private names are only allowed in property accesses (\`obj.#${e}\`) or in \`in\` expressions (\`#${e} in obj\`).`,PrivateNameRedeclaration:({identifierName:e})=>`Duplicate private name #${e}.`,RestTrailingComma:`Unexpected trailing comma after rest element.`,SloppyFunction:`In non-strict mode code, functions can only be declared at top level or inside a block.`,SloppyFunctionAnnexB:`In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.`,SourcePhaseImportRequiresDefault:'Only `import source x from "./module"` is valid.',StaticPrototype:`Classes may not have static property named prototype.`,SuperCallNotNewExpression:`Cannot use new with super(...).`,SuperNotAllowed:"`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",SuperPrivateField:`Private fields can't be accessed on super.`,TrailingDecorator:`Decorators must be attached to a class element.`,UnexpectedArgumentPlaceholder:`Unexpected argument placeholder.`,UnexpectedDigitAfterHash:`Unexpected digit after hash token.`,UnexpectedImportExport:`'import' and 'export' may only appear at the top level.`,UnexpectedKeyword:({keyword:e})=>`Unexpected keyword '${e}'.`,UnexpectedLeadingDecorator:`Leading decorators must be attached to a class declaration.`,UnexpectedLexicalDeclaration:`Lexical declaration cannot appear in a single-statement context.`,UnexpectedNewTarget:"`new.target` can only be used in functions or class properties.",UnexpectedNumericSeparator:`A numeric separator is only allowed between two digits.`,UnexpectedPrivateField:`Unexpected private name.`,UnexpectedReservedWord:({reservedWord:e})=>`Unexpected reserved word '${e}'.`,UnexpectedSuper:`'super' is only allowed in object methods and classes.`,UnexpectedToken:({expected:e,unexpected:t})=>`Unexpected token${t?` '${t}'.`:``}${e?`, expected "${e}"`:``}`,UnexpectedTokenUnaryExponentiation:`Illegal expression. Wrap left hand side or entire exponentiation in parentheses.`,UnexpectedUsingDeclaration:"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement.",UnexpectedVoidPattern:`Unexpected void binding.`,UnsupportedDecoratorExport:`A decorated export must export a class declaration.`,UnsupportedDefaultExport:"Only expressions, functions or classes are allowed as the `default` export.",UnsupportedImport:"`import` can only be used in `import()` or `import.meta`.",UnsupportedMetaProperty:({target:e,onlyValidPropertyName:t})=>`The only valid meta property for ${e} is ${e}.${t}.`,UnsupportedParameterDecorator:`Decorators cannot be used to decorate parameters.`,UnsupportedPropertyDecorator:`Decorators cannot be used to decorate object literal properties.`,UnsupportedSuper:`'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).`,UnterminatedComment:`Unterminated comment.`,UnterminatedRegExp:`Unterminated regular expression.`,UnterminatedString:`Unterminated string constant.`,UnterminatedTemplate:`Unterminated template.`,UsingDeclarationExport:`Using declaration cannot be exported.`,UsingDeclarationHasBindingPattern:`Using declaration cannot have destructuring patterns.`,VarRedeclaration:({identifierName:e})=>`Identifier '${e}' has already been declared.`,VoidPatternCatchClauseParam:"A void binding can not be the catch clause parameter. Use `try { ... } catch { ... }` if you want to discard the caught error.",VoidPatternInitializer:`A void binding may not have an initializer.`,YieldBindingIdentifier:`Can not use 'yield' as identifier inside a generator.`,YieldInParameter:`Yield expression is not allowed in formal parameters.`,YieldNotInGeneratorFunction:`'yield' is only allowed within generator functions.`,ZeroDigitNumericSeparator:`Numeric separator can not be used after leading 0.`},Au={StrictDelete:`Deleting local variable in strict mode.`,StrictEvalArguments:({referenceName:e})=>`Assigning to '${e}' in strict mode.`,StrictEvalArgumentsBinding:({bindingName:e})=>`Binding '${e}' in strict mode.`,StrictFunction:`In strict mode code, functions can only be declared at top level or inside a block.`,StrictNumericEscape:`The only valid numeric escape in strict mode is '\\0'.`,StrictOctalLiteral:`Legacy octal literals are not allowed in strict mode.`,StrictWith:`'with' in strict mode.`},ju={ParseExpressionEmptyInput:`Unexpected parseExpression() input: The input is empty or contains only comments.`,ParseExpressionExpectsEOF:({unexpected:e})=>`Unexpected parseExpression() input: The input should contain exactly one expression, but the first expression is followed by the unexpected character \`${String.fromCodePoint(e)}\`.`},Mu=new Set([`ArrowFunctionExpression`,`AssignmentExpression`,`ConditionalExpression`,`YieldExpression`]),Nu={PipeTopicRequiresHackPipes:'Topic references are only supported when using the `"proposal": "hack"` version of the pipeline proposal.',PipeTopicUnbound:`Topic reference is unbound; it must be inside a pipe body.`,PipeTopicUnconfiguredToken:({token:e})=>`Invalid topic token ${e}. In order to use ${e} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${e}" }.`,PipeTopicUnused:`Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.`,PipeUnparenthesizedBody:({type:e})=>`Hack-style pipe body cannot be an unparenthesized ${Ou({type:e})}; please wrap it in parentheses.`,PipelineUnparenthesized:`Cannot mix binary operator with solo-await F#-style pipeline. Please wrap the pipeline in parentheses.`},Pu={UnsupportedBind:`Binding should be performed on object property.`,UnsupportedBindRHS:`The right-hand side of binding can not be super or import.`};function Fu(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!0,value:n})}function Iu({toMessage:e,code:t,reasonCode:n,syntaxPlugin:r}){let i=n===`MissingPlugin`||n===`MissingOneOfPlugins`;return function a(o,s,c){let l=SyntaxError();return l.code=t,l.reasonCode=n,l.loc=o,l.pos=s,l.syntaxPlugin=r,i&&(l.missingPlugin=c.missingPlugin),Fu(l,`clone`,function(e={}){let{line:t,column:n,index:r=s}=e.loc??o;return a(new Su(t,n),r,{...c,...e.details})}),Fu(l,`details`,c),Object.defineProperty(l,"message",{configurable:!0,get(){let t=`${e(c)} (${o.line}:${o.column})`;return this.message=t,t},set(e){Object.defineProperty(this,"message",{value:e,writable:!0})}}),l}}function Lu(e,t){if(Array.isArray(e))return t=>Lu(t,e[0]);let n={};for(let r of Object.keys(e)){let i=e[r],{message:a,...o}=typeof i==`string`?{message:()=>i}:typeof i==`function`?{message:i}:i;n[r]=Iu({code:`BABEL_PARSER_SYNTAX_ERROR`,reasonCode:r,toMessage:typeof a==`string`?()=>a:a,...t?{syntaxPlugin:t}:{},...o})}return n}var G={...Lu(Eu),...Lu(ku),...Lu(Au),...Lu(ju),...Lu`pipelineOperator`(Nu),...Lu`functionBind`(Pu)};function Ru(){return{sourceType:`script`,sourceFilename:void 0,startIndex:0,startColumn:0,startLine:1,allowAwaitOutsideFunction:!1,allowReturnOutsideFunction:!1,allowNewTargetOutsideFunction:!1,allowImportExportEverywhere:!1,allowSuperOutsideMethod:!1,allowUndeclaredExports:!1,allowYieldOutsideFunction:!1,plugins:[],strictMode:void 0,ranges:!1,locations:!0,tokens:!1,createImportExpressions:!0,createParenthesizedExpressions:!1,errorRecovery:!1,attachComment:!0,annexB:!0}}function zu(e){let t=Ru();if(e==null)return t;if(e.annexB!=null&&e.annexB!==!1)throw Error("The `annexB` option can only be set to `false`.");for(let n of Object.keys(t))e[n]!=null&&(t[n]=e[n]);if(t.startLine===1)e.startIndex==null&&t.startColumn>0?t.startIndex=t.startColumn:e.startColumn==null&&t.startIndex>0&&(t.startColumn=t.startIndex);else if(e.startColumn==null||e.startIndex==null)throw Error("With a `startLine > 1` you must also specify `startIndex` and `startColumn`.");if(t.sourceType===`commonjs`){if(e.allowAwaitOutsideFunction!=null)throw Error("The `allowAwaitOutsideFunction` option cannot be used with `sourceType: 'commonjs'`.");if(e.allowReturnOutsideFunction!=null)throw Error("`sourceType: 'commonjs'` implies `allowReturnOutsideFunction: true`, please remove the `allowReturnOutsideFunction` option or use `sourceType: 'script'`.");if(e.allowNewTargetOutsideFunction!=null)throw Error("`sourceType: 'commonjs'` implies `allowNewTargetOutsideFunction: true`, please remove the `allowNewTargetOutsideFunction` option or use `sourceType: 'script'`.")}return t}function Bu(e){let{start:t,end:n}=e.loc;return e.loc.start=new Su(t.line,t.column),e.loc.end=new Su(n.line,n.column),e}var Vu=e=>class extends e{createPosition(e){return new Su(e.line,e.column)}parse(){let e=super.parse();return this.optionFlags&512&&(e.tokens=e.tokens.map(Bu)),Bu(e)}parseRegExpLiteral({pattern:e,flags:t}){let n=null;try{n=new RegExp(e,t)}catch{}let r=this.estreeParseLiteral(n);return r.regex={pattern:e,flags:t},r}parseBigIntLiteral(e){let t;try{t=BigInt(e)}catch{t=null}let n=this.estreeParseLiteral(t);return n.bigint=n.value===null?e:String(n.value),n}estreeParseLiteral(e){return this.parseLiteral(e,`Literal`)}parseStringLiteral(e){return this.estreeParseLiteral(e)}parseNumericLiteral(e){return this.estreeParseLiteral(e)}parseNullLiteral(){return this.estreeParseLiteral(null)}parseBooleanLiteral(e){return this.estreeParseLiteral(e)}estreeParseChainExpression(e,t){let n=this.startNodeAtNode(e);return n.expression=e,this.finishNodeAtNode(n,`ChainExpression`,t)}directiveToStmt(e){let t=e.value;delete e.value,this.castNodeTo(t,`Literal`),t.raw=t.extra.raw,t.value=t.extra.expressionValue;let n=this.castNodeTo(e,`ExpressionStatement`);return n.expression=t,n.directive=t.extra.rawValue,delete t.extra,n}fillOptionalPropertiesForTSESLint(e){}cloneEstreeStringLiteral(e){let{start:t,end:n,loc:r,range:i,raw:a,value:o}=e,s=Object.create(e.constructor.prototype);return s.type=`Literal`,s.start=t,s.end=n,s.loc=r,s.range=i,s.raw=a,s.value=o,s}initFunction(e,t){super.initFunction(e,t),e.expression=!1}checkDeclaration(e){e!=null&&this.isObjectProperty(e)?this.checkDeclaration(e.value):super.checkDeclaration(e)}getObjectOrClassMethodParams(e){return e.value.params}isValidDirective(e){return e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&!e.expression.extra?.parenthesized}parseBlockBody(e,t,n,r,i){super.parseBlockBody(e,t,n,r,i),e.body=e.directives.map(e=>this.directiveToStmt(e)).concat(e.body),delete e.directives}parsePrivateName(){let e=super.parsePrivateName();return this.convertPrivateNameToPrivateIdentifier(e)}convertPrivateNameToPrivateIdentifier(e){let t=super.getPrivateNameSV(e);return delete e.id,e.name=t,this.castNodeTo(e,`PrivateIdentifier`)}isPrivateName(e){return e.type===`PrivateIdentifier`}getPrivateNameSV(e){return e.name}parseLiteral(e,t){let n=super.parseLiteral(e,t);return n.raw=n.extra.raw,delete n.extra,n}parseFunctionBody(e,t,n=!1){super.parseFunctionBody(e,t,n),e.expression=e.body.type!==`BlockStatement`}parseMethod(e,t,n,r,i,a,o=!1){let s=this.startNode();s.kind=e.kind,s=super.parseMethod(s,t,n,r,i,a,o),delete s.kind;let{typeParameters:c}=e;return c&&(delete e.typeParameters,s.typeParameters=c,this.resetStartLocationFromNode(s,c)),e.value=this.castNodeTo(s,this.hasPlugin(`typescript`)&&!s.body?`TSEmptyBodyFunctionExpression`:`FunctionExpression`),a===`ClassPrivateMethod`&&(e.computed=!1),this.hasPlugin(`typescript`)&&e.abstract?(delete e.abstract,this.finishNode(e,`TSAbstractMethodDefinition`)):a===`ObjectMethod`?(e.kind===`method`&&(e.kind=`init`),e.shorthand=!1,this.finishNode(e,`Property`)):this.finishNode(e,`MethodDefinition`)}nameIsConstructor(e){return e.type===`Literal`?e.value===`constructor`:super.nameIsConstructor(e)}parseClassProperty(...e){let t=super.parseClassProperty(...e);return t.abstract&&this.hasPlugin(`typescript`)?(delete t.abstract,this.castNodeTo(t,`TSAbstractPropertyDefinition`)):this.castNodeTo(t,`PropertyDefinition`),t}parseClassPrivateProperty(...e){let t=super.parseClassPrivateProperty(...e);return t.abstract&&this.hasPlugin(`typescript`)?this.castNodeTo(t,`TSAbstractPropertyDefinition`):this.castNodeTo(t,`PropertyDefinition`),t.computed=!1,t}parseClassAccessorProperty(e){let t=super.parseClassAccessorProperty(e);return t.abstract&&this.hasPlugin(`typescript`)?(delete t.abstract,this.castNodeTo(t,`TSAbstractAccessorProperty`)):this.castNodeTo(t,`AccessorProperty`),t}parseObjectProperty(e,t,n,r){let i=super.parseObjectProperty(e,t,n,r);return i&&(i.kind=`init`,this.castNodeTo(i,`Property`)),i}finishObjectProperty(e){return e.kind=`init`,this.finishNode(e,`Property`)}isValidLVal(e,t,n,r){return e===`Property`?`value`:super.isValidLVal(e,t,n,r)}isAssignable(e,t){return e!=null&&this.isObjectProperty(e)?this.isAssignable(e.value,t):super.isAssignable(e,t)}toAssignable(e,t=!1){if(e!=null&&this.isObjectProperty(e)){let{key:n,value:r}=e;this.isPrivateName(n)&&this.classScope.usePrivateName(this.getPrivateNameSV(n),n.start),this.toAssignable(r,t)}else super.toAssignable(e,t)}toAssignableObjectExpressionProp(e,t,n){e.type===`Property`&&(e.kind===`get`||e.kind===`set`)?this.raise(G.PatternHasAccessor,e.key):e.type===`Property`&&e.method?this.raise(G.PatternHasMethod,e.key):super.toAssignableObjectExpressionProp(e,t,n)}finishCallExpression(e,t){let n=super.finishCallExpression(e,t);return n.callee.type===`Import`?(this.castNodeTo(n,`ImportExpression`),n.source=n.arguments[0],n.options=n.arguments[1]??null,delete n.arguments,delete n.callee):n.type===`OptionalCallExpression`?this.castNodeTo(n,`CallExpression`):n.optional=!1,n}parseExport(e,t){let n=this.state.lastTokStartLoc,r=super.parseExport(e,t);switch(r.type){case`ExportAllDeclaration`:r.exported=null;break;case`ExportNamedDeclaration`:r.specifiers.length===1&&r.specifiers[0].type===`ExportNamespaceSpecifier`&&(this.castNodeTo(r,`ExportAllDeclaration`),r.exported=r.specifiers[0].exported,delete r.specifiers);case`ExportDefaultDeclaration`:{let{declaration:e}=r;e?.type===`ClassDeclaration`&&e.decorators?.length>0&&e.start===r.start&&this.resetStartLocation(r,n)}}return r}stopParseSubscript(e,t){let n=super.stopParseSubscript(e,t);return t.optionalChainMember?this.estreeParseChainExpression(n,e):n}parseMember(e,t,n,r,i){let a=super.parseMember(e,t,n,r,i);return a.type===`OptionalMemberExpression`?this.castNodeTo(a,`MemberExpression`):a.optional=!1,a}isOptionalMemberExpression(e){return e.type===`ChainExpression`?e.expression.type===`MemberExpression`:super.isOptionalMemberExpression(e)}hasPropertyAsPrivateName(e){return e.type===`ChainExpression`&&(e=e.expression),super.hasPropertyAsPrivateName(e)}isObjectProperty(e){return e.type===`Property`&&e.kind===`init`&&!e.method}isObjectMethod(e){return e.type===`Property`&&(e.method||e.kind===`get`||e.kind===`set`)}castNodeTo(e,t){let n=super.castNodeTo(e,t);return this.fillOptionalPropertiesForTSESLint(n),n}cloneIdentifier(e){let t=super.cloneIdentifier(e);return this.fillOptionalPropertiesForTSESLint(t),t}cloneStringLiteral(e){return e.type===`Literal`?this.cloneEstreeStringLiteral(e):super.cloneStringLiteral(e)}finishNodeAt(e,t,n){return Bu(super.finishNodeAt(e,t,n))}finishNodeAtNode(e,t,n){return Bu(super.finishNodeAtNode(e,t,n))}finishNode(e,t){let n=super.finishNode(e,t);return this.fillOptionalPropertiesForTSESLint(n),n}resetStartLocation(e,t){super.resetStartLocation(e,t),Bu(e)}resetEndLocation(e,t=this.state.lastTokEndLoc){super.resetEndLocation(e,t),Bu(e)}},Hu=!0,K=!0,Uu=!0,Wu=!0,Gu=!0,Ku=!0,qu=class{label;keyword;beforeExpr;startsExpr;rightAssociative;isLoop;isAssign;prefix;postfix;binop;constructor(e,t={}){this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.rightAssociative=!!t.rightAssociative,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop==null?null:t.binop}},Ju=new Map;function Yu(e,t={}){t.keyword=e;let n=id(e,t);return Ju.set(e,n),n}function Xu(e,t){return id(e,{beforeExpr:Hu,binop:t})}var Zu=-1,Qu=[],$u=[],ed=[],td=[],nd=[],rd=[];function id(e,t={}){return++Zu,$u.push(e),ed.push(t.binop??-1),td.push(t.beforeExpr??!1),nd.push(t.startsExpr??!1),rd.push(t.prefix??!1),Qu.push(new qu(e,t)),Zu}function ad(e,t={}){return++Zu,Ju.set(e,Zu),$u.push(e),ed.push(t.binop??-1),td.push(t.beforeExpr??!1),nd.push(t.startsExpr??!1),rd.push(t.prefix??!1),Qu.push(new qu(`name`,t)),Zu}var od={bracketL:id(`[`,{beforeExpr:Hu,startsExpr:K}),bracketR:id(`]`),braceL:id(`{`,{beforeExpr:Hu,startsExpr:K}),braceBarL:id(`{|`,{beforeExpr:Hu,startsExpr:K}),braceR:id(`}`),braceBarR:id(`|}`),parenL:id(`(`,{beforeExpr:Hu,startsExpr:K}),parenR:id(`)`),comma:id(`,`,{beforeExpr:Hu}),semi:id(`;`,{beforeExpr:Hu}),colon:id(`:`,{beforeExpr:Hu}),doubleColon:id(`::`,{beforeExpr:Hu}),dot:id(`.`),question:id(`?`,{beforeExpr:Hu}),questionDot:id(`?.`),arrow:id(`=>`,{beforeExpr:Hu}),template:id(`template`),ellipsis:id(`...`,{beforeExpr:Hu}),backQuote:id("`",{startsExpr:K}),dollarBraceL:id("${",{beforeExpr:Hu,startsExpr:K}),templateTail:id("...`",{startsExpr:K}),templateNonTail:id("...${",{beforeExpr:Hu,startsExpr:K}),at:id(`@`),hash:id(`#`,{startsExpr:K}),interpreterDirective:id(`#!...`),eq:id(`=`,{beforeExpr:Hu,isAssign:Wu}),assign:id(`_=`,{beforeExpr:Hu,isAssign:Wu}),slashAssign:id(`_=`,{beforeExpr:Hu,isAssign:Wu}),xorAssign:id(`_=`,{beforeExpr:Hu,isAssign:Wu}),moduloAssign:id(`_=`,{beforeExpr:Hu,isAssign:Wu}),incDec:id(`++/--`,{prefix:Gu,postfix:Ku,startsExpr:K}),bang:id(`!`,{beforeExpr:Hu,prefix:Gu,startsExpr:K}),tilde:id(`~`,{beforeExpr:Hu,prefix:Gu,startsExpr:K}),doubleCaret:id(`^^`,{startsExpr:K}),doubleAt:id(`@@`,{startsExpr:K}),pipeline:Xu(`|>`,0),nullishCoalescing:Xu(`??`,1),logicalOR:Xu(`||`,1),logicalAND:Xu(`&&`,2),bitwiseOR:Xu(`|`,3),bitwiseXOR:Xu(`^`,4),bitwiseAND:Xu(`&`,5),equality:Xu(`==/!=/===/!==`,6),lt:Xu(`</>/<=/>=`,7),gt:Xu(`</>/<=/>=`,7),relational:Xu(`</>/<=/>=`,7),bitShift:Xu(`<</>>/>>>`,8),bitShiftL:Xu(`<</>>/>>>`,8),bitShiftR:Xu(`<</>>/>>>`,8),plusMin:id(`+/-`,{beforeExpr:Hu,binop:9,prefix:Gu,startsExpr:K}),modulo:id(`%`,{binop:10,startsExpr:K}),star:id(`*`,{binop:10}),slash:Xu(`/`,10),exponent:id(`**`,{beforeExpr:Hu,binop:11,rightAssociative:!0}),_in:Yu(`in`,{beforeExpr:Hu,binop:7}),_instanceof:Yu(`instanceof`,{beforeExpr:Hu,binop:7}),_break:Yu(`break`),_case:Yu(`case`,{beforeExpr:Hu}),_catch:Yu(`catch`),_continue:Yu(`continue`),_debugger:Yu(`debugger`),_default:Yu(`default`,{beforeExpr:Hu}),_else:Yu(`else`,{beforeExpr:Hu}),_finally:Yu(`finally`),_function:Yu(`function`,{startsExpr:K}),_if:Yu(`if`),_return:Yu(`return`,{beforeExpr:Hu}),_switch:Yu(`switch`),_throw:Yu(`throw`,{beforeExpr:Hu,prefix:Gu,startsExpr:K}),_try:Yu(`try`),_var:Yu(`var`),_const:Yu(`const`),_with:Yu(`with`),_new:Yu(`new`,{beforeExpr:Hu,startsExpr:K}),_this:Yu(`this`,{startsExpr:K}),_super:Yu(`super`,{startsExpr:K}),_class:Yu(`class`,{startsExpr:K}),_extends:Yu(`extends`,{beforeExpr:Hu}),_export:Yu(`export`),_import:Yu(`import`,{startsExpr:K}),_null:Yu(`null`,{startsExpr:K}),_true:Yu(`true`,{startsExpr:K}),_false:Yu(`false`,{startsExpr:K}),_typeof:Yu(`typeof`,{beforeExpr:Hu,prefix:Gu,startsExpr:K}),_void:Yu(`void`,{beforeExpr:Hu,prefix:Gu,startsExpr:K}),_delete:Yu(`delete`,{beforeExpr:Hu,prefix:Gu,startsExpr:K}),_do:Yu(`do`,{isLoop:Uu,beforeExpr:Hu}),_for:Yu(`for`,{isLoop:Uu}),_while:Yu(`while`,{isLoop:Uu}),_as:ad(`as`,{startsExpr:K}),_assert:ad(`assert`,{startsExpr:K}),_async:ad(`async`,{startsExpr:K}),_await:ad(`await`,{startsExpr:K}),_defer:ad(`defer`,{startsExpr:K}),_from:ad(`from`,{startsExpr:K}),_get:ad(`get`,{startsExpr:K}),_let:ad(`let`,{startsExpr:K}),_meta:ad(`meta`,{startsExpr:K}),_of:ad(`of`,{startsExpr:K}),_sent:ad(`sent`,{startsExpr:K}),_set:ad(`set`,{startsExpr:K}),_source:ad(`source`,{startsExpr:K}),_static:ad(`static`,{startsExpr:K}),_using:ad(`using`,{startsExpr:K}),_yield:ad(`yield`,{startsExpr:K}),_asserts:ad(`asserts`,{startsExpr:K}),_checks:ad(`checks`,{startsExpr:K}),_exports:ad(`exports`,{startsExpr:K}),_global:ad(`global`,{startsExpr:K}),_implements:ad(`implements`,{startsExpr:K}),_intrinsic:ad(`intrinsic`,{startsExpr:K}),_infer:ad(`infer`,{startsExpr:K}),_is:ad(`is`,{startsExpr:K}),_mixins:ad(`mixins`,{startsExpr:K}),_proto:ad(`proto`,{startsExpr:K}),_require:ad(`require`,{startsExpr:K}),_satisfies:ad(`satisfies`,{startsExpr:K}),_keyof:ad(`keyof`,{startsExpr:K}),_readonly:ad(`readonly`,{startsExpr:K}),_unique:ad(`unique`,{startsExpr:K}),_abstract:ad(`abstract`,{startsExpr:K}),_declare:ad(`declare`,{startsExpr:K}),_enum:ad(`enum`,{startsExpr:K}),_module:ad(`module`,{startsExpr:K}),_namespace:ad(`namespace`,{startsExpr:K}),_interface:ad(`interface`,{startsExpr:K}),_type:ad(`type`,{startsExpr:K}),_opaque:ad(`opaque`,{startsExpr:K}),name:id(`name`,{startsExpr:K}),placeholder:id(`%%`,{startsExpr:K}),string:id(`string`,{startsExpr:K}),num:id(`num`,{startsExpr:K}),bigint:id(`bigint`,{startsExpr:K}),regexp:id(`regexp`,{startsExpr:K}),privateName:id(`#name`,{startsExpr:K}),eof:id(`eof`),jsxName:id(`jsxName`),jsxText:id(`jsxText`,{beforeExpr:Hu}),jsxTagStart:id(`jsxTagStart`,{startsExpr:K}),jsxTagEnd:id(`jsxTagEnd`)};function sd(e){return e>=89&&e<=129}function cd(e){return e<=88}function ld(e){return e>=54&&e<=129}function ud(e){return e>=54&&e<=132}function dd(e){return td[e]}function fd(e){return nd[e]}function pd(e){return e>=25&&e<=29}function md(e){return e>=125&&e<=127}function hd(e){return e>=86&&e<=88}function gd(e){return e>=54&&e<=88}function _d(e){return e>=35&&e<=55}function vd(e){return e===30}function yd(e){return rd[e]}function bd(e){return e>=117&&e<=119}function xd(e){return e>=120&&e<=126}function Sd(e){return $u[e]}function Cd(e){return ed[e]}function wd(e){return e===53}function Td(e){return e>=20&&e<=21}function Ed(e){return Qu[e]}var Dd=class{constructor(e,t){this.token=e,this.preserveSpace=!!t}token;preserveSpace},Od={brace:new Dd(`{`),j_oTag:new Dd(`<tag`),j_cTag:new Dd(`</tag`),j_expr:new Dd(`<tag>...</tag>`,!0)},kd=/[\p{ID_Start}\u0558\u058b\u058c\u088f\u0c5c\u0cdc\u208f\u209d-\u209f\ua7ce\ua7cf\ua7d2\ua7d4\ua7dd\ua7e2\ua7f1\uab6c\uab6d]/u,Ad=/[\p{ID_Continue}\u0558\u058b\u058c\u088f\u0c5c\u0cdc\u208f\u209d-\u209f\ua7ce\ua7cf\ua7d2\ua7d4\ua7dd\ua7e2\ua7f1\uab6c\uab6d\u05c8\u05c9\u0b53\u0b54\u1acf-\u1af0]/u,jd=[1979,4,385,25,1388,2,18,21,3100,0,678,43,22,0,1662,0,6,10,209,310,18458,24,3,24,287,4,6146,7,1239,4,47,23,96,114,14,913,15,50,8017,5,64,0,9534,0,2169,5,7,86,15,6,55,50,1729,30,2,2,2,1,2,6,3,4,10,1,53307,5,223,0,5764,11,21763,4297,39815,11327],Md=[3787,4,33,11,3173,7,633,9,7,0,45879,1,296,2,9,1,3,0,33,1,5218,0,3,0,8,1,6,0];function Nd(e,t){let n=65536;for(let r=0,i=t.length;r<i;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Pd(e){return e<65?e===36:e<=90?!0:e<97?e===95:e<=122?!0:e<=65535?e>=170&&kd.test(String.fromCharCode(e)):!isNaN(e)&&e<=1114111&&(kd.test(String.fromCodePoint(e))||Nd(e,jd))}function Fd(e){return e<48?e===36:e<58?!0:e<65?!1:e<=90?!0:e<97?e===95:e<=122?!0:e<=65535?e>=170&&Ad.test(String.fromCharCode(e)):!isNaN(e)&&e<=1114111&&(Ad.test(String.fromCodePoint(e))||Nd(e,jd)||Nd(e,Md))}var Id={keyword:`break.case.catch.continue.debugger.default.do.else.finally.for.function.if.return.switch.throw.try.var.const.while.with.new.this.super.class.extends.export.import.null.true.false.in.instanceof.typeof.void.delete`.split(`.`),strict:[`implements`,`interface`,`let`,`package`,`private`,`protected`,`public`,`static`,`yield`],strictBind:[`eval`,`arguments`]},Ld=new Set(Id.keyword),Rd=new Set(Id.strict),zd=new Set(Id.strictBind);function Bd(e,t){return t&&e===`await`||e===`enum`}function Vd(e,t){return Bd(e,t)||Rd.has(e)}function Hd(e){return zd.has(e)}function Ud(e,t){return Vd(e,t)||Hd(e)}function Wd(e){return Ld.has(e)}function Gd(e,t,n){return e===64&&t===64&&Pd(n)}var Kd=new Set(`break.case.catch.continue.debugger.default.do.else.finally.for.function.if.return.switch.throw.try.var.const.while.with.new.this.super.class.extends.export.import.null.true.false.in.instanceof.typeof.void.delete.implements.interface.let.package.private.protected.public.static.yield.eval.arguments.enum.await`.split(`.`));function qd(e){return Kd.has(e)}var Jd=class{flags=0;names=new Map;firstLexicalName=``;constructor(e){this.flags=e}},Yd=class{parser;scopeStack=[];inModule;undefinedExports=new Map;constructor(e,t){this.parser=e,this.inModule=t}get inTopLevel(){return(this.currentScope().flags&1)>0}get inFunction(){return(this.currentVarScopeFlags()&2)>0}get allowSuper(){return(this.currentThisScopeFlags()&16)>0}get allowDirectSuper(){return(this.currentThisScopeFlags()&32)>0}get allowNewTarget(){return(this.currentThisScopeFlags()&512)>0}get inClass(){return(this.currentThisScopeFlags()&64)>0}get inClassAndNotInNonArrowFunction(){let e=this.currentThisScopeFlags();return(e&64)>0&&!(e&2)}get inStaticBlock(){for(let e=this.scopeStack.length-1;;e--){let{flags:t}=this.scopeStack[e];if(t&128)return!0;if(t&3779)return!1}}get inNonArrowFunction(){return(this.currentThisScopeFlags()&2)>0}get inBareCaseStatement(){return(this.currentScope().flags&256)>0}get treatFunctionsAsVar(){return this.treatFunctionsAsVarInScope(this.currentScope())}createScope(e){return new Jd(e)}enter(e){this.scopeStack.push(this.createScope(e))}exit(){return this.scopeStack.pop().flags}treatFunctionsAsVarInScope(e){return!!(e.flags&130||!this.parser.inModule&&e.flags&1)}declareName(e,t,n){let r=this.currentScope();if(t&8||t&16){this.checkRedeclarationInScope(r,e,t,n);let i=r.names.get(e)||0;t&16?i|=4:(r.firstLexicalName||(r.firstLexicalName=e),i|=2),r.names.set(e,i),t&8&&this.maybeExportDefined(r,e)}else if(t&4)for(let i=this.scopeStack.length-1;i>=0&&(r=this.scopeStack[i],this.checkRedeclarationInScope(r,e,t,n),r.names.set(e,(r.names.get(e)||0)|1),this.maybeExportDefined(r,e),!(r.flags&3715));--i);this.parser.inModule&&r.flags&1&&this.undefinedExports.delete(e)}maybeExportDefined(e,t){this.parser.inModule&&e.flags&1&&this.undefinedExports.delete(t)}checkRedeclarationInScope(e,t,n,r){this.isRedeclaredInScope(e,t,n)&&this.parser.raise(G.VarRedeclaration,r,{identifierName:t})}isRedeclaredInScope(e,t,n){if(!(n&1))return!1;if(n&8)return e.names.has(t);let r=e.names.get(t)||0;return n&16?(r&2)>0||!this.treatFunctionsAsVarInScope(e)&&(r&1)>0:(r&2)>0&&!(e.flags&8&&e.firstLexicalName===t)||!this.treatFunctionsAsVarInScope(e)&&(r&4)>0}checkLocalExport(e){let{name:t}=e;this.scopeStack[0].names.has(t)||this.undefinedExports.set(t,e.start)}currentScope(){return this.scopeStack[this.scopeStack.length-1]}currentVarScopeFlags(){for(let e=this.scopeStack.length-1;;e--){let{flags:t}=this.scopeStack[e];if(t&3715)return t}}currentThisScopeFlags(){for(let e=this.scopeStack.length-1;;e--){let{flags:t}=this.scopeStack[e];if(t&3779&&!(t&4))return t}}},Xd=class extends Jd{declareFunctions=new Set},Zd=class extends Yd{createScope(e){return new Xd(e)}declareName(e,t,n){let r=this.currentScope();if(t&2048){this.checkRedeclarationInScope(r,e,t,n),this.maybeExportDefined(r,e),r.declareFunctions.add(e);return}super.declareName(e,t,n)}isRedeclaredInScope(e,t,n){if(super.isRedeclaredInScope(e,t,n))return!0;if(n&2048&&!e.declareFunctions.has(t)){let n=e.names.get(t);return(n&4)>0||(n&2)>0}return!1}checkLocalExport(e){this.scopeStack[0].declareFunctions.has(e.name)||super.checkLocalExport(e)}},Qd=new Set([`_`,`any`,`bool`,`boolean`,`empty`,`extends`,`false`,`interface`,`mixed`,`null`,`number`,`static`,`string`,`true`,`typeof`,`void`]),$d=Lu`flow`({AmbiguousConditionalArrow:`Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.`,AmbiguousDeclareModuleKind:"Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module.",AssignReservedType:({reservedType:e})=>`Cannot overwrite reserved type ${e}.`,DeclareClassElement:"The `declare` modifier can only appear on class fields.",DeclareClassFieldInitializer:"Initializers are not allowed in fields with the `declare` modifier.",DuplicateDeclareModuleExports:"Duplicate `declare module.exports` statement.",EnumBooleanMemberNotInitialized:({memberName:e,enumName:t})=>`Boolean enum members need to be initialized. Use either \`${e} = true,\` or \`${e} = false,\` in enum \`${t}\`.`,EnumDuplicateMemberName:({memberName:e,enumName:t})=>`Enum member names need to be unique, but the name \`${e}\` has already been used before in enum \`${t}\`.`,EnumInconsistentMemberValues:({enumName:e})=>`Enum \`${e}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,EnumInvalidExplicitType:({invalidEnumType:e,enumName:t})=>`Enum type \`${e}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${t}\`.`,EnumInvalidExplicitTypeUnknownSupplied:({enumName:e})=>`Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${e}\`.`,EnumInvalidMemberInitializerPrimaryType:({enumName:e,memberName:t,explicitType:n})=>`Enum \`${e}\` has type \`${n}\`, so the initializer of \`${t}\` needs to be a ${n} literal.`,EnumInvalidMemberInitializerSymbolType:({enumName:e,memberName:t})=>`Symbol enum members cannot be initialized. Use \`${t},\` in enum \`${e}\`.`,EnumInvalidMemberInitializerUnknownType:({enumName:e,memberName:t})=>`The enum member initializer for \`${t}\` needs to be a literal (either a boolean, number, or string) in enum \`${e}\`.`,EnumInvalidMemberName:({enumName:e,memberName:t,suggestion:n})=>`Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${t}\`, consider using \`${n}\`, in enum \`${e}\`.`,EnumNumberMemberNotInitialized:({enumName:e,memberName:t})=>`Number enum members need to be initialized, e.g. \`${t} = 1\` in enum \`${e}\`.`,EnumStringMemberInconsistentlyInitialized:({enumName:e})=>`String enum members need to consistently either all use initializers, or use no initializers, in enum \`${e}\`.`,GetterMayNotHaveThisParam:"A getter cannot have a `this` parameter.",ImportTypeShorthandOnlyInPureImport:"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.",InexactInsideExact:`Explicit inexact syntax cannot appear inside an explicit exact object type.`,InexactInsideNonObject:`Explicit inexact syntax cannot appear in class or interface definitions.`,InexactVariance:`Explicit inexact syntax cannot have variance.`,InvalidNonTypeImportInDeclareModule:"Imports within a `declare module` body must always be `import type` or `import typeof`.",MissingTypeParamDefault:`Type parameter declaration needs a default, since a preceding type parameter declaration has a default.`,NestedDeclareModule:"`declare module` cannot be used inside another `declare module`.",NestedFlowComment:`Cannot have a flow comment inside another flow comment.`,PatternIsOptional:{message:`A binding pattern parameter cannot be optional in an implementation signature.`},SetterMayNotHaveThisParam:"A setter cannot have a `this` parameter.",SpreadVariance:`Spread properties cannot have variance.`,ThisParamAnnotationRequired:"A type annotation is required for the `this` parameter.",ThisParamBannedInConstructor:"Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",ThisParamMayNotBeOptional:"The `this` parameter cannot be optional.",ThisParamMustBeFirst:"The `this` parameter must be the first function parameter.",ThisParamNoDefault:"The `this` parameter may not have a default value.",TypeBeforeInitializer:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeCastInPattern:`The type cast expression is expected to be wrapped with parenthesis.`,UnexpectedExplicitInexactInObject:`Explicit inexact syntax must appear at the end of an inexact object.`,UnexpectedReservedType:({reservedType:e})=>`Unexpected reserved type ${e}.`,UnexpectedReservedUnderscore:"`_` is only allowed as a type argument to call or new.",UnexpectedSpaceBetweenModuloChecks:"Spaces between `%` and `checks` are not allowed here.",UnexpectedSpreadType:`Spread operator cannot appear in class or interface definitions.`,UnexpectedSubtractionOperand:`Unexpected token, expected "number" or "bigint".`,UnexpectedTokenAfterTypeParameter:`Expected an arrow function after this type parameter declaration.`,UnexpectedTypeParameterBeforeAsyncArrowFunction:"Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",UnsupportedDeclareExportKind:({unsupportedExportKind:e,suggestion:t})=>`\`declare export ${e}\` is not supported. Use \`${t}\` instead.`,UnsupportedStatementInDeclareModule:`Only declares and type imports are allowed inside declare module.`,UnterminatedFlowComment:`Unterminated flow-comment.`});function ef(e){return e.type===`DeclareExportAllDeclaration`||e.type===`DeclareExportDeclaration`&&(!e.declaration||e.declaration.type!==`TypeAlias`&&e.declaration.type!==`InterfaceDeclaration`)}function tf(e){return e.importKind===`type`||e.importKind===`typeof`}var nf={const:`declare export var`,let:`declare export var`,type:`export type`,interface:`export interface`};function rf(e,t){let n=[],r=[];for(let i=0;i<e.length;i++)(t(e[i],i,e)?n:r).push(e[i]);return[n,r]}var af=/\*?\s*@((?:no)?flow)\b/,of=e=>class extends e{flowPragma=void 0;getScopeHandler(){return Zd}shouldParseTypes(){return this.getPluginOption(`flow`,`all`)||this.flowPragma===`flow`}finishToken(e,t){e!==130&&e!==9&&e!==24&&this.flowPragma===void 0&&(this.flowPragma=null),super.finishToken(e,t)}addComment(e){if(this.flowPragma===void 0){let t=af.exec(e.value);if(t){if(t[1]===`flow`)this.flowPragma=`flow`;else if(t[1]===`noflow`)this.flowPragma=`noflow`;else throw Error(`Unexpected flow pragma`)}}super.addComment(e)}flowParseTypeInitialiser(e){let t=this.state.inType;this.state.inType=!0,this.expect(e||10);let n=this.flowParseType();return this.state.inType=t,n}flowParsePredicate(){let e=this.startNode(),t=this.state.startLoc;return this.next(),this.expectContextual(106),this.state.lastTokStartLoc.index>t.index+1&&this.raise($d.UnexpectedSpaceBetweenModuloChecks,t),this.eat(6)?(e.value=super.parseExpression(),this.expect(7),this.finishNode(e,`DeclaredPredicate`)):this.finishNode(e,`InferredPredicate`)}flowParseTypeAndPredicateInitialiser(e){let t=this.state.inType;this.state.inType=!0,this.expect(10);let n=null,r=null;return e&&this.match(50)?(this.state.inType=t,r=this.flowParsePredicate()):(n=this.flowParseType(),this.state.inType=t,this.match(50)&&(r=this.flowParsePredicate())),[n,r]}flowParseDeclareClass(e){return this.next(),this.flowParseInterfaceish(e,!0),this.finishNode(e,`DeclareClass`)}flowParseDeclareFunction(e){this.next();let t=e.id=this.parseIdentifier(),n=this.startNode(),r=this.startNode();n.typeParameters=this.match(43)?this.flowParseTypeParameterDeclaration():null,this.expect(6);let i=this.flowParseFunctionTypeParams();return n.params=i.params,n.rest=i.rest,n.this=i._this,this.expect(7),[n.returnType,e.predicate]=this.flowParseTypeAndPredicateInitialiser(!1),r.typeAnnotation=this.finishNode(n,`FunctionTypeAnnotation`),t.typeAnnotation=this.finishNode(r,`TypeAnnotation`),this.resetEndLocation(t),this.semicolon(),this.scope.declareName(e.id.name,2048,e.id.start),this.finishNode(e,`DeclareFunction`)}flowParseDeclare(e,t){if(this.match(76))return this.flowParseDeclareClass(e);if(this.match(64))return this.flowParseDeclareFunction(e);if(this.match(70))return this.flowParseDeclareVariable(e);if(this.eatContextual(123))return this.match(12)?this.flowParseDeclareModuleExports(e):(t&&this.raise($d.NestedDeclareModule,this.state.lastTokStartLoc),this.flowParseDeclareModule(e));if(this.isContextual(126))return this.flowParseDeclareTypeAlias(e);if(this.isContextual(127))return this.flowParseDeclareOpaqueType(e);if(this.isContextual(125))return this.flowParseDeclareInterface(e);if(this.match(78))return this.flowParseDeclareExportDeclaration(e,t);throw this.unexpected()}flowParseDeclareVariable(e){return this.next(),e.id=this.flowParseTypeAnnotatableIdentifier(),this.scope.declareName(e.id.name,5,e.id.start),this.semicolon(),this.finishNode(e,`DeclareVariable`)}flowParseDeclareModule(e){this.scope.enter(0),e.id=this.match(130)?super.parseExprAtom():this.parseIdentifier();let t=this.startNode(),n=t.body=[];for(this.expect(2);!this.match(4);){let e=this.startNode();this.match(79)?(this.next(),!this.isContextual(126)&&!this.match(83)&&this.raise($d.InvalidNonTypeImportInDeclareModule,this.state.lastTokStartLoc),n.push(super.parseImport(e))):(this.expectContextual(121,$d.UnsupportedStatementInDeclareModule),n.push(this.flowParseDeclare(e,!0)))}this.scope.exit(),this.expect(4),e.body=this.finishNode(t,`BlockStatement`);let r=null,i=!1;return n.forEach(e=>{ef(e)?(r===`CommonJS`&&this.raise($d.AmbiguousDeclareModuleKind,e),r=`ES`):e.type===`DeclareModuleExports`&&(i&&this.raise($d.DuplicateDeclareModuleExports,e),r===`ES`&&this.raise($d.AmbiguousDeclareModuleKind,e),r=`CommonJS`,i=!0)}),e.kind=r||`CommonJS`,this.finishNode(e,`DeclareModule`)}flowParseDeclareExportDeclaration(e,t){if(this.expect(78),this.eat(61))return this.match(64)||this.match(76)?e.declaration=this.flowParseDeclare(this.startNode()):(e.declaration=this.flowParseType(),this.semicolon()),e.default=!0,this.finishNode(e,`DeclareExportDeclaration`);if(this.match(71)||this.isLet()||(this.isContextual(126)||this.isContextual(125))&&!t){let e=this.state.value;throw this.raise($d.UnsupportedDeclareExportKind,this.state.startLoc,{unsupportedExportKind:e,suggestion:nf[e]})}if(this.match(70)||this.match(64)||this.match(76)||this.isContextual(127))return e.declaration=this.flowParseDeclare(this.startNode()),e.default=!1,this.finishNode(e,`DeclareExportDeclaration`);if(this.match(51)||this.match(2)||this.isContextual(125)||this.isContextual(126)||this.isContextual(127)){let t=this.parseExport(e,null);return t.type===`ExportNamedDeclaration`?(t.default=!1,delete t.exportKind,this.castNodeTo(t,`DeclareExportDeclaration`)):this.castNodeTo(t,`DeclareExportAllDeclaration`)}throw this.unexpected()}flowParseDeclareModuleExports(e){return this.next(),this.expectContextual(107),e.typeAnnotation=this.flowParseTypeAnnotation(),this.semicolon(),this.finishNode(e,`DeclareModuleExports`)}flowParseDeclareTypeAlias(e){this.next();let t=this.flowParseTypeAlias(e);return this.castNodeTo(t,`DeclareTypeAlias`),t}flowParseDeclareOpaqueType(e){return this.next(),this.flowParseOpaqueType(e,!0)}flowParseDeclareInterface(e){return this.next(),this.flowParseInterfaceish(e,!1),this.finishNode(e,`DeclareInterface`)}flowParseInterfaceish(e,t){if(e.id=this.flowParseRestrictedIdentifier(!t,!0),this.scope.declareName(e.id.name,t?17:8201,e.id.start),e.typeParameters=this.match(43)?this.flowParseTypeParameterDeclaration():null,e.extends=[],this.eat(77))do e.extends.push(this.flowParseInterfaceExtends());while(!t&&this.eat(8));if(t){let t=[],n=[];if(this.eatContextual(113))do n.push(this.flowParseInterfaceExtends());while(this.eat(8));if(this.eatContextual(109))do t.push(this.flowParseClassImplements());while(this.eat(8));e.implements=t,e.mixins=n}e.body=this.flowParseObjectType({allowStatic:t,allowExact:!1,allowSpread:!1,allowProto:t,allowInexact:!1})}flowParseInterfaceExtends(){let e=this.startNode();return e.id=this.flowParseQualifiedTypeIdentifier(),e.typeParameters=this.match(43)?this.flowParseTypeParameterInstantiation():null,this.finishNode(e,`InterfaceExtends`)}flowParseInterface(e){return this.flowParseInterfaceish(e,!1),this.finishNode(e,`InterfaceDeclaration`)}checkNotUnderscore(e){e===`_`&&this.raise($d.UnexpectedReservedUnderscore,this.state.startLoc)}checkReservedType(e,t,n){Qd.has(e)&&this.raise(n?$d.AssignReservedType:$d.UnexpectedReservedType,t,{reservedType:e})}flowParseRestrictedIdentifierName(e,t){return this.checkReservedType(this.state.value,this.state.startLoc,t),this.parseIdentifierName(e)}flowParseRestrictedIdentifier(e,t){let n=this.startNode(),r=this.flowParseRestrictedIdentifierName(e,t);return this.createIdentifier(n,r)}flowParseTypeAlias(e){return e.id=this.flowParseRestrictedIdentifier(!1,!0),this.scope.declareName(e.id.name,8201,e.id.start),e.typeParameters=this.match(43)?this.flowParseTypeParameterDeclaration():null,e.right=this.flowParseTypeInitialiser(25),this.semicolon(),this.finishNode(e,`TypeAlias`)}flowParseOpaqueType(e,t){return this.expectContextual(126),e.id=this.flowParseRestrictedIdentifier(!0,!0),this.scope.declareName(e.id.name,8201,e.id.start),e.typeParameters=this.match(43)?this.flowParseTypeParameterDeclaration():null,e.supertype=null,this.match(10)&&(e.supertype=this.flowParseTypeInitialiser(10)),e.impltype=null,t||(e.impltype=this.flowParseTypeInitialiser(25)),this.semicolon(),this.finishNode(e,t?`DeclareOpaqueType`:`OpaqueType`)}flowParseTypeParameterBound(){if(this.match(10)||this.isContextual(77)){let e=this.startNode();return this.next(),e.typeAnnotation=this.flowParseType(),this.finishNode(e,`TypeAnnotation`)}}flowParseTypeParameter(e=!1){let t=this.state.startLoc,n=this.startNode(),r=this.flowParseVariance();return n.name=this.flowParseRestrictedIdentifierName(),n.variance=r,n.bound=this.flowParseTypeParameterBound(),this.match(25)?(this.eat(25),n.default=this.flowParseType()):e&&this.raise($d.MissingTypeParamDefault,t),this.finishNode(n,`TypeParameter`)}flowParseTypeParameterDeclaration(){let e=this.state.inType,t=this.startNode();t.params=[],this.state.inType=!0,this.match(43)||this.match(138)?this.next():this.unexpected();let n=!1;do{let e=this.flowParseTypeParameter(n);t.params.push(e),e.default&&(n=!0),this.match(44)||this.expect(8)}while(!this.match(44));return this.expect(44),this.state.inType=e,this.finishNode(t,`TypeParameterDeclaration`)}flowInTopLevelContext(e){if(this.curContext()!==Od.brace){let t=this.state.context;this.state.context=[t[0]];try{return e()}finally{this.state.context=t}}else return e()}flowParseTypeParameterInstantiationInExpression(){if(this.reScan_lt()===43)return this.flowParseTypeParameterInstantiation()}flowParseTypeParameterInstantiation(){let e=this.startNode(),t=this.state.inType;return this.state.inType=!0,e.params=[],this.flowInTopLevelContext(()=>{this.expect(43);let t=this.state.noAnonFunctionType;for(this.state.noAnonFunctionType=!1;!this.match(44);)e.params.push(this.flowParseType()),this.match(44)||this.expect(8);this.state.noAnonFunctionType=t}),this.state.inType=t,!this.state.inType&&this.curContext()===Od.brace&&this.reScan_lt_gt(),this.expect(44),this.finishNode(e,`TypeParameterInstantiation`)}flowParseTypeParameterInstantiationCallOrNew(){if(this.reScan_lt()!==43)return null;let e=this.startNode(),t=this.state.inType;for(e.params=[],this.state.inType=!0,this.expect(43);!this.match(44);)e.params.push(this.flowParseTypeOrImplicitInstantiation()),this.match(44)||this.expect(8);return this.expect(44),this.state.inType=t,this.finishNode(e,`TypeParameterInstantiation`)}flowParseInterfaceType(){let e=this.startNode();if(this.expectContextual(125),e.extends=[],this.eat(77))do e.extends.push(this.flowParseInterfaceExtends());while(this.eat(8));return e.body=this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!1,allowProto:!1,allowInexact:!1}),this.finishNode(e,`InterfaceTypeAnnotation`)}flowParseObjectPropertyKey(){return this.match(131)||this.match(130)?super.parseExprAtom():this.parseIdentifier(!0)}flowParseObjectTypeIndexer(e,t,n){return e.static=t,this.lookahead().type===10?(e.id=this.parseIdentifier(!0),e.key=this.flowParseTypeInitialiser()):(e.id=null,e.key=this.flowParseType()),this.expect(1),e.value=this.flowParseTypeInitialiser(),e.variance=n,this.finishNode(e,`ObjectTypeIndexer`)}flowParseObjectTypeInternalSlot(e,t){return e.static=t,e.id=this.parseIdentifier(!0),this.expect(1),this.expect(1),this.match(43)||this.match(6)?(e.method=!0,e.optional=!1,e.value=this.flowParseObjectTypeMethodish(this.startNodeAtNode(e))):(e.method=!1,this.eat(13)&&(e.optional=!0),e.value=this.flowParseTypeInitialiser()),this.finishNode(e,`ObjectTypeInternalSlot`)}flowParseObjectTypeMethodish(e){for(e.params=[],e.rest=null,e.typeParameters=null,e.this=null,this.match(43)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),this.expect(6),this.match(74)&&(e.this=this.flowParseFunctionTypeParam(!0),e.this.name=null,this.match(7)||this.expect(8));!this.match(7)&&!this.match(17);)e.params.push(this.flowParseFunctionTypeParam(!1)),this.match(7)||this.expect(8);return this.eat(17)&&(e.rest=this.flowParseFunctionTypeParam(!1)),this.expect(7),e.returnType=this.flowParseTypeInitialiser(),this.finishNode(e,`FunctionTypeAnnotation`)}flowParseObjectTypeCallProperty(e,t){let n=this.startNode();return e.static=t,e.value=this.flowParseObjectTypeMethodish(n),this.finishNode(e,`ObjectTypeCallProperty`)}flowParseObjectType({allowStatic:e,allowExact:t,allowSpread:n,allowProto:r,allowInexact:i}){let a=this.state.inType;this.state.inType=!0;let o=this.startNode();o.callProperties=[],o.properties=[],o.indexers=[],o.internalSlots=[];let s,c,l=!1;for(t&&this.match(3)?(this.expect(3),s=5,c=!0):(this.expect(2),s=4,c=!1),o.exact=c;!this.match(s);){let t=!1,a=null,s=null,u=this.startNode();if(r&&this.isContextual(114)){let t=this.lookahead();t.type!==10&&t.type!==13&&(this.next(),a=this.state.startLoc,e=!1)}if(e&&this.isContextual(102)){let e=this.lookahead();e.type!==10&&e.type!==13&&(this.next(),t=!0)}let d=this.flowParseVariance();if(this.eat(0))a!=null&&this.unexpected(a),this.eat(0)?(d&&this.unexpected(d.start),o.internalSlots.push(this.flowParseObjectTypeInternalSlot(u,t))):o.indexers.push(this.flowParseObjectTypeIndexer(u,t,d));else if(this.match(6)||this.match(43))a!=null&&this.unexpected(a),d&&this.unexpected(d.start),o.callProperties.push(this.flowParseObjectTypeCallProperty(u,t));else{let e=`init`;(this.isContextual(95)||this.isContextual(100))&&ud(this.lookahead().type)&&(e=this.state.value,this.next());let r=this.flowParseObjectTypeProperty(u,t,a,d,e,n,i??!c);r===null?(l=!0,s=this.state.lastTokStartLoc):o.properties.push(r)}this.flowObjectTypeSemicolon(),s&&!this.match(4)&&!this.match(5)&&this.raise($d.UnexpectedExplicitInexactInObject,s)}this.expect(s),n&&(o.inexact=l);let u=this.finishNode(o,`ObjectTypeAnnotation`);return this.state.inType=a,u}flowParseObjectTypeProperty(e,t,n,r,i,a,o){if(this.eat(17))return this.match(8)||this.match(9)||this.match(4)||this.match(5)?(a?o||this.raise($d.InexactInsideExact,this.state.lastTokStartLoc):this.raise($d.InexactInsideNonObject,this.state.lastTokStartLoc),r&&this.raise($d.InexactVariance,r),null):(a||this.raise($d.UnexpectedSpreadType,this.state.lastTokStartLoc),n!=null&&this.unexpected(n),r&&this.raise($d.SpreadVariance,r),e.argument=this.flowParseType(),this.finishNode(e,`ObjectTypeSpreadProperty`));{e.key=this.flowParseObjectPropertyKey(),e.static=t,e.proto=n!=null,e.kind=i;let o=!1;return this.match(43)||this.match(6)?(e.method=!0,n!=null&&this.unexpected(n),r&&this.unexpected(r.start),e.value=this.flowParseObjectTypeMethodish(this.startNodeAtNode(e)),i===`get`||i===`set`?this.flowCheckGetterSetterParams(e):!t&&!a&&e.key.name===`constructor`&&e.value.this&&this.raise($d.ThisParamBannedInConstructor,e.value.this)):(i!==`init`&&this.unexpected(),e.method=!1,this.eat(13)&&(o=!0),e.value=this.flowParseTypeInitialiser(),e.variance=r),e.optional=o,this.finishNode(e,`ObjectTypeProperty`)}}flowCheckGetterSetterParams(e){let t=e.kind===`get`?0:1,n=e.value,r=n.params.length+ +!!n.rest;n.this&&this.raise(e.kind===`get`?$d.GetterMayNotHaveThisParam:$d.SetterMayNotHaveThisParam,n.this),r!==t&&this.raise(e.kind===`get`?G.BadGetterArity:G.BadSetterArity,e),e.kind===`set`&&n.rest&&this.raise(G.BadSetterRestParameter,e)}flowObjectTypeSemicolon(){!this.eat(9)&&!this.eat(8)&&!this.match(4)&&!this.match(5)&&this.unexpected()}flowParseQualifiedTypeIdentifier(e,t){e??=this.state.startLoc;let n=t||this.flowParseRestrictedIdentifier(!0);for(;this.eat(12);){let t=this.startNodeAt(e);t.qualification=n,t.id=this.flowParseRestrictedIdentifier(!0),n=this.finishNode(t,`QualifiedTypeIdentifier`)}return n}flowParseGenericType(e,t){let n=this.startNodeAt(e);return n.typeParameters=null,n.id=this.flowParseQualifiedTypeIdentifier(e,t),this.match(43)&&(n.typeParameters=this.flowParseTypeParameterInstantiation()),this.finishNode(n,`GenericTypeAnnotation`)}flowParseTypeofType(){let e=this.startNode();return this.expect(83),e.argument=this.flowParsePrimaryType(),this.finishNode(e,`TypeofTypeAnnotation`)}flowParseTupleType(){let e=this.startNode();for(e.types=[],this.expect(0);this.state.pos<this.length&&!this.match(1)&&(e.types.push(this.flowParseType()),!this.match(1));)this.expect(8);return this.expect(1),this.finishNode(e,`TupleTypeAnnotation`)}flowParseFunctionTypeParam(e){let t=null,n=!1,r,i=this.startNode(),a=this.lookahead(),o=this.state.type===74;return a.type===10||a.type===13?(o&&!e&&this.raise($d.ThisParamMustBeFirst,i),t=this.parseIdentifier(o),this.eat(13)&&(n=!0,o&&this.raise($d.ThisParamMayNotBeOptional,i)),r=this.flowParseTypeInitialiser()):r=this.flowParseType(),i.name=t,i.optional=n,i.typeAnnotation=r,this.finishNode(i,`FunctionTypeParam`)}reinterpretTypeAsFunctionTypeParam(e){let t=this.startNodeAtNode(e);return t.name=null,t.optional=!1,t.typeAnnotation=e,this.finishNode(t,`FunctionTypeParam`)}flowParseFunctionTypeParams(e=[]){let t=null,n=null;for(this.match(74)&&(n=this.flowParseFunctionTypeParam(!0),n.name=null,this.match(7)||this.expect(8));!this.match(7)&&!this.match(17);)e.push(this.flowParseFunctionTypeParam(!1)),this.match(7)||this.expect(8);return this.eat(17)&&(t=this.flowParseFunctionTypeParam(!1)),{params:e,rest:t,_this:n}}flowIdentToTypeAnnotation(e,t,n){switch(n.name){case`any`:return this.finishNode(t,`AnyTypeAnnotation`);case`bool`:case`boolean`:return this.finishNode(t,`BooleanTypeAnnotation`);case`mixed`:return this.finishNode(t,`MixedTypeAnnotation`);case`empty`:return this.finishNode(t,`EmptyTypeAnnotation`);case`number`:return this.finishNode(t,`NumberTypeAnnotation`);case`string`:return this.finishNode(t,`StringTypeAnnotation`);case`symbol`:return this.finishNode(t,`SymbolTypeAnnotation`);default:return this.checkNotUnderscore(n.name),this.flowParseGenericType(e,n)}}flowParsePrimaryType(){let e=this.state.startLoc,t=this.startNode(),n,r,i=!1,a=this.state.noAnonFunctionType;switch(this.state.type){case 2:return this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!0,allowProto:!1,allowInexact:!0});case 3:return this.flowParseObjectType({allowStatic:!1,allowExact:!0,allowSpread:!0,allowProto:!1,allowInexact:!1});case 0:return this.state.noAnonFunctionType=!1,r=this.flowParseTupleType(),this.state.noAnonFunctionType=a,r;case 43:{let e=this.startNode();return e.typeParameters=this.flowParseTypeParameterDeclaration(),this.expect(6),n=this.flowParseFunctionTypeParams(),e.params=n.params,e.rest=n.rest,e.this=n._this,this.expect(7),this.expect(15),e.returnType=this.flowParseType(),this.finishNode(e,`FunctionTypeAnnotation`)}case 6:{let e=this.startNode();if(this.next(),!this.match(7)&&!this.match(17)){if(sd(this.state.type)||this.match(74)){let e=this.lookahead().type;i=e!==13&&e!==10}else i=!0}if(i){if(this.state.noAnonFunctionType=!1,r=this.flowParseType(),this.state.noAnonFunctionType=a,this.state.noAnonFunctionType||!(this.match(8)||this.match(7)&&this.lookahead().type===15))return this.expect(7),r;this.eat(8)}return n=r?this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(r)]):this.flowParseFunctionTypeParams(),e.params=n.params,e.rest=n.rest,e.this=n._this,this.expect(7),this.expect(15),e.returnType=this.flowParseType(),e.typeParameters=null,this.finishNode(e,`FunctionTypeAnnotation`)}case 130:return this.parseLiteral(this.state.value,`StringLiteralTypeAnnotation`);case 81:case 82:return t.value=this.match(81),this.next(),this.finishNode(t,`BooleanLiteralTypeAnnotation`);case 49:if(this.state.value===`-`){if(this.next(),this.match(131))return this.parseLiteralAtNode(-this.state.value,`NumberLiteralTypeAnnotation`,t);if(this.match(132))return this.parseLiteralAtNode(-this.state.value,`BigIntLiteralTypeAnnotation`,t);throw this.raise($d.UnexpectedSubtractionOperand,this.state.startLoc)}throw this.unexpected();case 131:return this.parseLiteral(this.state.value,`NumberLiteralTypeAnnotation`);case 132:return this.parseLiteral(this.state.value,`BigIntLiteralTypeAnnotation`);case 84:return this.next(),this.finishNode(t,`VoidTypeAnnotation`);case 80:return this.next(),this.finishNode(t,`NullLiteralTypeAnnotation`);case 74:return this.next(),this.finishNode(t,`ThisTypeAnnotation`);case 51:return this.next(),this.finishNode(t,`ExistsTypeAnnotation`);case 83:return this.flowParseTypeofType();default:if(gd(this.state.type)){let e=Sd(this.state.type);return this.next(),super.createIdentifier(t,e)}if(sd(this.state.type))return this.isContextual(125)?this.flowParseInterfaceType():this.flowIdentToTypeAnnotation(e,t,this.parseIdentifier())}throw this.unexpected()}flowParsePostfixType(){let e=this.state.startLoc,t=this.flowParsePrimaryType(),n=!1;for(;(this.match(0)||this.match(14))&&!this.canInsertSemicolon();){let r=this.startNodeAt(e),i=this.eat(14);n||=i,this.expect(0),!i&&this.match(1)?(r.elementType=t,this.next(),t=this.finishNode(r,`ArrayTypeAnnotation`)):(r.objectType=t,r.indexType=this.flowParseType(),this.expect(1),n?(r.optional=i,t=this.finishNode(r,`OptionalIndexedAccessType`)):t=this.finishNode(r,`IndexedAccessType`))}return t}flowParsePrefixType(){let e=this.startNode();return this.eat(13)?(e.typeAnnotation=this.flowParsePrefixType(),this.finishNode(e,`NullableTypeAnnotation`)):this.flowParsePostfixType()}flowParseAnonFunctionWithoutParens(){let e=this.flowParsePrefixType();if(!this.state.noAnonFunctionType&&this.eat(15)){let t=this.startNodeAtNode(e);return t.params=[this.reinterpretTypeAsFunctionTypeParam(e)],t.rest=null,t.this=null,t.returnType=this.flowParseType(),t.typeParameters=null,this.finishNode(t,`FunctionTypeAnnotation`)}return e}flowParseIntersectionType(){let e=this.startNode();this.eat(41);let t=this.flowParseAnonFunctionWithoutParens();for(e.types=[t];this.eat(41);)e.types.push(this.flowParseAnonFunctionWithoutParens());return e.types.length===1?t:this.finishNode(e,`IntersectionTypeAnnotation`)}flowParseUnionType(){let e=this.startNode();this.eat(39);let t=this.flowParseIntersectionType();for(e.types=[t];this.eat(39);)e.types.push(this.flowParseIntersectionType());return e.types.length===1?t:this.finishNode(e,`UnionTypeAnnotation`)}flowParseType(){let e=this.state.inType;this.state.inType=!0;let t=this.flowParseUnionType();return this.state.inType=e,t}flowParseTypeOrImplicitInstantiation(){if(this.state.type===128&&this.state.value===`_`){let e=this.state.startLoc,t=this.parseIdentifier();return this.flowParseGenericType(e,t)}return this.flowParseType()}flowParseTypeAnnotation(){let e=this.startNode();return e.typeAnnotation=this.flowParseTypeInitialiser(),this.finishNode(e,`TypeAnnotation`)}flowParseTypeAnnotatableIdentifier(){let e=this.startNode(),t=this.parseIdentifierName();return this.match(10)&&(e.typeAnnotation=this.flowParseTypeAnnotation()),this.createIdentifier(e,t)}typeCastToParameter(e){return e.expression.typeAnnotation=e.typeAnnotation,this.resetEndLocationFromNode(e.expression,e.typeAnnotation),e.expression}flowParseVariance(){let e=null;return this.match(49)?(e=this.startNode(),this.state.value===`+`?e.kind=`plus`:e.kind=`minus`,this.next(),this.finishNode(e,`Variance`)):e}parseFunctionBody(e,t,n=!1){if(t){this.forwardNoArrowParamsConversionAt(e,()=>super.parseFunctionBody(e,!0,n));return}super.parseFunctionBody(e,!1,n)}parseFunctionBodyAndFinish(e,t,n=!1){if(this.match(10)){let n=this.startNode();t===`FunctionDeclaration`||t===`FunctionExpression`||t===`ArrowFunctionExpression`?[n.typeAnnotation,e.predicate]=this.flowParseTypeAndPredicateInitialiser(!0):n.typeAnnotation=this.flowParseTypeInitialiser(),e.returnType=n.typeAnnotation?this.finishNode(n,`TypeAnnotation`):null}return super.parseFunctionBodyAndFinish(e,t,n)}parseStatementLike(e){if(this.state.strict&&this.isContextual(125)){if(ld(this.lookahead().type)){let e=this.startNode();return this.next(),this.flowParseInterface(e)}}else if(this.isContextual(122)){let e=this.startNode();return this.next(),this.flowParseEnumDeclaration(e)}let t=super.parseStatementLike(e);return this.flowPragma===void 0&&!this.isValidDirective(t)&&(this.flowPragma=null),t}parseExpressionStatement(e,t){if(t.type===`Identifier`){if(t.name===`declare`){if(this.match(76)||sd(this.state.type)||this.match(64)||this.match(70)||this.match(78))return this.flowParseDeclare(e)}else if(sd(this.state.type)){if(t.name===`interface`)return this.flowParseInterface(e);if(t.name===`type`)return this.flowParseTypeAlias(e);if(t.name===`opaque`)return this.flowParseOpaqueType(e,!1)}}return super.parseExpressionStatement(e,t)}shouldParseExportDeclaration(){let{type:e}=this.state;return e===122||md(e)?!this.state.containsEsc:super.shouldParseExportDeclaration()}isExportDefaultSpecifier(){let{type:e}=this.state;return e===122||md(e)?this.state.containsEsc:super.isExportDefaultSpecifier()}parseExportDefaultExpression(){if(this.isContextual(122)){let e=this.startNode();return this.next(),this.flowParseEnumDeclaration(e)}return super.parseExportDefaultExpression()}parseConditional(e,t,n){if(!this.match(13))return e;if(n!=null){let t=this.lookaheadCharCode();if(t===44||t===61||t===58||t===41)return this.setOptionalParametersError(n),e}this.expect(13);let r=this.state.clone(),i=this.state.noArrowAt,a=this.startNodeAt(t),{consequent:o,failed:s}=this.tryParseConditionalConsequent(),c=this.getArrowLikeExpressions(o),l=c[0],u=c[1];if(s||u.length>0){let e=[...i];if(u.length>0){this.state=r,this.state.noArrowAt=e;for(let t=0;t<u.length;t++)e.push(u[t].start);({consequent:o,failed:s}=this.tryParseConditionalConsequent()),[l]=this.getArrowLikeExpressions(o)}s&&l.length>1&&this.raise($d.AmbiguousConditionalArrow,r.startLoc),s&&l.length===1&&(this.state=r,e.push(l[0].start),this.state.noArrowAt=e,{consequent:o}=this.tryParseConditionalConsequent())}return this.getArrowLikeExpressions(o,!0),this.state.noArrowAt=i,this.expect(10),a.test=e,a.consequent=o,a.alternate=this.forwardNoArrowParamsConversionAt(a,()=>this.parseMaybeAssign()),this.finishNode(a,`ConditionalExpression`)}tryParseConditionalConsequent(){this.state.noArrowParamsConversionAt.push(this.state.start);let e=this.parseMaybeAssignAllowIn(),t=!this.match(10);return this.state.noArrowParamsConversionAt.pop(),{consequent:e,failed:t}}getArrowLikeExpressions(e,t){let n=[e],r=[];for(;n.length!==0;){let e=n.pop();e.type===`ArrowFunctionExpression`?(e.typeParameters||!e.returnType?this.finishArrowValidation(e):r.push(e),e.body.type!==`BlockStatement`&&n.push(e.body)):e.type===`ConditionalExpression`&&(n.push(e.consequent),n.push(e.alternate))}return t?(r.forEach(e=>this.finishArrowValidation(e)),[r,[]]):rf(r,e=>e.params.every(e=>this.isAssignable(e,!0)))}finishArrowValidation(e){this.toAssignableList(e.params,e.extra?.trailingCommaLoc,!1),this.scope.enter(518),super.checkParams(e,!1,!0),this.scope.exit()}forwardNoArrowParamsConversionAt(e,t){let n;return this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start))?(this.state.noArrowParamsConversionAt.push(this.state.start),n=t(),this.state.noArrowParamsConversionAt.pop()):n=t(),n}parseParenItem(e,t){let n=super.parseParenItem(e,t);if(this.eat(13)&&(n.optional=!0,this.resetEndLocation(e)),this.match(10)){let e=this.startNodeAt(t);return e.expression=n,e.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(e,`TypeCastExpression`)}return n}assertModuleNodeAllowed(e){e.type===`ImportDeclaration`&&(e.importKind===`type`||e.importKind===`typeof`)||e.type===`ExportNamedDeclaration`&&e.exportKind===`type`||e.type===`ExportAllDeclaration`&&e.exportKind===`type`||super.assertModuleNodeAllowed(e)}parseExportDeclaration(e){if(this.isContextual(126)){e.exportKind=`type`;let t=this.startNode();return this.next(),this.match(2)?(e.specifiers=this.parseExportSpecifiers(!0),super.parseExportFrom(e),null):this.flowParseTypeAlias(t)}if(this.isContextual(127)){e.exportKind=`type`;let t=this.startNode();return this.next(),this.flowParseOpaqueType(t,!1)}if(this.isContextual(125)){e.exportKind=`type`;let t=this.startNode();return this.next(),this.flowParseInterface(t)}if(this.isContextual(122)){e.exportKind=`value`;let t=this.startNode();return this.next(),this.flowParseEnumDeclaration(t)}return super.parseExportDeclaration(e)}eatExportStar(e){return super.eatExportStar(e)?!0:this.isContextual(126)&&this.lookahead().type===51?(e.exportKind=`type`,this.next(),this.next(),!0):!1}maybeParseExportNamespaceSpecifier(e){let{startLoc:t}=this.state,n=super.maybeParseExportNamespaceSpecifier(e);return n&&e.exportKind===`type`&&this.unexpected(t),n}parseClassId(e,t,n){if((!t||n)&&this.isContextual(109)){e.id=null;return}super.parseClassId(e,t,n),this.match(43)&&(e.typeParameters=this.flowParseTypeParameterDeclaration())}parseClassMember(e,t,n){let{startLoc:r}=this.state;if(this.isContextual(121)){if(super.parseClassMemberFromModifier(e,t))return;t.declare=!0}super.parseClassMember(e,t,n),t.declare&&(t.type!==`ClassProperty`&&t.type!==`ClassPrivateProperty`&&t.type!==`PropertyDefinition`?this.raise($d.DeclareClassElement,r):t.value&&this.raise($d.DeclareClassFieldInitializer,t.value))}isIterator(e){return e===`iterator`||e===`asyncIterator`}readIterator(){let e=super.readWord1(),t=`@@`+e;(!this.isIterator(e)||!this.state.inType)&&this.raise(G.InvalidIdentifier,this.state.curPosition(),{identifierName:t}),this.finishToken(128,t)}getTokenFromCode(e){let t=this.input.charCodeAt(this.state.pos+1);e===123&&t===124?this.finishOp(3,2):this.state.inType&&(e===62||e===60)?this.finishOp(e===62?44:43,1):this.state.inType&&e===63?t===46?this.finishOp(14,2):this.finishOp(13,1):Gd(e,t,this.input.charCodeAt(this.state.pos+2))?(this.state.pos+=2,this.readIterator()):super.getTokenFromCode(e)}isAssignable(e,t){return e.type===`TypeCastExpression`?this.isAssignable(e.expression,t):super.isAssignable(e,t)}toAssignable(e,t=!1){!t&&e.type===`AssignmentExpression`&&e.left.type===`TypeCastExpression`&&(e.left=this.typeCastToParameter(e.left)),super.toAssignable(e,t)}toAssignableListItem(e,t,n){let r=e[t];r.type===`TypeCastExpression`&&(e[t]=this.typeCastToParameter(r)),super.toAssignableListItem(e,t,n)}toReferencedList(e,t){for(let n=0;n<e.length;n++){let r=e[n];r?.type===`TypeCastExpression`&&!r.extra?.parenthesized&&(e.length>1||!t)&&this.raise($d.TypeCastInPattern,r.typeAnnotation)}return e}parseArrayLike(e,t){let n=super.parseArrayLike(e,t);return n.type===`ArrayExpression`&&this.toReferencedList(n.elements),n}isValidLVal(e,t,n,r){return e===`TypeCastExpression`||super.isValidLVal(e,t,n,r)}parseClassProperty(e){return this.match(10)&&(e.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassProperty(e)}parseClassPrivateProperty(e){return this.match(10)&&(e.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassPrivateProperty(e)}isClassMethod(){return this.match(43)||super.isClassMethod()}isClassProperty(){return this.match(10)||super.isClassProperty()}isNonstaticConstructor(e){return!this.match(10)&&super.isNonstaticConstructor(e)}pushClassMethod(e,t,n,r,i,a){if(t.variance&&this.unexpected(t.variance.start),delete t.variance,this.match(43)&&(t.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassMethod(e,t,n,r,i,a),t.params&&i){let e=t.params;e.length>0&&this.isThisParam(e[0])&&this.raise($d.ThisParamBannedInConstructor,t)}else if(t.type===`MethodDefinition`&&i&&t.value.params){let e=t.value.params;e.length>0&&this.isThisParam(e[0])&&this.raise($d.ThisParamBannedInConstructor,t)}}pushClassPrivateMethod(e,t,n,r){t.variance&&this.unexpected(t.variance.start),delete t.variance,this.match(43)&&(t.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassPrivateMethod(e,t,n,r)}flowParseClassImplements(){let e=this.startNode();return e.id=this.flowParseRestrictedIdentifier(!0),e.typeParameters=this.match(43)?this.flowParseTypeParameterInstantiation():null,this.finishNode(e,`ClassImplements`)}parseClassSuper(e){if(super.parseClassSuper(e),e.superClass&&(this.match(43)||this.match(47))&&(e.superTypeArguments=this.flowParseTypeParameterInstantiationInExpression()),this.eatContextual(109)){let t=e.implements=[];do t.push(this.flowParseClassImplements());while(this.eat(8))}}checkGetterSetterParams(e){super.checkGetterSetterParams(e);let t=this.getObjectOrClassMethodParams(e);if(t.length>0){let n=t[0];this.isThisParam(n)&&e.kind===`get`?this.raise($d.GetterMayNotHaveThisParam,n):this.isThisParam(n)&&this.raise($d.SetterMayNotHaveThisParam,n)}}parsePropertyNamePrefixOperator(e){e.variance=this.flowParseVariance()}parseObjPropValue(e,t,n,r,i,a,o){e.variance&&this.unexpected(e.variance.start),delete e.variance;let s;this.match(43)&&!a&&(s=this.flowParseTypeParameterDeclaration(),this.match(6)||this.unexpected());let c=super.parseObjPropValue(e,t,n,r,i,a,o);return s&&((c.value||c).typeParameters=s),c}parseFunctionParamType(e){return this.eat(13)&&(e.type!==`Identifier`&&this.raise($d.PatternIsOptional,e),this.isThisParam(e)&&this.raise($d.ThisParamMayNotBeOptional,e),e.optional=!0),this.match(10)?e.typeAnnotation=this.flowParseTypeAnnotation():this.isThisParam(e)&&this.raise($d.ThisParamAnnotationRequired,e),this.match(25)&&this.isThisParam(e)&&this.raise($d.ThisParamNoDefault,e),this.resetEndLocation(e),e}parseMaybeDefault(e,t){let n=super.parseMaybeDefault(e,t);return n.type===`AssignmentPattern`&&n.typeAnnotation&&n.right.start<n.typeAnnotation.start&&this.raise($d.TypeBeforeInitializer,n.typeAnnotation),n}parseImportSpecifierLocal(e,t,n){t.local=tf(e)?this.flowParseRestrictedIdentifier(!0,!0):this.parseIdentifier(),e.specifiers.push(this.finishImportSpecifier(t,n))}isPotentialImportPhase(e){if(super.isPotentialImportPhase(e))return!0;if(this.isContextual(126)){if(!e)return!0;let t=this.lookaheadCharCode();return t===123||t===42}return!e&&this.isContextual(83)}applyImportPhase(e,t,n,r){if(super.applyImportPhase(e,t,n,r),t){if(!n&&this.match(61))return;e.exportKind=n===`type`?n:`value`}else n===`type`&&this.match(51)&&this.unexpected(),e.importKind=n===`type`||n===`typeof`?n:`value`}parseImportSpecifier(e,t,n,r,i){let a=e.imported,o=null;a.type===`Identifier`&&(a.name===`type`?o=`type`:a.name===`typeof`&&(o=`typeof`));let s=!1;if(this.isContextual(89)&&!this.isLookaheadContextual(`as`)){let t=this.parseIdentifier(!0);o!==null&&!ld(this.state.type)?(e.imported=t,e.importKind=o,e.local=this.cloneIdentifier(t)):(e.imported=a,e.importKind=null,e.local=this.parseIdentifier())}else{if(o!==null&&ld(this.state.type))e.imported=this.parseIdentifier(!0),e.importKind=o;else{if(t)throw this.raise(G.ImportBindingIsString,e,{importName:a.value});e.imported=a,e.importKind=null}this.eatContextual(89)?e.local=this.parseIdentifier():(s=!0,e.local=this.cloneIdentifier(e.imported))}let c=tf(e);return n&&c&&this.raise($d.ImportTypeShorthandOnlyInPureImport,e),(n||c)&&this.checkReservedType(e.local.name,e.local.start,!0),s&&!n&&!c&&this.checkReservedWord(e.local.name,e.start,!0,!0),this.finishImportSpecifier(e,`ImportSpecifier`)}parseBindingAtom(){switch(this.state.type){case 74:return this.parseIdentifier(!0);default:return super.parseBindingAtom()}}parseFunctionParams(e,t){let n=e.kind;n!==`get`&&n!==`set`&&this.match(43)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),super.parseFunctionParams(e,t)}parseVarId(e,t){super.parseVarId(e,t),this.match(10)&&(e.id.typeAnnotation=this.flowParseTypeAnnotation(),this.resetEndLocation(e.id))}parseAsyncArrowFromCallExpression(e,t){if(this.match(10)){let t=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0,e.returnType=this.flowParseTypeAnnotation(),this.state.noAnonFunctionType=t}return super.parseAsyncArrowFromCallExpression(e,t)}shouldParseAsyncArrow(){return this.match(10)||super.shouldParseAsyncArrow()}parseMaybeAssign(e,t){let n=null,r;if(this.hasPlugin(`jsx`)&&(this.match(138)||this.match(43))){if(n=this.state.clone(),r=this.tryParse(()=>super.parseMaybeAssign(e,t),n),!r.error)return r.node;let{context:i}=this.state,a=i[i.length-1];(a===Od.j_oTag||a===Od.j_expr)&&i.pop()}if(r?.error||this.match(43)){n||=this.state.clone();let i,a=this.tryParse(n=>{i=this.flowParseTypeParameterDeclaration();let r=this.forwardNoArrowParamsConversionAt(i,()=>{let n=super.parseMaybeAssign(e,t);return this.resetStartLocationFromNode(n,i),n});r.extra?.parenthesized&&n();let a=this.maybeUnwrapTypeCastExpression(r);return a.type!==`ArrowFunctionExpression`&&n(),a.typeParameters=i,this.resetStartLocationFromNode(a,i),r},n),o=null;if(a.node&&this.maybeUnwrapTypeCastExpression(a.node).type===`ArrowFunctionExpression`){if(!a.error&&!a.aborted)return a.node.async&&this.raise($d.UnexpectedTypeParameterBeforeAsyncArrowFunction,i),a.node;o=a.node}if(r?.node)return this.state=r.failState,r.node;if(o)return this.state=a.failState,o;throw r?.thrown?r.error:a.thrown?a.error:this.raise($d.UnexpectedTokenAfterTypeParameter,i)}return super.parseMaybeAssign(e,t)}parseArrow(e){if(this.match(10)){let t=this.tryParse(()=>{let t=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0;let n=this.startNode();return[n.typeAnnotation,e.predicate]=this.flowParseTypeAndPredicateInitialiser(!0),this.state.noAnonFunctionType=t,this.canInsertSemicolon()&&this.unexpected(),this.match(15)||this.unexpected(),n});if(t.thrown)return null;t.error&&(this.state=t.failState),e.returnType=t.node.typeAnnotation?this.finishNode(t.node,`TypeAnnotation`):null}return super.parseArrow(e)}shouldParseArrow(e){return this.match(10)||super.shouldParseArrow(e)}setArrowFunctionParameters(e,t){this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start))?e.params=t:super.setArrowFunctionParameters(e,t)}checkParams(e,t,n,r=!0){if(!(n&&this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start)))){for(let t=0;t<e.params.length;t++)this.isThisParam(e.params[t])&&t>0&&this.raise($d.ThisParamMustBeFirst,e.params[t]);super.checkParams(e,t,n,r)}}parseParenAndDistinguishExpression(e){return super.parseParenAndDistinguishExpression(e&&!this.state.noArrowAt.includes(this.sourceToOffsetPos(this.state.start)))}parseSubscripts(e,t,n){if(e.type===`Identifier`&&e.name===`async`&&this.state.noArrowAt.includes(t.index)){this.next();let n=this.startNodeAt(t);n.callee=e,n.arguments=super.parseCallExpressionArguments(),e=this.finishNode(n,`CallExpression`)}else if(e.type===`Identifier`&&e.name===`async`&&this.match(43)){let r=this.state.clone(),i=this.tryParse(e=>this.parseAsyncArrowWithTypeParameters(t)||e(),r);if(!i.error&&!i.aborted)return i.node;let a=this.tryParse(()=>super.parseSubscripts(e,t,n),r);if(a.node&&!a.error)return a.node;if(i.node)return this.state=i.failState,i.node;if(a.node)return this.state=a.failState,a.node;throw i.error||a.error}return super.parseSubscripts(e,t,n)}parseSubscript(e,t,n,r){if(this.match(14)&&this.isLookaheadToken_lt()){if(r.optionalChainMember=!0,n)return r.stop=!0,e;this.next();let i=this.startNodeAt(t);return i.callee=e,i.typeArguments=this.flowParseTypeParameterInstantiationInExpression(),this.expect(6),i.arguments=this.parseCallExpressionArguments(),i.optional=!0,this.finishCallExpression(i,!0)}if(!n&&this.shouldParseTypes()&&(this.match(43)||this.match(47))){let n=this.startNodeAt(t);n.callee=e;let i=this.tryParse(()=>(n.typeArguments=this.flowParseTypeParameterInstantiationCallOrNew(),this.expect(6),n.arguments=super.parseCallExpressionArguments(),r.optionalChainMember&&(n.optional=!1),this.finishCallExpression(n,r.optionalChainMember)));if(i.node)return i.error&&(this.state=i.failState),i.node}return super.parseSubscript(e,t,n,r)}parseNewCallee(e){super.parseNewCallee(e);let t=null;this.shouldParseTypes()&&this.match(43)&&(t=this.tryParse(()=>this.flowParseTypeParameterInstantiationCallOrNew()).node),e.typeArguments=t}parseAsyncArrowWithTypeParameters(e){let t=this.startNodeAt(e);if(this.parseFunctionParams(t,!1),this.parseArrow(t))return super.parseArrowExpression(t,void 0,!0)}readToken_mult_modulo(e){let t=this.input.charCodeAt(this.state.pos+1);if(e===42&&t===47&&this.state.hasFlowComment){this.state.hasFlowComment=!1,this.state.pos+=2,this.nextToken();return}super.readToken_mult_modulo(e)}readToken_pipe_amp(e){let t=this.input.charCodeAt(this.state.pos+1);if(e===124&&t===125){this.finishOp(5,2);return}super.readToken_pipe_amp(e)}parseTopLevel(e,t){let n=super.parseTopLevel(e,t);return this.state.hasFlowComment&&this.raise($d.UnterminatedFlowComment,this.state.curPosition()),n}skipBlockComment(){if(this.hasPlugin(`flowComments`)&&this.skipFlowComment()){if(this.state.hasFlowComment)throw this.raise($d.NestedFlowComment,this.state.startLoc);this.hasFlowCommentCompletion();let e=this.skipFlowComment();e&&(this.state.pos+=e,this.state.hasFlowComment=!0);return}return super.skipBlockComment(this.state.hasFlowComment?`*-/`:`*/`)}skipFlowComment(){let{pos:e}=this.state,t=2;for(;[32,9].includes(this.input.charCodeAt(e+t));)t++;let n=this.input.charCodeAt(t+e),r=this.input.charCodeAt(t+e+1);return n===58&&r===58?t+2:this.input.slice(t+e,t+e+12)===`flow-include`?t+12:n===58&&r!==58&&t}hasFlowCommentCompletion(){if(this.input.indexOf(`*/`,this.state.pos)===-1)throw this.raise(G.UnterminatedComment,this.state.curPosition())}flowEnumErrorBooleanMemberNotInitialized(e,t){this.raise($d.EnumBooleanMemberNotInitialized,e,t)}flowEnumErrorInvalidMemberInitializer(e,t){return this.raise(t.explicitType?t.explicitType===`symbol`?$d.EnumInvalidMemberInitializerSymbolType:$d.EnumInvalidMemberInitializerPrimaryType:$d.EnumInvalidMemberInitializerUnknownType,e,t)}flowEnumErrorNumberMemberNotInitialized(e,t){this.raise($d.EnumNumberMemberNotInitialized,e,t)}flowEnumErrorStringMemberInconsistentlyInitialized(e,t){this.raise($d.EnumStringMemberInconsistentlyInitialized,e,t)}flowEnumMemberInit(){let e=this.state.startLoc,t=()=>this.match(8)||this.match(4);switch(this.state.type){case 131:{let e=this.parseNumericLiteral(this.state.value);if(t())return{type:`number`,loc:e.start,value:e};break}case 130:{let e=this.parseStringLiteral(this.state.value);if(t())return{type:`string`,loc:e.start,value:e};break}case 81:case 82:{let e=this.parseBooleanLiteral(this.match(81));if(t())return{type:`boolean`,loc:e.start,value:e}}}return{type:`invalid`,loc:e}}flowEnumMemberRaw(){let e=this.state.startLoc;return{id:this.parseIdentifier(!0),init:this.eat(25)?this.flowEnumMemberInit():{type:`none`,loc:e}}}flowEnumCheckExplicitTypeMismatch(e,t,n){let{explicitType:r}=t;r!==null&&r!==n&&this.flowEnumErrorInvalidMemberInitializer(e,t)}flowEnumMembers({enumName:e,explicitType:t}){let n=new Set,r={booleanMembers:[],numberMembers:[],stringMembers:[],defaultedMembers:[]},i=!1;for(;!this.match(4);){if(this.eat(17)){i=!0;break}let a=this.startNode(),{id:o,init:s}=this.flowEnumMemberRaw(),c=o.name;if(c===``)continue;/^[a-z]/.test(c)&&this.raise($d.EnumInvalidMemberName,o,{memberName:c,suggestion:c[0].toUpperCase()+c.slice(1),enumName:e}),n.has(c)&&this.raise($d.EnumDuplicateMemberName,o,{memberName:c,enumName:e}),n.add(c);let l={enumName:e,explicitType:t,memberName:c};switch(a.id=o,s.type){case`boolean`:this.flowEnumCheckExplicitTypeMismatch(s.loc,l,`boolean`),a.init=s.value,r.booleanMembers.push(this.finishNode(a,`EnumBooleanMember`));break;case`number`:this.flowEnumCheckExplicitTypeMismatch(s.loc,l,`number`),a.init=s.value,r.numberMembers.push(this.finishNode(a,`EnumNumberMember`));break;case`string`:this.flowEnumCheckExplicitTypeMismatch(s.loc,l,`string`),a.init=s.value,r.stringMembers.push(this.finishNode(a,`EnumStringMember`));break;case`invalid`:throw this.flowEnumErrorInvalidMemberInitializer(s.loc,l);case`none`:switch(t){case`boolean`:this.flowEnumErrorBooleanMemberNotInitialized(s.loc,l);break;case`number`:this.flowEnumErrorNumberMemberNotInitialized(s.loc,l);break;default:r.defaultedMembers.push(this.finishNode(a,`EnumDefaultedMember`))}}this.match(4)||this.expect(8)}return{members:r,hasUnknownMembers:i}}flowEnumStringMembers(e,t,{enumName:n}){if(e.length===0)return t;if(t.length===0)return e;if(t.length>e.length){for(let t of e)this.flowEnumErrorStringMemberInconsistentlyInitialized(t,{enumName:n});return t}for(let e of t)this.flowEnumErrorStringMemberInconsistentlyInitialized(e,{enumName:n});return e}flowEnumParseExplicitType({enumName:e}){if(!this.eatContextual(98))return null;if(!sd(this.state.type))throw this.raise($d.EnumInvalidExplicitTypeUnknownSupplied,this.state.startLoc,{enumName:e});let{value:t}=this.state;return this.next(),t!==`boolean`&&t!==`number`&&t!==`string`&&t!==`symbol`&&this.raise($d.EnumInvalidExplicitType,this.state.startLoc,{enumName:e,invalidEnumType:t}),t}flowEnumBody(e,t){let n=t.name,r=t.start,i=this.flowEnumParseExplicitType({enumName:n});this.expect(2);let{members:a,hasUnknownMembers:o}=this.flowEnumMembers({enumName:n,explicitType:i});switch(e.hasUnknownMembers=o,i){case`boolean`:return e.explicitType=!0,e.members=a.booleanMembers,this.expect(4),this.finishNode(e,`EnumBooleanBody`);case`number`:return e.explicitType=!0,e.members=a.numberMembers,this.expect(4),this.finishNode(e,`EnumNumberBody`);case`string`:return e.explicitType=!0,e.members=this.flowEnumStringMembers(a.stringMembers,a.defaultedMembers,{enumName:n}),this.expect(4),this.finishNode(e,`EnumStringBody`);case`symbol`:return e.members=a.defaultedMembers,this.expect(4),this.finishNode(e,`EnumSymbolBody`);default:{let t=()=>(e.members=[],this.expect(4),this.finishNode(e,`EnumStringBody`));e.explicitType=!1;let i=a.booleanMembers.length,o=a.numberMembers.length,s=a.stringMembers.length,c=a.defaultedMembers.length;if(!i&&!o&&!s&&!c)return t();if(!i&&!o)return e.members=this.flowEnumStringMembers(a.stringMembers,a.defaultedMembers,{enumName:n}),this.expect(4),this.finishNode(e,`EnumStringBody`);if(!o&&!s&&i>=c){for(let e of a.defaultedMembers)this.flowEnumErrorBooleanMemberNotInitialized(e.start,{enumName:n,memberName:e.id.name});return e.members=a.booleanMembers,this.expect(4),this.finishNode(e,`EnumBooleanBody`)}if(!i&&!s&&o>=c){for(let e of a.defaultedMembers)this.flowEnumErrorNumberMemberNotInitialized(e.start,{enumName:n,memberName:e.id.name});return e.members=a.numberMembers,this.expect(4),this.finishNode(e,`EnumNumberBody`)}return this.raise($d.EnumInconsistentMemberValues,r,{enumName:n}),t()}}}flowParseEnumDeclaration(e){let t=this.parseIdentifier();return e.id=t,e.body=this.flowEnumBody(this.startNode(),t),this.finishNode(e,`EnumDeclaration`)}jsxParseOpeningElementAfterName(e){return this.shouldParseTypes()&&(this.match(43)||this.match(47))&&(e.typeArguments=this.flowParseTypeParameterInstantiationInExpression()),super.jsxParseOpeningElementAfterName(e)}isLookaheadToken_lt(){let e=this.nextTokenStart();if(this.input.charCodeAt(e)===60){let t=this.input.charCodeAt(e+1);return t!==60&&t!==61}return!1}reScan_lt_gt(){let{type:e}=this.state;e===43?(--this.state.pos,this.readToken_lt()):e===44&&(--this.state.pos,this.readToken_gt())}reScan_lt(){let{type:e}=this.state;return e===47?(this.state.pos-=2,this.finishOp(43,1),43):e}maybeUnwrapTypeCastExpression(e){return e.type===`TypeCastExpression`?e.expression:e}},sf={__proto__:null,quot:`"`,amp:`&`,apos:`'`,lt:`<`,gt:`>`,nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,fnof:`ƒ`,circ:`ˆ`,tilde:`˜`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,ensp:` `,emsp:` `,thinsp:` `,zwnj:`‌`,zwj:`‍`,lrm:`‎`,rlm:`‏`,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,bull:`•`,hellip:`…`,permil:`‰`,prime:`′`,Prime:`″`,lsaquo:`‹`,rsaquo:`›`,oline:`‾`,frasl:`⁄`,euro:`€`,image:`ℑ`,weierp:`℘`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`},cf=/\r\n|[\r\n\u2028\u2029]/g;function lf(e){switch(e){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function uf(e,t,n){for(let r=t;r<n;r++)if(lf(e.charCodeAt(r)))return!0;return!1}var df=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ff=/(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;function pf(e){switch(e){case 9:case 11:case 12:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:case 65279:return!0;default:return!1}}var mf=Lu`jsx`({AttributeIsEmpty:`JSX attributes must only be assigned a non-empty expression.`,MissingClosingTagElement:({openingTagName:e})=>`Expected corresponding JSX closing tag for <${e}>.`,MissingClosingTagFragment:`Expected corresponding JSX closing tag for <>.`,UnexpectedSequenceExpression:`Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?`,UnexpectedToken:({unexpected:e,HTMLEntity:t})=>`Unexpected token \`${e}\`. Did you mean \`${t}\` or \`{'${e}'}\`?`,UnsupportedJsxValue:`JSX value should be either an expression or a quoted JSX text.`,UnterminatedJsxContent:`Unterminated JSX contents.`,UnwrappedAdjacentJSXElements:`Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?`});function hf(e){return e?e.type===`JSXOpeningFragment`||e.type===`JSXClosingFragment`:!1}function gf(e){if(e.type===`JSXIdentifier`)return e.name;if(e.type===`JSXNamespacedName`)return e.namespace.name+`:`+e.name.name;if(e.type===`JSXMemberExpression`)return gf(e.object)+`.`+gf(e.property);throw Error(`Node had unexpected type: `+e.type)}var _f=e=>class extends e{jsxReadToken(){let e=``,t=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(mf.UnterminatedJsxContent,this.state.startLoc);let n=this.input.charCodeAt(this.state.pos);switch(n){case 60:case 123:if(this.state.pos===this.state.start){n===60&&this.state.canStartJSXElement?(++this.state.pos,this.finishToken(138)):super.getTokenFromCode(n);return}e+=this.input.slice(t,this.state.pos),this.finishToken(137,e);return;case 38:e+=this.input.slice(t,this.state.pos),e+=this.jsxReadEntity(),t=this.state.pos;break;case 62:case 125:this.raise(mf.UnexpectedToken,this.state.curPosition(),{unexpected:this.input[this.state.pos],HTMLEntity:n===125?`&rbrace;`:`&gt;`});default:lf(n)?(e+=this.input.slice(t,this.state.pos),e+=this.jsxReadNewLine(!0),t=this.state.pos):++this.state.pos}}}jsxReadNewLine(e){let t=this.input.charCodeAt(this.state.pos),n;return++this.state.pos,t===13&&this.input.charCodeAt(this.state.pos)===10?(++this.state.pos,n=e?`
19
21
  `:`\r
20
22
  `):n=String.fromCharCode(t),++this.state.curLine,this.state.lineStart=this.state.pos,n}jsxReadString(e){let t=``,n=++this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(G.UnterminatedString,this.state.startLoc);let r=this.input.charCodeAt(this.state.pos);if(r===e)break;r===38?(t+=this.input.slice(n,this.state.pos),t+=this.jsxReadEntity(),n=this.state.pos):lf(r)?(t+=this.input.slice(n,this.state.pos),t+=this.jsxReadNewLine(!1),n=this.state.pos):++this.state.pos}t+=this.input.slice(n,this.state.pos++),this.finishToken(130,t)}jsxReadEntity(){let e=++this.state.pos;if(this.codePointAtPos(this.state.pos)===35){++this.state.pos;let e=10;this.codePointAtPos(this.state.pos)===120&&(e=16,++this.state.pos);let t=this.readInt(e,void 0,!1,`bail`);if(t!==null&&t<=1114111&&this.codePointAtPos(this.state.pos)===59)return++this.state.pos,String.fromCodePoint(t)}else{let t=0,n=!1;for(;t++<10&&this.state.pos<this.length&&!(n=this.codePointAtPos(this.state.pos)===59);)++this.state.pos;if(n){let t=sf[this.input.slice(e,this.state.pos)];if(++this.state.pos,t)return t}}return this.state.pos=e,`&`}jsxReadWord(){let e,t=this.state.pos;do e=this.input.charCodeAt(++this.state.pos);while(Fd(e)||e===45);this.finishToken(136,this.input.slice(t,this.state.pos))}jsxParseIdentifier(){let e=this.startNode();return this.match(136)?e.name=this.state.value:gd(this.state.type)?e.name=Sd(this.state.type):this.unexpected(),this.next(),this.finishNode(e,`JSXIdentifier`)}jsxParseNamespacedName(){let e=this.state.startLoc,t=this.jsxParseIdentifier();if(!this.eat(10))return t;let n=this.startNodeAt(e);return n.namespace=t,n.name=this.jsxParseIdentifier(),this.finishNode(n,`JSXNamespacedName`)}jsxParseElementName(){let e=this.state.startLoc,t=this.jsxParseNamespacedName();if(t.type===`JSXNamespacedName`)return t;for(;this.eat(12);){let n=this.startNodeAt(e);n.object=t,n.property=this.jsxParseIdentifier(),t=this.finishNode(n,`JSXMemberExpression`)}return t}jsxParseAttributeValue(){let e;switch(this.state.type){case 2:return e=this.startNode(),this.setContext(Od.brace),this.next(),e=this.jsxParseExpressionContainer(e,Od.j_oTag),e.expression.type===`JSXEmptyExpression`&&this.raise(mf.AttributeIsEmpty,e),e;case 138:case 130:return this.parseExprAtom();default:throw this.raise(mf.UnsupportedJsxValue,this.state.startLoc)}}jsxParseEmptyExpression(){let e=this.startNodeAt(this.state.lastTokEndLoc);return this.finishNodeAt(e,`JSXEmptyExpression`,this.state.startLoc)}jsxParseSpreadChild(e){return this.next(),e.expression=this.parseExpression(),this.setContext(Od.j_expr),this.state.canStartJSXElement=!0,this.expect(4),this.finishNode(e,`JSXSpreadChild`)}jsxParseExpressionContainer(e,t){if(this.match(4))e.expression=this.jsxParseEmptyExpression();else{let t=this.parseExpression();t.type===`SequenceExpression`&&!t.extra?.parenthesized&&this.raise(mf.UnexpectedSequenceExpression,t.expressions[1]),e.expression=t}return this.setContext(t),this.state.canStartJSXElement=!0,this.expect(4),this.finishNode(e,`JSXExpressionContainer`)}jsxParseAttribute(){if(this.match(2)){let e=this.startNode();return this.setContext(Od.brace),this.next(),this.expect(17),e.argument=this.parseMaybeAssignAllowIn(),this.setContext(Od.j_oTag),this.state.canStartJSXElement=!0,this.expect(4),this.finishNode(e,`JSXSpreadAttribute`)}let e=this.startNode();return e.name=this.jsxParseNamespacedName(),e.value=this.eat(25)?this.jsxParseAttributeValue():null,this.finishNode(e,`JSXAttribute`)}jsxParseOpeningElementAt(e){if(this.eat(139)){let t=this.startNodeAt(e);return this.finishNode(t,`JSXOpeningFragment`)}let t=this.startNodeAt(e);return t.name=this.jsxParseElementName(),this.jsxParseOpeningElementAfterName(t)}jsxParseOpeningElementAfterName(e){let t=[];for(;!this.match(52)&&!this.match(139);)t.push(this.jsxParseAttribute());return e.attributes=t,e.selfClosing=this.eat(52),this.expect(139),this.finishNode(e,`JSXOpeningElement`)}jsxParseClosingElementAt(e){if(this.eat(139)){let t=this.startNodeAt(e);return this.finishNode(t,`JSXClosingFragment`)}let t=this.startNodeAt(e);return t.name=this.jsxParseElementName(),this.expect(139),this.finishNode(t,`JSXClosingElement`)}jsxParseElementAt(e){let t=this.startNodeAt(e),n=[],r=this.jsxParseOpeningElementAt(e),i=null;if(!r.selfClosing){contents:for(;;)switch(this.state.type){case 138:if(e=this.state.startLoc,this.next(),this.eat(52)){this.setLoc(e),i=this.jsxParseClosingElementAt(e);break contents}n.push(this.jsxParseElementAt(e));break;case 137:n.push(this.parseLiteral(this.state.value,`JSXText`));break;case 2:{let e=this.startNode();this.setContext(Od.brace),this.next(),this.match(17)?n.push(this.jsxParseSpreadChild(e)):n.push(this.jsxParseExpressionContainer(e,Od.j_expr));break}default:this.unexpected()}hf(r)&&!hf(i)&&i!==null?this.raise(mf.MissingClosingTagFragment,i):(!hf(r)&&hf(i)||!hf(r)&&!hf(i)&&gf(i.name)!==gf(r.name))&&this.raise(mf.MissingClosingTagElement,i,{openingTagName:gf(r.name)})}if(hf(r)?(t.openingFragment=r,t.closingFragment=i):(t.openingElement=r,t.closingElement=i),t.children=n,this.match(43))throw this.raise(mf.UnwrappedAdjacentJSXElements,this.state.startLoc);return hf(r)?this.finishNode(t,`JSXFragment`):this.finishNode(t,`JSXElement`)}jsxParseElement(){let e=this.state.startLoc;return this.next(),this.jsxParseElementAt(e)}setContext(e){let{context:t}=this.state;t[t.length-1]=e}parseExprAtom(e){return this.match(138)?this.jsxParseElement():this.match(43)&&this.input.charCodeAt(this.state.pos)!==33?(this.replaceToken(138),this.jsxParseElement()):super.parseExprAtom(e)}skipSpace(){this.curContext().preserveSpace||super.skipSpace()}getTokenFromCode(e){let t=this.curContext();if(t===Od.j_expr){this.jsxReadToken();return}if(t===Od.j_oTag||t===Od.j_cTag){if(Pd(e)){this.jsxReadWord();return}if(e===62){++this.state.pos,this.finishToken(139);return}if((e===34||e===39)&&t===Od.j_oTag){this.jsxReadString(e);return}}if(e===60&&this.state.canStartJSXElement&&this.input.charCodeAt(this.state.pos+1)!==33){++this.state.pos,this.finishToken(138);return}super.getTokenFromCode(e)}updateContext(e){let{context:t,type:n}=this.state;if(n===52&&e===138)t.splice(-2,2,Od.j_cTag),this.state.canStartJSXElement=!1;else if(n===138)t.push(Od.j_oTag);else if(n===139){let n=t[t.length-1];n===Od.j_oTag&&e===52||n===Od.j_cTag?(t.pop(),this.state.canStartJSXElement=t[t.length-1]===Od.j_expr):(this.setContext(Od.j_expr),this.state.canStartJSXElement=!0)}else this.state.canStartJSXElement=dd(n)}},vf=class extends Jd{tsNames=new Map},yf=class extends Yd{get inTSNamespace(){let e=this.scopeStack;return e.length>=2&&e[e.length-1].flags===0&&(e[e.length-2].flags&2048)>0}importsStack=[];createScope(e){return this.importsStack.push(new Set),new vf(e)}enter(e){e&3072&&this.importsStack.push(new Set),super.enter(e)}exit(){let e=super.exit();return e&3072&&this.importsStack.pop(),e}hasImport(e,t){let n=this.importsStack.length;if(this.importsStack[n-1].has(e))return!0;if(!t&&n>1){for(let t=0;t<n-1;t++)if(this.importsStack[t].has(e))return!0}return!1}declareName(e,t,n){if(t&4096){this.hasImport(e,!0)&&this.parser.raise(G.VarRedeclaration,n,{identifierName:e}),this.importsStack[this.importsStack.length-1].add(e);return}let r=this.currentScope(),i=r.tsNames.get(e)||0;if(t&1024){this.maybeExportDefined(r,e),r.tsNames.set(e,i|16);return}super.declareName(e,t,n),t&2&&(t&1||(this.checkRedeclarationInScope(r,e,t,n),this.maybeExportDefined(r,e)),i|=1),t&256&&(i|=2),t&512&&(i|=4),t&128&&(i|=8),i&&r.tsNames.set(e,i)}isRedeclaredInScope(e,t,n){let r=e.tsNames.get(t);return(r&2)>0?n&256?(n&512)>0!=(r&4)>0:!0:n&128&&(r&8)>0?e.names.get(t)&2?!!(n&1):!1:n&2&&(r&1)>0?!0:super.isRedeclaredInScope(e,t,n)}checkLocalExport(e){let{name:t}=e;if(this.hasImport(t))return;let n=this.scopeStack.length;for(let e=n-1;e>=0;e--){let n=this.scopeStack[e].tsNames.get(t);if((n&1)>0||(n&16)>0)return}super.checkLocalExport(e)}},bf=class{sawUnambiguousESM=!1;ambiguousScriptDifferentAst=!1;sourceToOffsetPos(e){return e+this.startIndex}offsetToSourcePos(e){return e-this.startIndex}hasPlugin(e){if(typeof e==`string`)return this.plugins.has(e);{let[t,n]=e;if(!this.hasPlugin(t))return!1;let r=this.plugins.get(t);for(let e of Object.keys(n))if(r?.[e]!==n[e])return!1;return!0}}getPluginOption(e,t){return this.plugins.get(e)?.[t]}};function xf(e,t){e.trailingComments===void 0?e.trailingComments=t:e.trailingComments.unshift(...t)}function Sf(e,t){e.leadingComments===void 0?e.leadingComments=t:e.leadingComments.unshift(...t)}function Cf(e,t){e.innerComments===void 0?e.innerComments=t:e.innerComments.unshift(...t)}function wf(e,t,n){let r=null,i=t.length;for(;r===null&&i>0;)r=t[--i];r===null||r.start>n.start?Cf(e,n.comments):xf(r,n.comments)}var Tf=class extends bf{addComment(e){this.filename&&(e.loc.filename=this.filename);let{commentsLen:t}=this.state;this.comments.length!==t&&(this.comments.length=t),this.comments.push(e),this.state.commentsLen++}processComment(e){let{commentStack:t}=this.state,n=t.length;if(n===0)return;let r=n-1,i=t[r];i.start===e.end&&(i.leadingNode=e,r--);let a=e.start;for(;r>=0;r--){let n=t[r],i=n.end;if(i>a)n.containingNode=e,this.finalizeComment(n),t.splice(r,1);else{i===a&&(n.trailingNode=e);break}}}finalizeComment(e){let{comments:t}=e;if(e.leadingNode!==null||e.trailingNode!==null)e.leadingNode!==null&&xf(e.leadingNode,t),e.trailingNode!==null&&Sf(e.trailingNode,t);else{let n=e.containingNode,r=e.start;if(this.input.charCodeAt(this.offsetToSourcePos(r)-1)===44)switch(n.type){case`ObjectExpression`:case`ObjectPattern`:wf(n,n.properties,e);break;case`CallExpression`:case`NewExpression`:case`OptionalCallExpression`:wf(n,n.arguments,e);break;case`ImportExpression`:wf(n,[n.source,n.options??null],e);break;case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:case`ObjectMethod`:case`ClassMethod`:case`ClassPrivateMethod`:case`TSTypeParameterDeclaration`:wf(n,n.params,e);break;case`ArrayExpression`:case`ArrayPattern`:wf(n,n.elements,e);break;case`ExportNamedDeclaration`:case`ImportDeclaration`:wf(n,n.specifiers,e);break;case`TSEnumBody`:wf(n,n.members,e);break;case`TSInterfaceBody`:wf(n,n.body,e);break;default:Cf(n,t)}else Cf(n,t)}}finalizeRemainingComments(){let{commentStack:e}=this.state;for(let t=e.length-1;t>=0;t--)this.finalizeComment(e[t]);this.state.commentStack=[]}resetPreviousNodeTrailingComments(e){let{commentStack:t}=this.state,{length:n}=t;if(n===0)return;let r=t[n-1];r.leadingNode===e&&(r.leadingNode=null)}takeSurroundingComments(e,t,n){let{commentStack:r}=this.state,i=r.length;if(i===0)return;let a=i-1;for(;a>=0;a--){let i=r[a],o=i.end;if(i.start===n)i.leadingNode=e;else if(o===t)i.trailingNode=e;else if(o<t)break}}},Ef=class e{flags=2048;get strict(){return(this.flags&1)>0}set strict(e){e?this.flags|=1:this.flags&=-2}startIndex;curLine;lineStart;startLoc;endLoc;init({strictMode:e,sourceType:t,startIndex:n,startLine:r,startColumn:i}){this.strict=e===!1?!1:e===!0||t===`module`,this.startIndex=n,this.curLine=r,this.lineStart=-i,this.startLoc=this.endLoc=new Su(r,i,n)}errors=[];noArrowAt=[];noArrowParamsConversionAt=[];get canStartArrow(){return(this.flags&2)>0}set canStartArrow(e){e?this.flags|=2:this.flags&=-3}get inType(){return(this.flags&4)>0}set inType(e){e?this.flags|=4:this.flags&=-5}get noAnonFunctionType(){return(this.flags&8)>0}set noAnonFunctionType(e){e?this.flags|=8:this.flags&=-9}get hasFlowComment(){return(this.flags&16)>0}set hasFlowComment(e){e?this.flags|=16:this.flags&=-17}get isAmbientContext(){return(this.flags&32)>0}set isAmbientContext(e){e?this.flags|=32:this.flags&=-33}get inAbstractClass(){return(this.flags&64)>0}set inAbstractClass(e){e?this.flags|=64:this.flags&=-65}get inDisallowConditionalTypesContext(){return(this.flags&128)>0}set inDisallowConditionalTypesContext(e){e?this.flags|=128:this.flags&=-129}get inConditionalConsequent(){return(this.flags&256)>0}set inConditionalConsequent(e){e?this.flags|=256:this.flags&=-257}get inHackPipelineBody(){return(this.flags&512)>0}set inHackPipelineBody(e){e?this.flags|=512:this.flags&=-513}get seenTopicReference(){return(this.flags&1024)>0}set seenTopicReference(e){e?this.flags|=1024:this.flags&=-1025}labels=[];commentsLen=0;commentStack=[];pos=0;type=135;value=null;start=0;end=0;lastTokEndLoc=null;lastTokStartLoc=null;context=[Od.brace];get canStartJSXElement(){return(this.flags&2048)>0}set canStartJSXElement(e){e?this.flags|=2048:this.flags&=-2049}get containsEsc(){return(this.flags&4096)>0}set containsEsc(e){e?this.flags|=4096:this.flags&=-4097}firstInvalidTemplateEscapePos=null;get hasTopLevelAwait(){return(this.flags&8192)>0}set hasTopLevelAwait(e){e?this.flags|=8192:this.flags&=-8193}strictErrors=new Map;tokensLength=0;curPosition(){return new Su(this.curLine,this.pos-this.lineStart,this.pos+this.startIndex)}clone(){let t=new e;return t.flags=this.flags,t.startIndex=this.startIndex,t.curLine=this.curLine,t.lineStart=this.lineStart,t.startLoc=this.startLoc,t.endLoc=this.endLoc,t.errors=this.errors.slice(),t.noArrowAt=this.noArrowAt.slice(),t.noArrowParamsConversionAt=this.noArrowParamsConversionAt.slice(),t.labels=this.labels.slice(),t.commentsLen=this.commentsLen,t.commentStack=this.commentStack.slice(),t.pos=this.pos,t.type=this.type,t.value=this.value,t.start=this.start,t.end=this.end,t.lastTokEndLoc=this.lastTokEndLoc,t.lastTokStartLoc=this.lastTokStartLoc,t.context=this.context.slice(),t.firstInvalidTemplateEscapePos=this.firstInvalidTemplateEscapePos,t.strictErrors=this.strictErrors,t.tokensLength=this.tokensLength,t}},Df=function(e){return e>=48&&e<=57},Of={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},kf={bin:e=>e===48||e===49,oct:e=>e>=48&&e<=55,dec:e=>e>=48&&e<=57,hex:e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102};function Af(e,t,n,r,i,a){let o=n,s=r,c=i,l=``,u=null,d=n,{length:f}=t;for(;;){if(n>=f){a.unterminated(o,s,c),l+=t.slice(d,n);break}let p=t.charCodeAt(n);if(jf(e,p,t,n)){l+=t.slice(d,n);break}if(p===92){l+=t.slice(d,n);let o=Mf(t,n,r,i,e===`template`,a);o.ch===null&&!u?u={pos:n,lineStart:r,curLine:i}:l+=o.ch,{pos:n,lineStart:r,curLine:i}=o,d=n}else p===8232||p===8233?(++n,++i,r=n):p===10||p===13?e===`template`?(l+=t.slice(d,n)+`
21
23
  `,++n,p===13&&t.charCodeAt(n)===10&&++n,++i,d=r=n):a.unterminated(o,s,c):++n}return{pos:n,str:l,firstInvalidLoc:u,lineStart:r,curLine:i}}function jf(e,t,n,r){return e===`template`?t===96||t===36&&n.charCodeAt(r+1)===123:t===(e===`double`?34:39)}function Mf(e,t,n,r,i,a){let o=!i;t++;let s=e=>({pos:t,ch:e,lineStart:n,curLine:r}),c=e.charCodeAt(t++);switch(c){case 110:return s(`
22
24
  `);case 114:return s(`\r`);case 120:{let i;return{code:i,pos:t}=Nf(e,t,n,r,2,!1,o,a),s(i===null?null:String.fromCharCode(i))}case 117:{let i;return{code:i,pos:t}=Ff(e,t,n,r,o,a),s(i===null?null:String.fromCodePoint(i))}case 116:return s(` `);case 98:return s(`\b`);case 118:return s(`\v`);case 102:return s(`\f`);case 13:e.charCodeAt(t)===10&&++t;case 10:n=t,++r;case 8232:case 8233:return s(``);case 56:case 57:if(i)return s(null);a.strictNumericEscape(t-1,n,r);default:if(c>=48&&c<=55){let o=t-1,c=/^[0-7]+/.exec(e.slice(o,t+2))[0],l=parseInt(c,8);l>255&&(c=c.slice(0,-1),l=parseInt(c,8)),t+=c.length-1;let u=e.charCodeAt(t);if(c!==`0`||u===56||u===57){if(i)return s(null);a.strictNumericEscape(o,n,r)}return s(String.fromCharCode(l))}return s(String.fromCharCode(c))}}function Nf(e,t,n,r,i,a,o,s){let c=t,l;return{n:l,pos:t}=Pf(e,t,n,r,16,i,a,!1,s,!o),l===null&&(o?s.invalidEscapeSequence(c,n,r):t=c-1),{code:l,pos:t}}function Pf(e,t,n,r,i,a,o,s,c,l){let u=t,d=i===16?Of.hex:Of.decBinOct,f=i===16?kf.hex:i===10?kf.dec:i===8?kf.oct:kf.bin,p=!1,m=0;for(let u=0,h=a??1/0;u<h;++u){let a=e.charCodeAt(t),u;if(a===95&&s!==`bail`){let i=e.charCodeAt(t-1),a=e.charCodeAt(t+1);if(!s){if(l)return{n:null,pos:t};c.numericSeparatorInEscapeSequence(t,n,r)}else if(Number.isNaN(a)||!f(a)||d.has(i)||d.has(a)){if(l)return{n:null,pos:t};c.unexpectedNumericSeparator(t,n,r)}++t;continue}if(u=a>=97?a-97+10:a>=65?a-65+10:Df(a)?a-48:1/0,u>=i){if(u<=9){if(l)return{n:null,pos:t};c.invalidDigit(t,n,r,i),u=0}else if(o)u=0,p=!0;else break}++t,m=m*i+u}return t===u||a!=null&&t-u!==a||p?{n:null,pos:t}:{n:m,pos:t}}function Ff(e,t,n,r,i,a){let o=e.charCodeAt(t),s;if(o===123){if(++t,{code:s,pos:t}=Nf(e,t,n,r,e.indexOf(`}`,t)-t,!0,i,a),++t,s!==null&&s>1114111){if(i)a.invalidCodePoint(t,n,r);else return{code:null,pos:t}}}else({code:s,pos:t}=Nf(e,t,n,r,4,!1,i,a));return{code:s,pos:t}}function If(e,t,n){return new Su(n,e-t,e)}var Lf=new Set([103,109,115,105,121,117,100,118]),Rf=class{constructor(e){let t=e.startIndex||0;this.type=e.type,this.value=e.value,this.start=t+e.start,this.end=t+e.end,this.loc=new Cu(e.startLoc,e.endLoc)}},zf,Bf=class extends Tf{isLookahead;tokens=[];constructor(e,t){super(),this.state=new Ef,this.state.init(e),this.input=t,this.length=t.length,this.comments=[],this.isLookahead=!1,(!zf||zf.length<(this.length+1)*2)&&(zf=new Uint32Array((this.length+1)*2)),this.locData=zf}setLoc(e){let t=this.offsetToSourcePos(e.index);this.locData[t*2]=e.line,this.locData[t*2+1]=e.column}getLoc(e){let t=this.offsetToSourcePos(e);return new Su(this.locData[t*2],this.locData[t*2+1],e)}pushToken(e){this.tokens.length=this.state.tokensLength,this.tokens.push(e),++this.state.tokensLength}next(){this.checkKeywordEscapes(),this.optionFlags&512&&this.pushToken(new Rf(this.state)),this.state.lastTokEndLoc=this.state.endLoc,this.state.lastTokStartLoc=this.state.startLoc,this.nextToken()}eat(e){return this.match(e)?(this.next(),!0):!1}match(e){return this.state.type===e}createLookaheadState(e){return{pos:e.pos,value:null,type:e.type,start:e.start,end:e.end,context:[this.curContext()],inType:e.inType,startLoc:e.startLoc,lastTokEndLoc:e.lastTokEndLoc,curLine:e.curLine,lineStart:e.lineStart,curPosition:e.curPosition}}lookahead(){let e=this.state;this.state=this.createLookaheadState(e),this.isLookahead=!0,this.nextToken(),this.isLookahead=!1;let t=this.state;return this.state=e,t}nextTokenStart(){return this.nextTokenStartSince(this.state.pos)}nextTokenStartSince(e){return df.lastIndex=e,df.test(this.input)?df.lastIndex:e}lookaheadCharCode(){return this.lookaheadCharCodeSince(this.state.pos)}lookaheadCharCodeSince(e){return this.input.charCodeAt(this.nextTokenStartSince(e))}nextTokenInLineStart(){return this.nextTokenInLineStartSince(this.state.pos)}nextTokenInLineStartSince(e){return ff.lastIndex=e,ff.test(this.input)?ff.lastIndex:e}lookaheadInLineCharCode(){return this.input.charCodeAt(this.nextTokenInLineStart())}codePointAtPos(e){let t=this.input.charCodeAt(e);if((t&64512)==55296&&++e<this.input.length){let n=this.input.charCodeAt(e);(n&64512)==56320&&(t=65536+((t&1023)<<10)+(n&1023))}return t}setStrict(e){this.state.strict=e,e&&(this.state.strictErrors.forEach(([e,t])=>this.raise(e,t)),this.state.strictErrors.clear())}curContext(){return this.state.context[this.state.context.length-1]}nextToken(){if(this.skipSpace(),this.state.start=this.state.pos,this.isLookahead||(this.state.startLoc=this.state.curPosition()),this.state.pos>=this.length){this.finishToken(135);return}this.getTokenFromCode(this.codePointAtPos(this.state.pos))}skipBlockComment(e){let t;this.isLookahead||(t=this.state.curPosition());let n=this.state.pos,r=this.input.indexOf(e,n+2);if(r===-1)throw this.raise(G.UnterminatedComment,this.state.curPosition());for(this.state.pos=r+e.length,cf.lastIndex=n+2;cf.test(this.input)&&cf.lastIndex<=r;)++this.state.curLine,this.state.lineStart=cf.lastIndex;if(this.isLookahead)return;let i={type:`CommentBlock`,value:this.input.slice(n+2,r),start:this.sourceToOffsetPos(n),end:this.sourceToOffsetPos(r+e.length),loc:new Cu(t,this.state.curPosition())};return this.optionFlags&512&&this.pushToken(i),i}skipLineComment(e){let t=this.state.pos,n;this.isLookahead||(n=this.state.curPosition());let r=this.input.charCodeAt(this.state.pos+=e);if(this.state.pos<this.length)for(;!lf(r)&&++this.state.pos<this.length;)r=this.input.charCodeAt(this.state.pos);if(this.isLookahead)return;let i=this.state.pos,a={type:`CommentLine`,value:this.input.slice(t+e,i),start:this.sourceToOffsetPos(t),end:this.sourceToOffsetPos(i),loc:new Cu(n,this.state.curPosition())};return this.optionFlags&512&&this.pushToken(a),a}skipSpace(){let e=this.state.pos,t=(this.optionFlags&8192)>0,n;loop:for(;this.state.pos<this.length;){let r=this.input.charCodeAt(this.state.pos);switch(r){case 32:case 160:case 9:++this.state.pos;break;case 13:this.input.charCodeAt(this.state.pos+1)===10&&++this.state.pos;case 10:case 8232:case 8233:++this.state.pos,++this.state.curLine,this.state.lineStart=this.state.pos;break;case 47:switch(this.input.charCodeAt(this.state.pos+1)){case 42:{let e=this.skipBlockComment(`*/`);e!==void 0&&(this.addComment(e),t&&(n??=[]).push(e));break}case 47:{let e=this.skipLineComment(2);e!==void 0&&(this.addComment(e),t&&(n??=[]).push(e));break}default:break loop}break;default:if(pf(r))++this.state.pos;else if(r===45&&!this.inModule&&this.optionFlags&16384){let r=this.state.pos;if(this.input.charCodeAt(r+1)===45&&this.input.charCodeAt(r+2)===62&&(e===0||this.state.lineStart>e)){let e=this.skipLineComment(3);e!==void 0&&(this.addComment(e),t&&(n??=[]).push(e))}else break loop}else if(r===60&&!this.inModule&&this.optionFlags&16384){let e=this.state.pos;if(this.input.charCodeAt(e+1)===33&&this.input.charCodeAt(e+2)===45&&this.input.charCodeAt(e+3)===45){let e=this.skipLineComment(4);e!==void 0&&(this.addComment(e),t&&(n??=[]).push(e))}else break loop}else break loop}}if(n?.length){let t=this.state.pos,r={start:this.sourceToOffsetPos(e),end:this.sourceToOffsetPos(t),comments:n,leadingNode:null,trailingNode:null,containingNode:null};this.state.commentStack.push(r)}}finishToken(e,t){this.state.end=this.state.pos,this.state.endLoc=this.state.curPosition();let n=this.state.type;this.state.type=e,this.state.value=t,this.isLookahead||this.updateContext(n)}replaceToken(e){this.state.type=e,this.updateContext()}readToken_numberSign(){if(this.state.pos===0&&this.readToken_interpreter())return;let e=this.state.pos+1,t=this.codePointAtPos(e);if(t>=48&&t<=57)throw this.raise(G.UnexpectedDigitAfterHash,this.state.curPosition());Pd(t)?(++this.state.pos,this.finishToken(134,this.readWord1(t))):t===92?(++this.state.pos,this.finishToken(134,this.readWord1())):this.finishOp(23,1)}readToken_dot(){let e=this.input.charCodeAt(this.state.pos+1);if(e>=48&&e<=57){this.readNumber(!0);return}e===46&&this.input.charCodeAt(this.state.pos+2)===46?(this.state.pos+=3,this.finishToken(17)):(++this.state.pos,this.finishToken(12))}readToken_slash(){this.input.charCodeAt(this.state.pos+1)===61?this.finishOp(27,2):this.finishOp(52,1)}readToken_interpreter(){if(this.state.pos!==0||this.length<2)return!1;let e=this.input.charCodeAt(this.state.pos+1);if(e!==33)return!1;let t=this.state.pos;for(this.state.pos+=1;!lf(e)&&++this.state.pos<this.length;)e=this.input.charCodeAt(this.state.pos);let n=this.input.slice(t+2,this.state.pos);return this.finishToken(24,n),!0}readToken_mult_modulo(e){let t=e===42?51:50,n=1,r=this.input.charCodeAt(this.state.pos+1);e===42&&r===42&&(n++,r=this.input.charCodeAt(this.state.pos+2),t=53),r===61&&!this.state.inType&&(n++,t=e===37?29:26),this.finishOp(t,n)}readToken_pipe_amp(e){let t=this.input.charCodeAt(this.state.pos+1);if(t===e){this.input.charCodeAt(this.state.pos+2)===61?this.finishOp(26,3):this.finishOp(e===124?37:38,2);return}if(e===124&&t===62){this.finishOp(35,2);return}if(t===61){this.finishOp(26,2);return}this.finishOp(e===124?39:41,1)}readToken_caret(){let e=this.input.charCodeAt(this.state.pos+1);e===61&&!this.state.inType?this.finishOp(28,2):e===94&&this.hasPlugin([`pipelineOperator`,{proposal:`hack`,topicToken:`^^`}])?(this.finishOp(33,2),this.input.codePointAt(this.state.pos)===94&&this.unexpected()):this.finishOp(40,1)}readToken_atSign(){this.input.charCodeAt(this.state.pos+1)===64&&this.hasPlugin([`pipelineOperator`,{proposal:`hack`,topicToken:`@@`}])?this.finishOp(34,2):this.finishOp(22,1)}readToken_plus_min(e){let t=this.input.charCodeAt(this.state.pos+1);if(t===e){this.finishOp(30,2);return}t===61?this.finishOp(26,2):this.finishOp(49,1)}readToken_lt(){let{pos:e}=this.state,t=this.input.charCodeAt(e+1);if(t===60){if(this.input.charCodeAt(e+2)===61){this.finishOp(26,3);return}this.finishOp(47,2);return}if(t===61){this.finishOp(45,2);return}this.finishOp(43,1)}readToken_gt(){let{pos:e}=this.state,t=this.input.charCodeAt(e+1);if(t===62){let t=this.input.charCodeAt(e+2)===62?3:2;if(this.input.charCodeAt(e+t)===61){this.finishOp(26,t+1);return}this.finishOp(48,t);return}if(t===61){this.finishOp(45,2);return}this.finishOp(44,1)}readToken_eq_excl(e){let t=this.input.charCodeAt(this.state.pos+1);if(t===61){this.finishOp(42,this.input.charCodeAt(this.state.pos+2)===61?3:2);return}if(e===61&&t===62){this.state.pos+=2,this.finishToken(15);return}this.finishOp(e===61?25:31,1)}readToken_question(){let e=this.input.charCodeAt(this.state.pos+1),t=this.input.charCodeAt(this.state.pos+2);e===63?t===61?this.finishOp(26,3):this.finishOp(36,2):e===46&&!(t>=48&&t<=57)?(this.state.pos+=2,this.finishToken(14)):(++this.state.pos,this.finishToken(13))}getTokenFromCode(e){switch(e){case 46:this.readToken_dot();return;case 40:++this.state.pos,this.finishToken(6);return;case 41:++this.state.pos,this.finishToken(7);return;case 59:++this.state.pos,this.finishToken(9);return;case 44:++this.state.pos,this.finishToken(8);return;case 91:++this.state.pos,this.finishToken(0);return;case 93:++this.state.pos,this.finishToken(1);return;case 123:++this.state.pos,this.finishToken(2);return;case 125:++this.state.pos,this.finishToken(4);return;case 58:this.hasPlugin(`functionBind`)&&this.input.charCodeAt(this.state.pos+1)===58?this.finishOp(11,2):(++this.state.pos,this.finishToken(10));return;case 63:this.readToken_question();return;case 96:this.readTemplateToken();return;case 48:{let e=this.input.charCodeAt(this.state.pos+1);if(e===120||e===88){this.readRadixNumber(16);return}if(e===111||e===79){this.readRadixNumber(8);return}if(e===98||e===66){this.readRadixNumber(2);return}}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:this.readNumber(!1);return;case 34:case 39:this.readString(e);return;case 47:this.readToken_slash();return;case 37:case 42:this.readToken_mult_modulo(e);return;case 124:case 38:this.readToken_pipe_amp(e);return;case 94:this.readToken_caret();return;case 43:case 45:this.readToken_plus_min(e);return;case 60:this.readToken_lt();return;case 62:this.readToken_gt();return;case 61:case 33:this.readToken_eq_excl(e);return;case 126:this.finishOp(32,1);return;case 64:this.readToken_atSign();return;case 35:this.readToken_numberSign();return;case 92:this.readWord();return;default:if(Pd(e)){this.readWord(e);return}}throw this.raise(G.InvalidOrUnexpectedToken,this.state.curPosition(),{unexpected:String.fromCodePoint(e)})}finishOp(e,t){let n=this.input.slice(this.state.pos,this.state.pos+t);this.state.pos+=t,this.finishToken(e,n)}readRegexp(){let e=this.state.startLoc,t=this.state.start+1,n,r,{pos:i}=this.state;for(;;++i){if(i>=this.length)throw this.raise(G.UnterminatedRegExp,wu(e,1));let t=this.input.charCodeAt(i);if(lf(t))throw this.raise(G.UnterminatedRegExp,wu(e,1));if(n)n=!1;else{if(t===91)r=!0;else if(t===93&&r)r=!1;else if(t===47&&!r)break;n=t===92}}let a=this.input.slice(t,i);++i;let o=``,s=()=>wu(e,i+2-t);for(;i<this.length;){let e=this.codePointAtPos(i),t=String.fromCharCode(e);if(Lf.has(e))e===118?o.includes(`u`)&&this.raise(G.IncompatibleRegExpUVFlags,s()):e===117&&o.includes(`v`)&&this.raise(G.IncompatibleRegExpUVFlags,s()),o.includes(t)&&this.raise(G.DuplicateRegExpFlags,s());else if(Fd(e)||e===92)this.raise(G.MalformedRegExpFlags,s());else break;++i,o+=t}this.state.pos=i,this.finishToken(133,{pattern:a,flags:o})}readInt(e,t,n=!1,r=!0){let{n:i,pos:a}=Pf(this.input,this.state.pos,this.state.lineStart,this.state.curLine,e,t,n,r,this.errorHandlers_readInt,!1);return this.state.pos=a,i}readRadixNumber(e){let t=this.state.pos,n=this.state.curPosition(),r=!1;this.state.pos+=2;let i=this.readInt(e);if(i??this.raise(G.InvalidDigit,wu(n,2),{radix:e}),this.input.charCodeAt(this.state.pos)===110&&(++this.state.pos,r=!0),Pd(this.codePointAtPos(this.state.pos)))throw this.raise(G.NumberIdentifier,this.state.curPosition());if(r){let e=this.input.slice(t,this.state.pos).replace(/[_n]/g,``);this.finishToken(132,e);return}this.finishToken(131,i)}readNumber(e){let t=this.state.pos,n=this.state.curPosition(),r=!1,i=!1,a=!1;!e&&this.readInt(10)===null&&this.raise(G.InvalidNumber,this.state.curPosition());let o=this.state.pos-t>=2&&this.input.charCodeAt(t)===48;if(o){let e=this.input.slice(t,this.state.pos);if(this.recordStrictModeErrors(G.StrictOctalLiteral,n),!this.state.strict){let t=e.indexOf(`_`);t>0&&this.raise(G.ZeroDigitNumericSeparator,wu(n,t))}a=o&&!/[89]/.test(e)}let s=this.input.charCodeAt(this.state.pos);s===46&&!a&&(++this.state.pos,this.readInt(10),r=!0,s=this.input.charCodeAt(this.state.pos)),(s===69||s===101)&&!a&&(s=this.input.charCodeAt(++this.state.pos),(s===43||s===45)&&++this.state.pos,this.readInt(10)===null&&this.raise(G.InvalidOrMissingExponent,n),r=!0,s=this.input.charCodeAt(this.state.pos));let c=this.input.slice(t,this.state.pos).replaceAll(`_`,``);if(s===110&&((r||o)&&this.raise(G.InvalidBigIntLiteral,n),++this.state.pos,i=!0),Pd(this.codePointAtPos(this.state.pos)))throw this.raise(G.NumberIdentifier,this.state.curPosition());if(i){this.finishToken(132,c);return}let l=a?parseInt(c,8):parseFloat(c);this.finishToken(131,l)}readCodePoint(e){let{code:t,pos:n}=Ff(this.input,this.state.pos,this.state.lineStart,this.state.curLine,e,this.errorHandlers_readCodePoint);return this.state.pos=n,t}readString(e){let{str:t,pos:n,curLine:r,lineStart:i}=Af(e===34?`double`:`single`,this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_string);this.state.pos=n+1,this.state.lineStart=i,this.state.curLine=r,this.finishToken(130,t)}readTemplateContinuation(){this.match(4)||this.unexpected(null,4),this.state.pos--,this.readTemplateToken()}readTemplateToken(){let e=this.input[this.state.pos],{str:t,firstInvalidLoc:n,pos:r,curLine:i,lineStart:a}=Af(`template`,this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_template);this.state.pos=r+1,this.state.lineStart=a,this.state.curLine=i,n&&(this.state.firstInvalidTemplateEscapePos=new Su(n.curLine,n.pos-n.lineStart,this.sourceToOffsetPos(n.pos))),this.input.codePointAt(r)===96?this.finishToken(20,n?null:e+t+"`"):(this.state.pos++,this.finishToken(21,n?null:e+t+"${"))}recordStrictModeErrors(e,t){let n=t.index;this.state.strict&&!this.state.strictErrors.has(n)?this.raise(e,t):this.state.strictErrors.set(n,[e,t])}readWord1(e){this.state.containsEsc=!1;let t=``,n=this.state.pos,r=this.state.pos;for(e!==void 0&&(this.state.pos+=e<=65535?1:2);this.state.pos<this.length;){let e=this.codePointAtPos(this.state.pos);if(Fd(e))this.state.pos+=e<=65535?1:2;else if(e===92){this.state.containsEsc=!0,t+=this.input.slice(r,this.state.pos);let e=this.state.curPosition(),i=this.state.pos===n?Pd:Fd;if(this.input.charCodeAt(++this.state.pos)!==117){this.raise(G.MissingUnicodeEscape,this.state.curPosition()),r=this.state.pos-1;continue}++this.state.pos;let a=this.readCodePoint(!0);a!==null&&(i(a)||this.raise(G.EscapedCharNotAnIdentifier,e),t+=String.fromCodePoint(a)),r=this.state.pos}else break}return t+this.input.slice(r,this.state.pos)}readWord(e){let t=this.readWord1(e),n=Ju.get(t);n===void 0?this.finishToken(128,t):this.finishToken(n,Sd(n))}checkKeywordEscapes(){let{type:e}=this.state;gd(e)&&this.state.containsEsc&&this.raise(G.InvalidEscapedReservedWord,this.state.startLoc,{reservedWord:Sd(e)})}raise(e,t,n={}){let r=t instanceof Su?t:typeof t==`number`?this.getLoc(t):this.optionFlags&256?t.loc.start:this.getLoc(t.start),i=e(r,t instanceof Su?r.index:typeof t==`number`?t:t.start,n);if(!(this.optionFlags&4096))throw i;return this.isLookahead||this.state.errors.push(i),i}raiseOverwrite(e,t,n={}){let r=t instanceof Su?t:this.optionFlags&256?t.loc.start:this.getLoc(t.start),i=t instanceof Su?r.index:t.start,a=this.state.errors;for(let t=a.length-1;t>=0;t--){let o=a[t];if(o.pos===i)return a[t]=e(r,i,n);if(o.pos<i)break}return this.raise(e,r,n)}updateContext(e){}unexpected(e,t){throw this.raise(G.UnexpectedToken,e??this.state.startLoc,{expected:t?Sd(t):null})}expectPlugin(e,t){if(this.hasPlugin(e))return!0;throw this.raise(G.MissingPlugin,t??this.state.startLoc,{missingPlugin:[e]})}expectOnePlugin(e){if(!e.some(e=>this.hasPlugin(e)))throw this.raise(G.MissingOneOfPlugins,this.state.startLoc,{missingPlugin:e})}errorBuilder(e){return(t,n,r)=>{this.raise(e,If(t,n,r))}}errorHandlers_readInt={invalidDigit:(e,t,n,r)=>{this.raise(G.InvalidDigit,If(e,t,n),{radix:r})},numericSeparatorInEscapeSequence:this.errorBuilder(G.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(G.UnexpectedNumericSeparator)};errorHandlers_readCodePoint={...this.errorHandlers_readInt,invalidEscapeSequence:this.errorBuilder(G.InvalidEscapeSequence),invalidCodePoint:this.errorBuilder(G.InvalidCodePoint)};errorHandlers_readStringContents_string={...this.errorHandlers_readCodePoint,strictNumericEscape:(e,t,n)=>{this.recordStrictModeErrors(G.StrictNumericEscape,If(e,t,n))},unterminated:(e,t,n)=>{throw this.raise(G.UnterminatedString,If(e-1,t,n))}};errorHandlers_readStringContents_template={...this.errorHandlers_readCodePoint,strictNumericEscape:this.errorBuilder(G.StrictNumericEscape),unterminated:(e,t,n)=>{throw this.raise(G.UnterminatedTemplate,If(e,t,n))}}},Vf=class{privateNames=new Set;loneAccessors=new Map;undefinedPrivateNames=new Map},Hf=class{parser;stack=[];constructor(e){this.parser=e}current(){return this.stack[this.stack.length-1]}enter(){this.stack.push(new Vf)}exit(){let e=this.stack.pop(),t=this.current();for(let[n,r]of Array.from(e.undefinedPrivateNames))t?t.undefinedPrivateNames.has(n)||t.undefinedPrivateNames.set(n,r):this.parser.raise(G.InvalidPrivateFieldResolution,r,{identifierName:n})}declarePrivateName(e,t,n){let{privateNames:r,loneAccessors:i,undefinedPrivateNames:a}=this.current(),o=r.has(e);if(t&3){let n=o&&i.get(e);if(n){let r=n&4,a=t&4;o=(n&3)==(t&3)||r!==a,o||i.delete(e)}else o||i.set(e,t)}o&&this.parser.raise(G.PrivateNameRedeclaration,n,{identifierName:e}),r.add(e),a.delete(e)}usePrivateName(e,t){let n;for(n of this.stack)if(n.privateNames.has(e))return;n?n.undefinedPrivateNames.set(e,t):this.parser.raise(G.InvalidPrivateFieldResolution,t,{identifierName:e})}},Uf=class{constructor(e=0){this.type=e}canBeArrowParameterDeclaration(){return this.type===2||this.type===1}isCertainlyParameterDeclaration(){return this.type===3}},Wf=class extends Uf{declarationErrors=new Map;constructor(e){super(e)}recordDeclarationError(e,t){this.declarationErrors.set(t,e)}clearDeclarationError(e){this.declarationErrors.delete(e)}iterateErrors(e){this.declarationErrors.forEach(e)}},Gf=class{parser;stack=[new Uf];constructor(e){this.parser=e}enter(e){this.stack.push(e)}exit(){this.stack.pop()}recordParameterInitializerError(e,t){let{stack:n}=this,r=n.length-1,i=n[r];for(;!i.isCertainlyParameterDeclaration();){if(i.canBeArrowParameterDeclaration())i.recordDeclarationError(e,t);else return;i=n[--r]}this.parser.raise(e,t)}recordArrowParameterBindingError(e,t){let{stack:n}=this,r=n[n.length-1],i=t.start;if(r.isCertainlyParameterDeclaration())this.parser.raise(e,i);else if(r.canBeArrowParameterDeclaration())r.recordDeclarationError(e,i);else return}recordAsyncArrowParametersError(e){let{stack:t}=this,n=t.length-1,r=t[n];for(;r.canBeArrowParameterDeclaration();)r.type===2&&r.recordDeclarationError(G.AwaitBindingIdentifier,e),r=t[--n]}validateAsPattern(){let{stack:e}=this,t=e[e.length-1];t.canBeArrowParameterDeclaration()&&t.iterateErrors((t,n)=>{this.parser.raise(t,n);let r=e.length-2,i=e[r];for(;i.canBeArrowParameterDeclaration();)i.clearDeclarationError(n),i=e[--r]})}};function Kf(){return new Uf(3)}function qf(){return new Wf(1)}function Jf(){return new Wf(2)}function Yf(){return new Uf}var Xf=class{stacks=[];enter(e){this.stacks.push(e)}exit(){this.stacks.pop()}currentFlags(){return this.stacks[this.stacks.length-1]}get hasAwait(){return(this.currentFlags()&2)>0}get hasYield(){return(this.currentFlags()&1)>0}get hasReturn(){return(this.currentFlags()&4)>0}get hasIn(){return(this.currentFlags()&8)>0}get inFSharpPipelineDirectBody(){return!(this.currentFlags()&16)}};function Zf(e,t){return(e?2:0)|!!t}var Qf=class extends Bf{addExtra(e,t,n,r=!0){if(!e)return;let{extra:i}=e;i??(i={},e.extra=i),r?i[t]=n:Object.defineProperty(i,t,{enumerable:r,value:n})}isContextual(e){return this.state.type===e&&!this.state.containsEsc}isUnparsedContextual(e,t){if(this.input.startsWith(t,e)){let n=this.input.charCodeAt(e+t.length);return!(Fd(n)||(n&64512)==55296)}return!1}isLookaheadContextual(e){let t=this.nextTokenStart();return this.isUnparsedContextual(t,e)}eatContextual(e){return this.isContextual(e)?(this.next(),!0):!1}expectContextual(e,t){if(!this.eatContextual(e)){if(t!=null)throw this.raise(t,this.state.startLoc);this.unexpected(null,e)}}canInsertSemicolon(){return this.match(135)||this.match(4)||this.hasPrecedingLineBreak()}hasPrecedingLineBreak(){return uf(this.input,this.offsetToSourcePos(this.state.lastTokEndLoc.index),this.state.start)}hasFollowingLineBreak(){return uf(this.input,this.state.end,this.nextTokenStart())}isLineTerminator(){return this.eat(9)||this.canInsertSemicolon()}semicolon(e=!0){(e?this.isLineTerminator():this.eat(9))||this.raise(G.MissingSemicolon,this.state.lastTokEndLoc)}expect(e,t){this.eat(e)||this.unexpected(t,e)}tryParse(e,t=this.state.clone()){let n={node:null};try{let r=e((e=null)=>{throw n.node=e,n});if(this.state.errors.length>t.errors.length){let e=this.state;return this.state=t,this.state.tokensLength=e.tokensLength,{node:r,error:e.errors[t.errors.length],thrown:!1,aborted:!1,failState:e}}return{node:r,error:null,thrown:!1,aborted:!1,failState:null}}catch(e){let r=this.state;if(this.state=t,e instanceof SyntaxError)return{node:null,error:e,thrown:!0,aborted:!1,failState:r};if(e===n)return{node:n.node,error:null,thrown:!1,aborted:!0,failState:r};throw e}}checkExpressionErrors(e,t){if(!e)return!1;let{shorthandAssignLoc:n,doubleProtoLoc:r,privateKeyLoc:i,optionalParametersLoc:a,voidPatternLoc:o}=e,s=!!n||!!r||!!a||!!i||!!o;if(!t)return s;n!=null&&this.raise(G.InvalidCoverInitializedName,n),r!=null&&this.raise(G.DuplicateProto,r),i!=null&&this.raise(G.UnexpectedPrivateField,i),a!=null&&this.unexpected(a),o!=null&&this.raise(G.InvalidCoverDiscardElement,o)}isLiteralPropertyName(){return ud(this.state.type)}isPrivateName(e){return e.type===`PrivateName`}getPrivateNameSV(e){return e.id.name}hasPropertyAsPrivateName(e){return(e.type===`MemberExpression`||e.type===`OptionalMemberExpression`)&&this.isPrivateName(e.property)}isObjectProperty(e){return e.type===`ObjectProperty`}isObjectMethod(e){return e.type===`ObjectMethod`}initializeScopes(e=this.options.sourceType===`module`){let t=this.state.labels;this.state.labels=[];let n=this.exportedIdentifiers;this.exportedIdentifiers=new Set;let r=this.inModule;this.inModule=e;let i=this.scope,a=this.getScopeHandler();this.scope=new a(this,e);let o=this.prodParam;this.prodParam=new Xf;let s=this.classScope;this.classScope=new Hf(this);let c=this.expressionScope;return this.expressionScope=new Gf(this),()=>{this.state.labels=t,this.exportedIdentifiers=n,this.inModule=r,this.scope=i,this.prodParam=o,this.classScope=s,this.expressionScope=c}}enterInitialScopes(){let e=0;(this.inModule||this.optionFlags&1)&&(e|=2),this.optionFlags&32&&(e|=1);let t=!this.inModule&&this.options.sourceType===`commonjs`;(t||this.optionFlags&2)&&(e|=4),this.prodParam.enter(e);let n=t?514:1;this.optionFlags&4&&(n|=512),this.optionFlags&16&&(n|=48),this.scope.enter(n)}checkDestructuringPrivate(e){let{privateKeyLoc:t}=e;t!==null&&this.expectPlugin(`destructuringPrivate`,t)}},$f=class{shorthandAssignLoc=null;doubleProtoLoc=null;privateKeyLoc=null;optionalParametersLoc=null;voidPatternLoc=null},ep=class{constructor(e,t,n,r){this.start=n,this.end=0,r!==void 0&&(this.loc=new Cu(r)),e&128&&(this.range=[n,0]),r!==void 0&&t&&(this.loc.filename=t)}type=``},tp=ep.prototype,np=class extends Qf{createPosition(e){return e}startNode(){let{startLoc:e}=this.state;return this.setLoc(e),this.startNodeAt(e)}startNodeAt(e){let{optionFlags:t,filename:n}=this;return t&256?new ep(t,n,e.index,this.createPosition(e)):new ep(t,n,e.index)}startNodeAtNode(e){let{optionFlags:t,filename:n}=this;return t&256?new ep(t,n,e.start,e.loc.start):new ep(t,n,e.start)}finishNode(e,t){return this.finishNodeAt(e,t,this.state.lastTokEndLoc)}finishNodeAt(e,t,n){e.type=t,e.end=n.index;let{optionFlags:r}=this;return r&256&&(e.loc.end=this.createPosition(n)),r&128&&(e.range[1]=n.index),r&8192&&this.processComment(e),e}finishNodeAtNode(e,t,n){e.type=t,e.end=n.end;let{optionFlags:r}=this;return r&256&&(e.loc.end=n.loc.end),r&128&&(e.range[1]=e.end),r&8192&&this.processComment(e),e}resetStartLocation(e,t){e.start=t.index;let{optionFlags:n}=this;n&256&&(e.loc.start=this.createPosition(t)),n&128&&(e.range[0]=t.index)}resetEndLocation(e,t=this.state.lastTokEndLoc){e.end=t.index;let{optionFlags:n}=this;n&256&&(e.loc.end=this.createPosition(t)),n&128&&(e.range[1]=t.index)}resetStartLocationFromNode(e,t){e.start=t.start;let{optionFlags:n}=this;n&256&&(e.loc.start=t.loc.start),n&128&&(e.range[0]=t.start)}resetEndLocationFromNode(e,t){e.end=t.end;let{optionFlags:n}=this;n&256&&(e.loc.end=t.loc.end),n&128&&(e.range[1]=t.end)}castNodeTo(e,t){return e.type=t,e}cloneIdentifier(e){let{type:t,start:n,end:r,loc:i,range:a,name:o}=e,s=Object.create(tp);return s.type=t,s.start=n,s.end=r,s.loc=i,s.range=a,s.name=o,e.extra&&(s.extra=e.extra),s}cloneStringLiteral(e){let{type:t,start:n,end:r,loc:i,range:a,extra:o}=e,s=Object.create(tp);return s.type=t,s.start=n,s.end=r,s.loc=i,s.range=a,s.extra=o,s.value=e.value,s}},rp=e=>e.type===`ParenthesizedExpression`?rp(e.expression):e,ip=class extends np{toAssignable(e,t=!1){let n;switch((e.type===`ParenthesizedExpression`||e.extra?.parenthesized)&&(n=rp(e),t?n.type===`Identifier`?this.expressionScope.recordArrowParameterBindingError(G.InvalidParenthesizedAssignment,e):n.type!==`CallExpression`&&n.type!==`MemberExpression`&&!this.isOptionalMemberExpression(n)&&this.raise(G.InvalidParenthesizedAssignment,e):this.raise(G.InvalidParenthesizedAssignment,e)),e.type){case`Identifier`:case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:case`VoidPattern`:break;case`ObjectExpression`:this.castNodeTo(e,`ObjectPattern`);for(let n=0,r=e.properties.length,i=r-1;n<r;n++){let r=e.properties[n],a=n===i;this.toAssignableObjectExpressionProp(r,a,t),a&&r.type===`RestElement`&&e.extra?.trailingCommaLoc&&this.raise(G.RestTrailingComma,e.extra.trailingCommaLoc)}break;case`ObjectProperty`:{let{key:n,value:r}=e;this.isPrivateName(n)&&this.classScope.usePrivateName(this.getPrivateNameSV(n),n.start),this.toAssignable(r,t);break}case`SpreadElement`:throw Error(`Internal @babel/parser error (this is a bug, please report it). SpreadElement should be converted by .toAssignable's caller.`);case`ArrayExpression`:this.castNodeTo(e,`ArrayPattern`),this.toAssignableList(e.elements,e.extra?.trailingCommaLoc,t);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(G.MissingEqInAssignment,this.optionFlags&256?e.left.loc.end:e.left),this.castNodeTo(e,`AssignmentPattern`),delete e.operator,e.left.type===`VoidPattern`&&this.raise(G.VoidPatternInitializer,e.left),this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(n,t)}}toAssignableObjectExpressionProp(e,t,n){if(e.type===`ObjectMethod`)this.raise(e.kind===`get`||e.kind===`set`?G.PatternHasAccessor:G.PatternHasMethod,e.key);else if(e.type===`SpreadElement`){this.castNodeTo(e,`RestElement`);let r=e.argument;this.checkToRestConversion(r,!1),this.toAssignable(r,n),t||this.raise(G.RestTrailingComma,e)}else this.toAssignable(e,n)}toAssignableList(e,t,n){let r=e.length-1;for(let i=0;i<=r;i++){let a=e[i];a&&(this.toAssignableListItem(e,i,n),a.type===`RestElement`&&(i<r?this.raise(G.RestTrailingComma,a):t&&this.raise(G.RestTrailingComma,t)))}}toAssignableListItem(e,t,n){let r=e[t];if(r.type===`SpreadElement`){this.castNodeTo(r,`RestElement`);let e=r.argument;this.checkToRestConversion(e,!0),this.toAssignable(e,n)}else this.toAssignable(r,n)}isAssignable(e,t){switch(e.type){case`Identifier`:case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:case`VoidPattern`:return!0;case`ObjectExpression`:{let t=e.properties.length-1;return e.properties.every((e,n)=>e.type!==`ObjectMethod`&&(n===t||e.type!==`SpreadElement`)&&this.isAssignable(e))}case`ObjectProperty`:return this.isAssignable(e.value);case`SpreadElement`:return this.isAssignable(e.argument);case`ArrayExpression`:return e.elements.every(e=>e===null||this.isAssignable(e));case`AssignmentExpression`:return e.operator===`=`;case`ParenthesizedExpression`:return this.isAssignable(e.expression);case`MemberExpression`:case`OptionalMemberExpression`:return!t;default:return!1}}toReferencedList(e,t){return e}parseSpread(e){let t=this.startNode();return this.next(),t.argument=this.parseMaybeAssignAllowIn(e),this.finishNode(t,`SpreadElement`)}parseRestBinding(){let e=this.startNode();this.next();let t=this.parseBindingAtom();return t.type===`VoidPattern`&&this.raise(G.UnexpectedVoidPattern,t),e.argument=t,this.finishNode(e,`RestElement`)}parseBindingAtom(){switch(this.state.type){case 0:{let e=this.startNode();return this.next(),e.elements=this.parseBindingList(1,93,1),this.finishNode(e,`ArrayPattern`)}case 2:return this.parseObjectLike(4,!0);case 84:return this.parseVoidPattern(null)}return this.parseIdentifier()}parseBindingList(e,t,n){let r=n&1,i=[],a=!0;for(;!this.eat(e);)if(a?a=!1:this.expect(8),r&&this.match(8))i.push(null);else if(this.eat(e))break;else if(this.match(17)){let r=this.parseRestBinding();if(n&2&&(r=this.parseFunctionParamType(r)),i.push(r),!this.checkCommaAfterRest(t)){this.expect(e);break}}else{let e=[];if(n&2)for(this.match(22)&&this.hasPlugin(`decorators`)&&this.raise(G.UnsupportedParameterDecorator,this.state.startLoc);this.match(22);)e.push(this.parseDecorator());i.push(this.parseBindingElement(n,e))}return i}parseBindingRestProperty(e){return this.next(),this.hasPlugin(`discardBinding`)&&this.match(84)?(e.argument=this.parseVoidPattern(null),this.raise(G.UnexpectedVoidPattern,e.argument)):e.argument=this.parseIdentifier(),this.checkCommaAfterRest(125),this.finishNode(e,`RestElement`)}parseBindingProperty(){let{type:e,startLoc:t}=this.state;if(e===17)return this.parseBindingRestProperty(this.startNode());let n=this.startNode();return e===134?(this.expectPlugin(`destructuringPrivate`,t),this.classScope.usePrivateName(this.state.value,t),n.key=this.parsePrivateName()):this.parsePropertyName(n),n.method=!1,this.parseObjPropValue(n,t,!1,!1,!0,!1)}parseBindingElement(e,t){let{startLoc:n}=this.state,r=this.parseMaybeDefault();return e&2&&this.parseFunctionParamType(r),t.length&&(r.decorators=t,this.resetStartLocationFromNode(r,t[0])),this.parseMaybeDefault(n,r)}parseFunctionParamType(e){return e}parseMaybeDefault(e,t){if(e??=this.state.startLoc,t??=this.parseBindingAtom(),!this.eat(25))return t;let n=this.startNodeAt(e);return t.type===`VoidPattern`&&this.raise(G.VoidPatternInitializer,t),n.left=t,n.right=this.parseMaybeAssignAllowIn(),this.finishNode(n,`AssignmentPattern`)}isValidLVal(e,t,n,r){switch(e){case`AssignmentPattern`:return`left`;case`RestElement`:return`argument`;case`ObjectProperty`:return`value`;case`ParenthesizedExpression`:return`expression`;case`ArrayPattern`:return`elements`;case`ObjectPattern`:return`properties`;case`VoidPattern`:return!0;case`CallExpression`:if(!t&&!this.state.strict&&this.optionFlags&16384)return!0}return!1}isOptionalMemberExpression(e){return e.type===`OptionalMemberExpression`}checkLVal(e,t,n=64,r=!1,i=!1,a=!1,o=!1){let s=e.type;if(this.isObjectMethod(e))return;let c=this.isOptionalMemberExpression(e);if(c||s===`MemberExpression`){c&&(this.expectPlugin(`optionalChainingAssign`,e.start),t.type!==`AssignmentExpression`&&this.raise(G.InvalidLhsOptionalChaining,e,{ancestor:t})),n!==64&&this.raise(G.InvalidPropertyBindingPattern,e);return}if(s===`Identifier`){this.checkIdentifier(e,n,i);let{name:t}=e;r&&(r.has(t)?this.raise(G.ParamDupe,e):r.add(t));return}s===`VoidPattern`&&t.type===`CatchClause`&&this.raise(G.VoidPatternCatchClauseParam,e);let l=rp(e);o||=l.type===`CallExpression`&&(l.callee.type===`Import`||l.callee.type===`Super`);let u=this.isValidLVal(s,o,!(a||e.extra?.parenthesized)&&t.type===`AssignmentExpression`,n);if(u===!0)return;if(u===!1){let r=n===64?G.InvalidLhs:G.InvalidLhsBinding;this.raise(r,e,{ancestor:t});return}let d,f;typeof u==`string`?(d=u,f=s===`ParenthesizedExpression`):[d,f]=u;let p=s===`ArrayPattern`||s===`ObjectPattern`?{type:s}:t,m=e[d];if(Array.isArray(m))for(let e of m)e&&this.checkLVal(e,p,n,r,i,f,!0);else m&&this.checkLVal(m,p,n,r,i,f,o)}checkIdentifier(e,t,n=!1){this.state.strict&&(n?Ud(e.name,this.inModule):Hd(e.name))&&(t===64?this.raise(G.StrictEvalArguments,e,{referenceName:e.name}):this.raise(G.StrictEvalArgumentsBinding,e,{bindingName:e.name})),t&8192&&e.name===`let`&&this.raise(G.LetInLexicalBinding,e),t&64||this.declareNameFromIdentifier(e,t)}declareNameFromIdentifier(e,t){this.scope.declareName(e.name,t,e.start)}checkToRestConversion(e,t){switch(e.type){case`ParenthesizedExpression`:this.checkToRestConversion(e.expression,t);break;case`Identifier`:case`MemberExpression`:break;case`ArrayExpression`:case`ObjectExpression`:if(t)break;default:this.raise(G.InvalidRestAssignmentPattern,e)}}checkCommaAfterRest(e){return this.match(8)?(this.raise(this.lookaheadCharCode()===e?G.RestTrailingComma:G.ElementAfterRest,this.state.startLoc),!0):!1}},ap=class extends ip{checkProto(e,t,n){if(e.type===`SpreadElement`||this.isObjectMethod(e)||e.computed||e.shorthand)return t;let r=e.key;return(r.type===`Identifier`?r.name:r.value)===`__proto__`?(t&&(n?n.doubleProtoLoc===null&&(n.doubleProtoLoc=this.getLoc(r.start)):this.raise(G.DuplicateProto,r)),!0):t}shouldExitDescending(e){return e.type===`ArrowFunctionExpression`&&!e.extra?.parenthesized}getExpression(){if(this.enterInitialScopes(),this.nextToken(),this.match(135))throw this.raise(G.ParseExpressionEmptyInput,this.state.startLoc);let e=this.parseExpression();if(!this.match(135))throw this.raise(G.ParseExpressionExpectsEOF,this.state.startLoc,{unexpected:this.input.codePointAt(this.state.start)});return this.finalizeRemainingComments(),e.comments=this.comments,e.errors=this.state.errors,this.optionFlags&512&&(e.tokens=up(this.tokens)),e}parseExpression(e,t){return e?this.disallowInAnd(()=>this.parseExpressionBase(t)):this.allowInAnd(()=>this.parseExpressionBase(t))}parseExpressionBase(e){let t=this.state.startLoc,n=this.parseMaybeAssign(e);if(this.match(8)){let r=this.startNodeAt(t);for(r.expressions=[n];this.eat(8);)r.expressions.push(this.parseMaybeAssign(e));return this.toReferencedList(r.expressions),this.finishNode(r,`SequenceExpression`)}return n}parseMaybeAssignDisallowIn(e){return this.disallowInAnd(()=>this.parseMaybeAssign(e))}parseMaybeAssignAllowIn(e,t){return this.allowInAnd(()=>this.parseMaybeAssign(e,t))}setOptionalParametersError(e){e.optionalParametersLoc=this.state.startLoc}parseMaybeAssign(e,t){let n=this.state.startLoc,r=this.isContextual(104);if(r&&this.prodParam.hasYield){this.next();let e=this.parseYield(n);return t&&(e=this.parseParenItem(e,n)),e}let i;e?i=!1:(e=new $f,i=!0),this.state.canStartArrow=!0;let a=this.parseMaybeConditional(e);if(t&&(a=this.parseParenItem(a,n)),pd(this.state.type)){let t=this.startNodeAt(n),r=this.state.value;if(t.operator=r,this.match(25)){this.toAssignable(a,!0),t.left=a;let r=n.index;e.doubleProtoLoc!=null&&e.doubleProtoLoc.index>=r&&(e.doubleProtoLoc=null),e.shorthandAssignLoc!=null&&e.shorthandAssignLoc.index>=r&&(e.shorthandAssignLoc=null),e.privateKeyLoc!=null&&e.privateKeyLoc.index>=r&&(this.checkDestructuringPrivate(e),e.privateKeyLoc=null),e.voidPatternLoc!=null&&e.voidPatternLoc.index>=r&&(e.voidPatternLoc=null)}else t.left=a;return this.next(),t.right=this.parseMaybeAssign(),this.checkLVal(a,this.finishNode(t,`AssignmentExpression`),void 0,void 0,void 0,void 0,r===`||=`||r===`&&=`||r===`??=`),t}if(i&&this.checkExpressionErrors(e,!0),r){let{type:e}=this.state;if((this.hasPlugin(`v8intrinsic`)?fd(e):fd(e)&&!this.match(50))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(G.YieldNotInGeneratorFunction,n),this.parseYield(n)}return a}parseMaybeConditional(e){let t=this.state.startLoc,n=this.parseExprOps(e);return this.shouldExitDescending(n)?n:this.parseConditional(n,t,e)}parseConditional(e,t,n){if(this.eat(13)){let n=this.startNodeAt(t);return n.test=e,n.consequent=this.parseMaybeAssignAllowIn(),this.expect(10),n.alternate=this.parseMaybeAssign(),this.finishNode(n,`ConditionalExpression`)}return e}parseMaybeUnaryOrPrivate(e){return this.match(134)?this.parsePrivateName():this.parseMaybeUnary(e)}parseExprOps(e){let t=this.state.startLoc,n=this.parseMaybeUnaryOrPrivate(e);return this.shouldExitDescending(n)?n:(this.state.canStartArrow=!1,this.parseExprOp(n,t,-1))}parseExprOp(e,t,n){if(this.isPrivateName(e)){let r=this.getPrivateNameSV(e);(n>=Cd(54)||!this.prodParam.hasIn||!this.match(54))&&this.raise(G.PrivateInExpectedIn,t,{identifierName:r}),this.classScope.usePrivateName(r,t)}let r=this.state.type;if(_d(r)&&(this.prodParam.hasIn||!this.match(54))){let i=Cd(r);if(i>n){if(r===35&&(this.expectPlugin(`pipelineOperator`),this.prodParam.inFSharpPipelineDirectBody))return e;let a=this.startNodeAt(t);a.left=e,a.operator=this.state.value;let o=r===37||r===38,s=r===36;s&&(i=Cd(38)),this.next(),a.right=this.parseExprOpRightExpr(r,i);let c=this.finishNode(a,o||s?`LogicalExpression`:`BinaryExpression`),l=this.state.type;if(s&&(l===37||l===38)||o&&l===36)throw this.raise(G.MixingCoalesceWithLogical,this.state.startLoc);return this.parseExprOp(c,t,n)}}return e}parseExprOpRightExpr(e,t){switch(e){case 35:switch(this.getPluginOption(`pipelineOperator`,`proposal`)){case`hack`:return this.withTopicBindingContext(()=>this.parseHackPipeBody());case`fsharp`:return this.parseFSharpPipelineBody(t)}default:return this.parseExprOpBaseRightExpr(e,t)}}parseExprOpBaseRightExpr(e,t){let n=this.state.startLoc;return this.parseExprOp(this.parseMaybeUnaryOrPrivate(),n,wd(e)?t-1:t)}parseHackPipeBody(){let{startLoc:e}=this.state,t=this.parseMaybeAssign();return Mu.has(t.type)&&!t.extra?.parenthesized&&this.raise(G.PipeUnparenthesizedBody,e,{type:t.type}),this.topicReferenceWasUsedInCurrentContext()||this.raise(G.PipeTopicUnused,e),t}checkExponentialAfterUnary(e){this.match(53)&&this.raise(G.UnexpectedTokenUnaryExponentiation,e.argument)}parseMaybeUnary(e,t){let n=this.state.startLoc,r=this.isContextual(92);if(r&&this.recordAwaitIfAllowed()){this.next();let e=this.parseAwait(n);return t||this.checkExponentialAfterUnary(e),e}let i=this.match(30),a=this.startNode();if(yd(this.state.type)){a.operator=this.state.value,a.prefix=!0,this.state.canStartArrow=!1,this.match(68)&&this.expectPlugin(`throwExpressions`);let n=this.match(85);if(this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(e,!0),this.state.strict&&n){let e=a.argument;e.type===`Identifier`?this.raise(G.StrictDelete,a):this.hasPropertyAsPrivateName(e)&&this.raise(G.DeletePrivateField,a)}if(!i)return t||this.checkExponentialAfterUnary(a),this.finishNode(a,`UnaryExpression`)}let o=this.parseUpdate(a,i,e);if(r){let{type:e}=this.state;if((this.hasPlugin(`v8intrinsic`)?fd(e):fd(e)&&!this.match(50))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(G.AwaitNotInAsyncContext,n),this.parseAwait(n)}return o}parseUpdate(e,t,n){if(t){let t=this.finishNode(e,`UpdateExpression`);return this.checkLVal(t.argument,t),t}let r=this.state.startLoc,i=this.parseExprSubscripts(n);if(this.checkExpressionErrors(n,!1))return i;for(;vd(this.state.type)&&!this.canInsertSemicolon();){let e=this.startNodeAt(r);e.operator=this.state.value,e.prefix=!1,e.argument=i,this.next(),this.checkLVal(i,i=this.finishNode(e,`UpdateExpression`))}return i}parseExprSubscripts(e){let t=this.state.startLoc;this.setLoc(t);let n=this.parseExprAtom(e);return this.shouldExitDescending(n)?n:this.parseSubscripts(n,t)}parseSubscripts(e,t,n){let r={optionalChainMember:!1,maybeAsyncArrow:this.atPossibleAsyncArrow(e),stop:!1};do e=this.parseSubscript(e,t,n,r),r.maybeAsyncArrow=!1;while(!r.stop);return e}parseSubscript(e,t,n,r){let{type:i}=this.state;if(!n&&i===11)return this.parseBind(e,t,r);if(Td(i))return this.parseTaggedTemplateExpression(e,t,r);let a=!1;if(i===14){if(n&&(this.raise(G.OptionalChainingNoNew,this.state.startLoc),this.lookaheadCharCode()===40))return this.stopParseSubscript(e,r);r.optionalChainMember=a=!0,this.next()}if(!n&&this.match(6))return this.parseCoverCallAndAsyncArrowHead(e,t,r,a);{let n=this.eat(0);return n||a||this.eat(12)?this.parseMember(e,t,r,n,a):this.stopParseSubscript(e,r)}}stopParseSubscript(e,t){return t.stop=!0,e}parseMember(e,t,n,r,i){let a=this.startNodeAt(t);return a.object=e,a.computed=r,r?(a.property=this.parseExpression(),this.expect(1)):this.match(134)?(e.type===`Super`&&this.raise(G.SuperPrivateField,t),this.classScope.usePrivateName(this.state.value,this.state.startLoc),a.property=this.parsePrivateName()):a.property=this.parseIdentifier(!0),n.optionalChainMember?(a.optional=i,this.finishNode(a,`OptionalMemberExpression`)):this.finishNode(a,`MemberExpression`)}parseBind(e,t,n){let r=this.startNodeAt(t);r.object=e,this.next();let i=this.parseNoCallExpr(e=>{throw this.raise(G.UnsupportedBindRHS,e)});if(i.type===`Super`||i.type===`Import`)throw this.raise(G.UnsupportedBindRHS,i);return r.callee=i,n.stop=!0,this.parseSubscripts(this.finishNode(r,`BindExpression`),t,!1)}parseCoverCallAndAsyncArrowHead(e,t,n,r){let i=null;this.next();let a=this.startNodeAt(t);a.callee=e;let{maybeAsyncArrow:o,optionalChainMember:s}=n;o&&(this.expressionScope.enter(Jf()),i=new $f),s&&(a.optional=r),a.arguments=r?this.parseCallExpressionArguments():this.parseCallExpressionArguments(e.type!==`Super`,a,i);let c=this.finishCallExpression(a,s);return o&&this.shouldParseAsyncArrow()&&!r?(n.stop=!0,this.checkDestructuringPrivate(i),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),c=this.parseAsyncArrowFromCallExpression(this.startNodeAt(t),c)):(o&&(this.checkExpressionErrors(i,!0),this.expressionScope.exit()),this.toReferencedList(a.arguments)),c}parseTaggedTemplateExpression(e,t,n){let r=this.startNodeAt(t);return r.tag=e,r.quasi=this.parseTemplate(!0),n.optionalChainMember&&this.raise(G.OptionalChainingNoTemplate,t),this.finishNode(r,`TaggedTemplateExpression`)}atPossibleAsyncArrow(e){return e.type===`Identifier`&&e.name===`async`&&this.state.lastTokEndLoc.index===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.state.canStartArrow}finishCallExpression(e,t){if(e.callee.type===`Import`){if(e.arguments.length===0||e.arguments.length>2)this.raise(G.ImportCallArity,e);else for(let t of e.arguments)t.type===`SpreadElement`&&this.raise(G.ImportCallSpreadArgument,t)}return this.finishNode(e,t?`OptionalCallExpression`:`CallExpression`)}parseCallExpressionArguments(e,t,n){let r=[],i=!0;for(;!this.eat(7);){if(i)i=!1;else if(this.expect(8),this.match(7)){t&&this.addTrailingCommaExtraToNode(t),this.next();break}r.push(this.parseExprListItem(7,!1,n,e))}return r}shouldParseAsyncArrow(){return this.match(15)&&!this.canInsertSemicolon()}parseAsyncArrowFromCallExpression(e,t){return this.resetPreviousNodeTrailingComments(t),this.expect(15),this.parseArrowExpression(e,t.arguments,!0,t.extra?.trailingCommaLoc),t.innerComments&&Cf(e,t.innerComments),t.callee.trailingComments&&Cf(e,t.callee.trailingComments),e}parseNoCallExpr(e){let t=this.state.startLoc,n=this.match(79),r=this.parseExprAtom();return n&&r.type===`ImportExpression`&&e(r),this.parseSubscripts(r,t,!0)}parseExprAtom(e){let t,n=null,{type:r}=this.state;switch(r){case 75:return this.parseSuper();case 79:return t=this.startNode(),this.next(),this.match(12)?this.parseImportMetaPropertyOrPhaseCall(t):this.match(6)?this.optionFlags&1024?this.parseImportCall(t):this.finishNode(t,`Import`):(this.raise(G.UnsupportedImport,this.state.lastTokStartLoc),this.finishNode(t,`Import`));case 74:return t=this.startNode(),this.next(),this.finishNode(t,`ThisExpression`);case 86:return this.parseDo(this.startNode(),!1);case 52:case 27:return this.readRegexp(),this.parseRegExpLiteral(this.state.value);case 131:return this.parseNumericLiteral(this.state.value);case 132:return this.parseBigIntLiteral(this.state.value);case 130:return this.parseStringLiteral(this.state.value);case 80:return this.parseNullLiteral();case 81:return this.parseBooleanLiteral(!0);case 82:return this.parseBooleanLiteral(!1);case 6:return this.parseParenAndDistinguishExpression(this.state.canStartArrow);case 0:return this.parseArrayLike(1,e);case 2:return this.parseObjectLike(4,!1,e);case 64:return this.parseFunctionOrFunctionSent();case 22:n=this.parseDecorators();case 76:return this.parseClass(this.maybeTakeDecorators(n,this.startNode()),!1);case 73:return this.parseNewOrNewTarget();case 21:case 20:return this.parseTemplate(!1);case 11:{t=this.startNode(),this.next(),t.object=null;let e=t.callee=this.parseNoCallExpr(e=>{throw this.raise(G.UnsupportedBind,e)});if(e.type===`MemberExpression`)return this.finishNode(t,`BindExpression`);throw this.raise(G.UnsupportedBind,e)}case 134:return this.raise(G.PrivateInExpectedIn,this.state.startLoc,{identifierName:this.state.value}),this.parsePrivateName();case 29:return this.parseTopicReferenceThenEqualsSign(50,`%`);case 28:return this.parseTopicReferenceThenEqualsSign(40,`^`);case 33:case 34:return this.parseTopicReference(`hack`);case 40:case 50:case 23:{let e=this.getPluginOption(`pipelineOperator`,`proposal`);if(e)return this.parseTopicReference(e);throw this.unexpected()}case 43:{let e=this.input.codePointAt(this.nextTokenStart());throw Pd(e)||e===62?this.expectOnePlugin([`jsx`,`flow`,`typescript`]):this.unexpected()}default:if(sd(r)){if(this.isContextual(123)&&this.lookaheadInLineCharCode()===123)return this.parseModuleExpression();let{canStartArrow:e,containsEsc:t}=this.state,n=this.parseIdentifier();if(!t&&n.name===`async`&&!this.canInsertSemicolon()){let{type:t}=this.state;if(t===64)return this.resetPreviousNodeTrailingComments(n),this.next(),this.parseAsyncFunctionExpression(this.startNodeAtNode(n));if(sd(t))return e&&this.lookaheadCharCode()===61?this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(n)):n;if(t===86)return this.resetPreviousNodeTrailingComments(n),this.parseDo(this.startNodeAtNode(n),!0)}return e&&this.match(15)&&!this.canInsertSemicolon()?(this.next(),this.parseArrowExpression(this.startNodeAtNode(n),[n],!1)):n}throw this.unexpected()}}parseTopicReferenceThenEqualsSign(e,t){let n=this.getPluginOption(`pipelineOperator`,`proposal`);if(n)return this.state.type=e,this.state.value=t,this.state.pos--,this.state.end--,this.state.endLoc=wu(this.state.endLoc,-1),this.parseTopicReference(n);throw this.unexpected()}parseTopicReference(e){let t=this.startNode(),n=this.state.startLoc,r=this.state.type;return this.next(),this.finishTopicReference(t,n,e,r)}finishTopicReference(e,t,n,r){if(this.testTopicReferenceConfiguration(n,t,r))return this.topicReferenceIsAllowedInCurrentContext()||this.raise(G.PipeTopicUnbound,t),this.registerTopicReference(),this.finishNode(e,`TopicReference`);throw this.raise(G.PipeTopicUnconfiguredToken,t,{token:Sd(r)})}testTopicReferenceConfiguration(e,t,n){switch(e){case`hack`:return this.hasPlugin([`pipelineOperator`,{topicToken:Sd(n)}]);default:throw this.raise(G.PipeTopicRequiresHackPipes,t)}}parseAsyncArrowUnaryFunction(e){this.prodParam.enter(Zf(!0,this.prodParam.hasYield));let t=[this.parseIdentifier()];return this.prodParam.exit(),this.hasPrecedingLineBreak()&&this.raise(G.LineTerminatorBeforeArrow,this.state.curPosition()),this.expect(15),this.parseArrowExpression(e,t,!0)}parseDo(e,t){this.expectPlugin(`doExpressions`),t&&this.expectPlugin(`asyncDoExpressions`),e.async=t,this.next();let n=this.state.labels;return this.state.labels=[],t?(this.prodParam.enter(2),e.body=this.parseBlock(),this.prodParam.exit()):e.body=this.parseBlock(),this.state.labels=n,this.finishNode(e,`DoExpression`)}parseSuper(){let e=this.startNode();return this.next(),this.match(6)&&!this.scope.allowDirectSuper?this.raise(G.SuperNotAllowed,e):this.scope.allowSuper||this.raise(G.UnexpectedSuper,e),!this.match(6)&&!this.match(0)&&!this.match(12)&&this.raise(G.UnsupportedSuper,e),this.finishNode(e,`Super`)}parsePrivateName(){let e=this.startNode(),t=this.startNodeAt(wu(this.state.startLoc,1)),n=this.state.value;return this.next(),e.id=this.createIdentifier(t,n),this.finishNode(e,`PrivateName`)}parseFunctionOrFunctionSent(){let e=this.startNode();if(this.next(),this.prodParam.hasYield&&this.match(12)){let t=this.createIdentifier(this.startNodeAtNode(e),`function`);return this.next(),this.match(99)?this.expectPlugin(`functionSent`):this.hasPlugin(`functionSent`)||this.unexpected(),this.parseMetaProperty(e,t,`sent`)}return this.parseFunction(e)}parseMetaProperty(e,t,n){e.meta=t;let r=this.state.containsEsc;return e.property=this.parseIdentifier(!0),(e.property.name!==n||r)&&this.raise(G.UnsupportedMetaProperty,e.property,{target:t.name,onlyValidPropertyName:n}),this.finishNode(e,`MetaProperty`)}parseImportMetaPropertyOrPhaseCall(e){if(this.next(),this.isContextual(101)||this.isContextual(93)){let t=this.isContextual(101);return this.expectPlugin(t?`sourcePhaseImports`:`deferredImportEvaluation`),this.next(),e.phase=t?`source`:`defer`,this.parseImportCall(e)}{let t=this.createIdentifierAt(this.startNodeAtNode(e),`import`,this.state.lastTokStartLoc);return this.isContextual(97)&&(this.inModule||this.raise(G.ImportMetaOutsideModule,t),this.sawUnambiguousESM=!0),this.parseMetaProperty(e,t,`meta`)}}parseLiteralAtNode(e,t,n){return this.addExtra(n,`rawValue`,e),this.addExtra(n,`raw`,this.input.slice(this.offsetToSourcePos(n.start),this.state.end)),n.value=e,this.next(),this.finishNode(n,t)}parseLiteral(e,t){let n=this.startNode();return this.parseLiteralAtNode(e,t,n)}parseStringLiteral(e){return this.parseLiteral(e,`StringLiteral`)}parseNumericLiteral(e){return this.parseLiteral(e,`NumericLiteral`)}parseBigIntLiteral(e){let t;try{t=BigInt(e)}catch{t=null}return this.parseLiteral(t,`BigIntLiteral`)}parseRegExpLiteral(e){let t=this.startNode();return this.addExtra(t,`raw`,this.input.slice(this.offsetToSourcePos(t.start),this.state.end)),t.pattern=e.pattern,t.flags=e.flags,this.next(),this.finishNode(t,`RegExpLiteral`)}parseBooleanLiteral(e){let t=this.startNode();return t.value=e,this.next(),this.finishNode(t,`BooleanLiteral`)}parseNullLiteral(){let e=this.startNode();return this.next(),this.finishNode(e,`NullLiteral`)}parseParenAndDistinguishExpression(e){let t=this.state.startLoc,n;this.next(),this.expressionScope.enter(qf());let r=this.state.startLoc,i=[],a=new $f,o=!0,s,c;for(;!this.match(7);){if(o)o=!1;else if(this.expect(8,a.optionalParametersLoc===null?null:a.optionalParametersLoc),this.match(7)){c=this.state.startLoc;break}if(this.match(17)){let e=this.state.startLoc;if(s=this.state.startLoc,i.push(this.parseParenItem(this.parseRestBinding(),e)),!this.checkCommaAfterRest(41))break}else i.push(this.parseMaybeAssignAllowInOrVoidPattern(7,a,!0))}let l=this.state.lastTokEndLoc;this.expect(7);let u=this.startNodeAt(t);return e&&this.shouldParseArrow(i)&&(u=this.parseArrow(u))?(this.checkDestructuringPrivate(a),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(u,i,!1),u):(this.expressionScope.exit(),i.length||this.unexpected(this.state.lastTokStartLoc),c&&this.unexpected(c),s&&this.unexpected(s),this.checkExpressionErrors(a,!0),this.toReferencedList(i,!0),i.length>1?(n=this.startNodeAt(r),n.expressions=i,this.finishNode(n,`SequenceExpression`),this.resetEndLocation(n,l)):n=i[0],this.wrapParenthesis(t,n))}wrapParenthesis(e,t){if(!(this.optionFlags&2048))return this.addExtra(t,`parenthesized`,!0),this.addExtra(t,`parenStart`,e.index),this.takeSurroundingComments(t,e.index,this.state.lastTokEndLoc.index),t;let n=this.startNodeAt(e);return n.expression=t,this.finishNode(n,`ParenthesizedExpression`)}shouldParseArrow(e){return!this.canInsertSemicolon()}parseArrow(e){if(this.eat(15))return e}parseParenItem(e,t){return e}parseNewOrNewTarget(){let e=this.startNode();if(this.next(),this.match(12)){let t=this.createIdentifier(this.startNodeAtNode(e),`new`);this.next();let n=this.parseMetaProperty(e,t,`target`);return this.scope.allowNewTarget||this.raise(G.UnexpectedNewTarget,n),n}return this.parseNew(e)}parseNew(e){if(this.parseNewCallee(e),this.eat(6)){let t=this.parseExprList(7);this.toReferencedList(t),e.arguments=t}else e.arguments=[];return this.finishNode(e,`NewExpression`)}parseNewCallee(e){let t=this.parseNoCallExpr(e=>{this.raise(G.ImportCallNotNewExpression,e,e)});e.callee=t,t.type===`Import`&&this.raise(G.ImportCallNotNewExpression,t),t.type===`Super`&&this.raise(G.SuperCallNotNewExpression,t)}parseTemplateElement(e){let{start:t,startLoc:n,end:r,value:i}=this.state,a=t+1,o=this.startNodeAt(wu(n,1));i===null&&(e||this.raise(G.InvalidEscapeSequenceTemplate,wu(this.state.firstInvalidTemplateEscapePos,1)));let s=this.match(20),c=s?-1:-2,l=r+c;o.value={raw:this.input.slice(a,l).replace(/\r\n?/g,`
23
- `),cooked:i===null?null:i.slice(1,c)},o.tail=s,this.next();let u=this.finishNode(o,`TemplateElement`);return this.resetEndLocation(u,wu(this.state.lastTokEndLoc,c)),u}parseTemplate(e){let t=this.startNode(),n=this.parseTemplateElement(e),r=[n],i=[];for(;!n.tail;)i.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),r.push(n=this.parseTemplateElement(e));return t.expressions=i,t.quasis=r,this.finishNode(t,`TemplateLiteral`)}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(e,t,n){let r=!1,i=!0,a=this.startNode();for(a.properties=[],this.next();!this.match(e);){if(i)i=!1;else if(this.expect(8),this.match(e)){this.addTrailingCommaExtraToNode(a);break}let o;t?o=this.parseBindingProperty():(o=this.parsePropertyDefinition(n),r=this.checkProto(o,r,n)),a.properties.push(o)}this.next();let o=t?`ObjectPattern`:`ObjectExpression`;return this.finishNode(a,o)}addTrailingCommaExtraToNode(e){this.addExtra(e,`trailingComma`,this.state.lastTokStartLoc.index),this.addExtra(e,`trailingCommaLoc`,this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(e){return!e.computed&&e.key.type===`Identifier`&&(this.isLiteralPropertyName()||this.match(0)||this.match(51))}parsePropertyDefinition(e){let t=[];if(this.match(22))for(this.hasPlugin(`decorators`)&&this.raise(G.UnsupportedPropertyDecorator,this.state.startLoc);this.match(22);)t.push(this.parseDecorator());let n=this.startNode(),r=!1,i=!1,a;if(this.match(17))return t.length&&this.unexpected(),this.parseSpread();t.length&&(n.decorators=t),n.method=!1,e&&(a=this.state.startLoc);let o=this.eat(51);this.parsePropertyNamePrefixOperator(n);let s=this.state.containsEsc;if(this.parsePropertyName(n,e),!o&&!s&&this.maybeAsyncOrAccessorProp(n)){let{key:e}=n,t=e.name;t===`async`&&!this.hasPrecedingLineBreak()&&(r=!0,this.resetPreviousNodeTrailingComments(e),o=this.eat(51),this.parsePropertyName(n)),(t===`get`||t===`set`)&&(i=!0,this.resetPreviousNodeTrailingComments(e),n.kind=t,this.match(51)&&(o=!0,this.raise(G.AccessorIsGenerator,this.state.curPosition(),{kind:t}),this.next()),this.parsePropertyName(n))}return this.parseObjPropValue(n,a,o,r,!1,i,e)}getGetterSetterExpectedParamCount(e){return e.kind===`get`?0:1}getObjectOrClassMethodParams(e){return e.params}checkGetterSetterParams(e){let t=this.getGetterSetterExpectedParamCount(e),n=this.getObjectOrClassMethodParams(e);n.length!==t&&this.raise(e.kind===`get`?G.BadGetterArity:G.BadSetterArity,e),e.kind===`set`&&n[n.length-1]?.type===`RestElement`&&this.raise(G.BadSetterRestParameter,e)}parseObjectMethod(e,t,n,r,i){if(i){let n=this.parseMethod(e,t,!1,!1,!1,`ObjectMethod`);return this.checkGetterSetterParams(n),n}if(n||t||this.match(6))return r&&this.unexpected(),e.kind=`method`,e.method=!0,this.parseMethod(e,t,n,!1,!1,`ObjectMethod`)}parseObjectProperty(e,t,n,r){if(e.shorthand=!1,this.eat(10))return e.value=n?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowInOrVoidPattern(4,r),this.finishObjectProperty(e);if(!e.computed&&e.key.type===`Identifier`){if(this.checkReservedWord(e.key.name,e.key.start,!0,!1),n)e.value=this.parseMaybeDefault(t,this.cloneIdentifier(e.key));else if(this.match(25)){let n=this.state.startLoc;r==null?this.raise(G.InvalidCoverInitializedName,n):r.shorthandAssignLoc===null&&(r.shorthandAssignLoc=n),e.value=this.parseMaybeDefault(t,this.cloneIdentifier(e.key))}else e.value=this.cloneIdentifier(e.key);return e.shorthand=!0,this.finishObjectProperty(e)}}finishObjectProperty(e){return this.finishNode(e,`ObjectProperty`)}parseObjPropValue(e,t,n,r,i,a,o){let s=this.parseObjectMethod(e,n,r,i,a)||this.parseObjectProperty(e,t,i,o);return s||this.unexpected(),s}parsePropertyName(e,t){if(this.eat(0))e.computed=!0,e.key=this.parseMaybeAssignAllowIn(),this.expect(1);else{let{type:n,value:r}=this.state,i;if(ld(n))i=this.parseIdentifier(!0);else switch(n){case 131:i=this.parseNumericLiteral(r);break;case 130:i=this.parseStringLiteral(r);break;case 132:i=this.parseBigIntLiteral(r);break;case 134:{let e=this.state.startLoc;t==null?this.raise(G.UnexpectedPrivateField,e):t.privateKeyLoc===null&&(t.privateKeyLoc=e),i=this.parsePrivateName();break}default:throw this.unexpected()}e.key=i,n!==134&&(e.computed=!1)}}initFunction(e,t){e.id=null,e.generator=!1,e.async=t}parseMethod(e,t,n,r,i,a,o=!1){this.initFunction(e,n),e.generator=t,this.scope.enter(530|(o?576:0)|(i?32:0)),this.prodParam.enter(Zf(n,e.generator)),this.parseFunctionParams(e,r);let s=this.parseFunctionBodyAndFinish(e,a,!0);return this.prodParam.exit(),this.scope.exit(),s}parseArrayLike(e,t){let n=this.startNode();return this.next(),n.elements=this.parseExprList(e,!0,t,n),this.finishNode(n,`ArrayExpression`)}parseArrowExpression(e,t,n,r){this.scope.enter(518);let i=Zf(n,!1);return this.match(2)||(i|=this.prodParam.currentFlags()&24),this.prodParam.enter(i),this.initFunction(e,n),t&&this.setArrowFunctionParameters(e,t,r),this.parseFunctionBody(e,!0),this.prodParam.exit(),this.scope.exit(),this.finishNode(e,`ArrowFunctionExpression`)}setArrowFunctionParameters(e,t,n){this.toAssignableList(t,n,!1),e.params=t}parseFunctionBodyAndFinish(e,t,n=!1){return this.parseFunctionBody(e,!1,n),this.finishNode(e,t)}parseFunctionBody(e,t,n=!1){let r=t&&!this.match(2);if(this.expressionScope.enter(Yf()),r)e.body=this.parseMaybeAssign(),this.checkParams(e,!1,t,!1);else{let r=this.state.strict,i=this.state.labels;this.state.labels=[],this.prodParam.enter(this.prodParam.currentFlags()|4),e.body=this.parseBlock(!0,!1,i=>{let a=!this.isSimpleParamList(e.params);i&&a&&this.raise(G.IllegalLanguageModeDirective,(e.kind===`method`||e.kind===`constructor`)&&e.key?this.optionFlags&256?e.key.loc.end:e.key:e);let o=!r&&this.state.strict;this.checkParams(e,!this.state.strict&&!t&&!n&&!a,t,o),this.state.strict&&e.id&&this.checkIdentifier(e.id,65,o)}),this.prodParam.exit(),this.state.labels=i}this.expressionScope.exit()}isSimpleParameter(e){return e.type===`Identifier`}isSimpleParamList(e){for(let t=0,n=e.length;t<n;t++)if(!this.isSimpleParameter(e[t]))return!1;return!0}checkParams(e,t,n,r=!0){let i=!t&&new Set,a={type:`FormalParameters`};for(let t of e.params)this.checkLVal(t,a,5,i,r)}parseExprList(e,t,n,r){let i=[],a=!0;for(;!this.eat(e);){if(a)a=!1;else if(this.expect(8),this.match(e)){r&&this.addTrailingCommaExtraToNode(r),this.next();break}i.push(this.parseExprListItem(e,t,n))}return i}parseExprListItem(e,t,n,r){let i;if(this.match(8))t||this.raise(G.UnexpectedToken,this.state.curPosition(),{unexpected:`,`}),i=null;else if(this.match(17)){let e=this.state.startLoc;i=this.parseParenItem(this.parseSpread(n),e)}else if(this.match(13)){this.expectPlugin(`partialApplication`),r||this.raise(G.UnexpectedArgumentPlaceholder,this.state.startLoc);let e=this.startNode();this.next(),i=this.finishNode(e,`ArgumentPlaceholder`)}else i=this.parseMaybeAssignAllowInOrVoidPattern(e,n,!0);return i}parseIdentifier(e){let t=this.startNode(),n=this.parseIdentifierName(e);return this.createIdentifier(t,n)}createIdentifier(e,t){return e.name=t,this.optionFlags&256&&(e.loc.identifierName=t),this.finishNode(e,`Identifier`)}createIdentifierAt(e,t,n){return e.name=t,this.optionFlags&256&&(e.loc.identifierName=t),this.finishNodeAt(e,`Identifier`,n)}parseIdentifierName(e){let t,{start:n,type:r}=this.state;ld(r)?t=this.state.value:this.unexpected();let i=cd(r);return e?i&&this.replaceToken(128):this.checkReservedWord(t,this.sourceToOffsetPos(n),i,!1),this.next(),t}checkReservedWord(e,t,n,r){if(!(e.length>10)&&qd(e)){if(n&&Wd(e)){this.raise(G.UnexpectedKeyword,t,{keyword:e});return}if((this.state.strict?r?Ud:Vd:Bd)(e,this.inModule)){this.raise(G.UnexpectedReservedWord,t,{reservedWord:e});return}if(e===`yield`){if(this.prodParam.hasYield){this.raise(G.YieldBindingIdentifier,t);return}}else if(e===`await`){if(this.prodParam.hasAwait){this.raise(G.AwaitBindingIdentifier,t);return}if(this.scope.inStaticBlock){this.raise(G.AwaitBindingIdentifierInStaticBlock,t);return}this.expressionScope.recordAsyncArrowParametersError(t)}else if(e===`arguments`&&this.scope.inClassAndNotInNonArrowFunction){this.raise(G.ArgumentsInClass,t);return}}}recordAwaitIfAllowed(){let e=this.prodParam.hasAwait;return e&&!this.scope.inFunction&&(this.state.hasTopLevelAwait=!0),e}parseAwait(e,t){let n=e.index;this.setLoc(e);let r=this.startNodeAt(e);return this.expressionScope.recordParameterInitializerError(G.AwaitExpressionFormalParameter,n),this.eat(51)&&this.raise(G.ObsoleteAwaitStar,e),!this.scope.inFunction&&!(this.optionFlags&1)&&(this.isAmbiguousPrefixOrIdentifier()?this.ambiguousScriptDifferentAst=!0:this.sawUnambiguousESM=!0),t||(r.argument=this.parseMaybeUnary(null,!0)),this.finishNode(r,`AwaitExpression`)}isAmbiguousPrefixOrIdentifier(){if(this.hasPrecedingLineBreak())return!0;let{type:e}=this.state;return e===49||e===6||e===0||Td(e)||e===98&&!this.state.containsEsc||e===133||e===52||this.hasPlugin(`v8intrinsic`)&&e===50}parseYield(e){this.setLoc(e);let t=this.startNodeAt(e);this.expressionScope.recordParameterInitializerError(G.YieldInParameter,e.index);let n=!1,r=null;if(!this.hasPrecedingLineBreak())switch(n=this.eat(51),this.state.type){case 9:case 135:case 4:case 7:case 1:case 5:case 10:case 8:if(!n)break;default:r=this.parseMaybeAssign()}return t.delegate=n,t.argument=r,this.finishNode(t,`YieldExpression`)}parseImportCall(e){this.next();let t=this.parseCallExpressionArguments();if(t.length===0||t.length>2)this.raise(G.ImportCallArity,e,e);else for(let n of t)n.type===`SpreadElement`&&this.raise(G.ImportCallSpreadArgument,n,e);return e.source=t[0],e.options=t[1]??null,this.finishNode(e,`ImportExpression`)}withTopicBindingContext(e){let t=this.state.inHackPipelineBody;this.state.inHackPipelineBody=!0;let n=this.state.seenTopicReference;this.state.seenTopicReference=!1;try{return e()}finally{this.state.inHackPipelineBody=t,this.state.seenTopicReference=n}}allowInAnd(e){let t=this.prodParam.currentFlags();if(24&~t){this.prodParam.enter(t|24);try{return e()}finally{this.prodParam.exit()}}return e()}disallowInAnd(e){let t=this.prodParam.currentFlags(),n=8&t,r=16&~t;if(n||r){this.prodParam.enter(t&-9|16);try{return e()}finally{this.prodParam.exit()}}return e()}registerTopicReference(){this.state.seenTopicReference=!0}topicReferenceIsAllowedInCurrentContext(){return this.state.inHackPipelineBody}topicReferenceWasUsedInCurrentContext(){return this.state.seenTopicReference}parseFSharpPipelineBody(e){let t=this.state.startLoc;this.prodParam.enter(this.prodParam.currentFlags()&-17);let n;if(this.isContextual(92)&&this.recordAwaitIfAllowed()){this.next(),n=this.parseAwait(t,!0);let e=this.state.type;_d(e)&&e!==35&&(this.prodParam.hasIn||e!==54)&&this.raise(G.PipelineUnparenthesized,t)}else this.state.canStartArrow=!0,n=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),t,e);return this.prodParam.exit(),n}parseModuleExpression(){this.expectPlugin(`moduleBlocks`);let e=this.startNode();this.next(),this.match(2)||this.unexpected(null,2);let t=this.startNodeAt(this.state.endLoc);this.next();let n=this.initializeScopes(!0);this.enterInitialScopes();try{e.body=this.parseProgram(t,4,`module`)}finally{n()}return this.finishNode(e,`ModuleExpression`)}parseVoidPattern(e){this.expectPlugin(`discardBinding`);let t=this.startNode();return e!=null&&(e.voidPatternLoc=this.state.startLoc),this.next(),this.finishNode(t,`VoidPattern`)}parseMaybeAssignAllowInOrVoidPattern(e,t,n){if(t!=null&&this.match(84)){let n=this.lookaheadCharCode();if(n===44||n===(e===1?93:e===4?125:41)||n===61)return this.parseMaybeDefault(this.state.startLoc,this.parseVoidPattern(t))}return this.parseMaybeAssignAllowIn(t,n)}parsePropertyNamePrefixOperator(e){}},op={kind:1},sp={kind:2},cp=/[\uD800-\uDFFF]/u,lp=/in(?:stanceof)?/y;function up(e){for(let t=0;t<e.length;t++){let n=e[t],{type:r}=n;typeof r==`number`&&(n.type=Ed(r))}return e}var dp=class extends ap{parseTopLevel(e,t){return e.program=this.parseProgram(t,135,this.options.sourceType===`module`?`module`:`script`),e.comments=this.comments,this.optionFlags&512&&(e.tokens=up(this.tokens)),this.finishNode(e,`File`)}parseProgram(e,t,n){if(e.sourceType=n,e.interpreter=this.parseInterpreterDirective(),this.parseBlockBody(e,!0,!0,t),this.inModule){if(!(this.optionFlags&64)&&this.scope.undefinedExports.size>0)for(let[e,t]of Array.from(this.scope.undefinedExports))this.raise(G.ModuleExportUndefined,t,{localName:e});this.addExtra(e,`topLevelAwait`,this.state.hasTopLevelAwait)}let r;return r=t===135?this.finishNode(e,`Program`):this.finishNodeAt(e,`Program`,wu(this.state.startLoc,-1)),r}stmtToDirective(e){let t=this.castNodeTo(e,`Directive`),n=this.castNodeTo(e.expression,`DirectiveLiteral`),r=n.value,i=this.input.slice(this.offsetToSourcePos(n.start),this.offsetToSourcePos(n.end)),a=n.value=i.slice(1,-1);return this.addExtra(n,`raw`,i),this.addExtra(n,`rawValue`,a),this.addExtra(n,`expressionValue`,r),t.value=n,delete e.expression,t}parseInterpreterDirective(){if(!this.match(24))return null;let e=this.startNode();return e.value=this.state.value,this.next(),this.finishNode(e,`InterpreterDirective`)}isLet(){return this.isContextual(96)?this.hasFollowingBindingAtom():!1}isUsing(){return this.isContextual(103)?this.nextTokenIsIdentifierOnSameLine():!1}isForUsing(){if(!this.isContextual(103))return!1;let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);if(this.isUnparsedContextual(e,`of`)){let t=this.lookaheadCharCodeSince(e+2);if(t!==61&&t!==58&&t!==59)return!1}return!!(this.chStartsBindingIdentifier(t,e)||this.isUnparsedContextual(e,`void`))}nextTokenIsIdentifierOnSameLine(){let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);return this.chStartsBindingIdentifier(t,e)}isAwaitUsing(){if(!this.isContextual(92))return!1;let e=this.nextTokenInLineStart();if(this.isUnparsedContextual(e,`using`)){e=this.nextTokenInLineStartSince(e+5);let t=this.codePointAtPos(e);if(this.chStartsBindingIdentifier(t,e))return!0}return!1}chStartsBindingIdentifier(e,t){if(Pd(e)){if(lp.lastIndex=t,lp.test(this.input)){let e=this.codePointAtPos(lp.lastIndex);if(!Fd(e)&&e!==92)return!1}return!0}return e===92}chStartsBindingPattern(e){return e===91||e===123}hasFollowingBindingAtom(){let e=this.nextTokenStart(),t=this.codePointAtPos(e);return this.chStartsBindingPattern(t)||this.chStartsBindingIdentifier(t,e)}hasInLineFollowingBindingIdentifierOrBrace(){let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);return t===123||this.chStartsBindingIdentifier(t,e)}allowsUsing(){return(this.scope.inModule||!this.scope.inTopLevel)&&!this.scope.inBareCaseStatement}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(e=!1){let t=0;return this.options.annexB&&!this.state.strict&&(t|=4,e&&(t|=8)),this.parseStatementLike(t)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(e){let t=null;return this.match(22)&&(t=this.parseDecorators(!0)),this.parseStatementContent(e,t)}parseStatementContent(e,t){let n=this.state.type,r=this.startNode(),i=!!(e&2),a=!!(e&4),o=e&1;switch(n){case 56:return this.parseBreakContinueStatement(r,!0);case 59:return this.parseBreakContinueStatement(r,!1);case 60:return this.parseDebuggerStatement(r);case 86:return this.parseDoWhileStatement(r);case 87:return this.parseForStatement(r);case 64:if(this.lookaheadCharCode()===46)break;return a||this.raise(this.state.strict?G.StrictFunction:this.options.annexB?G.SloppyFunctionAnnexB:G.SloppyFunction,this.state.startLoc),this.parseFunctionStatement(r,!1,!i&&a);case 76:return i||this.unexpected(),this.parseClass(this.maybeTakeDecorators(t,r),!0);case 65:return this.parseIfStatement(r);case 66:return this.parseReturnStatement(r);case 67:return this.parseSwitchStatement(r);case 68:return this.parseThrowStatement(r);case 69:return this.parseTryStatement(r);case 92:if(this.isAwaitUsing())return this.allowsUsing()?i?this.recordAwaitIfAllowed()||this.raise(G.AwaitUsingNotInAsyncContext,r):this.raise(G.UnexpectedLexicalDeclaration,r):this.raise(G.UnexpectedUsingDeclaration,r),this.next(),this.parseVarStatement(r,`await using`);break;case 103:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifierOrBrace())break;return this.allowsUsing()?i||this.raise(G.UnexpectedLexicalDeclaration,this.state.startLoc):this.raise(G.UnexpectedUsingDeclaration,this.state.startLoc),this.parseVarStatement(r,`using`);case 96:{if(this.state.containsEsc)break;let e=this.nextTokenStart(),t=this.codePointAtPos(e);if(t!==91&&(!i&&this.hasFollowingLineBreak()||!this.chStartsBindingIdentifier(t,e)&&t!==123))break}case 71:i||this.raise(G.UnexpectedLexicalDeclaration,this.state.startLoc);case 70:{let e=this.state.value;return this.parseVarStatement(r,e)}case 88:return this.parseWhileStatement(r);case 72:return this.parseWithStatement(r);case 2:return this.parseBlock();case 9:return this.parseEmptyStatement(r);case 79:{let e=this.lookaheadCharCode();if(e===40||e===46)break}case 78:{!(this.optionFlags&8)&&!o&&this.raise(G.UnexpectedImportExport,this.state.startLoc),this.next();let e;return e=n===79?this.parseImport(r):this.parseExport(r,t),this.assertModuleNodeAllowed(e),e}default:if(this.isAsyncFunction())return i||this.raise(G.AsyncFunctionInSingleStatementContext,this.state.startLoc),this.next(),this.parseFunctionStatement(r,!0,!i&&a)}let s=this.state.value,c=this.parseExpression();return sd(n)&&c.type===`Identifier`&&this.eat(10)?this.parseLabeledStatement(r,s,c,e):this.parseExpressionStatement(r,c)}assertModuleNodeAllowed(e){!(this.optionFlags&8)&&!this.inModule&&this.raise(G.ImportOutsideModule,e)}maybeTakeDecorators(e,t,n){return e&&(t.decorators?.length?(this.raise(G.DecoratorsBeforeAfterExport,t.decorators[0]),t.decorators.unshift(...e)):t.decorators=e,this.resetStartLocationFromNode(t,e[0]),n&&this.resetStartLocationFromNode(n,t)),t}canHaveLeadingDecorator(){return this.match(76)}parseDecorators(e){let t=[];do t.push(this.parseDecorator());while(this.match(22));if(this.match(78))e||this.unexpected();else if(!this.canHaveLeadingDecorator())throw this.raise(G.UnexpectedLeadingDecorator,this.state.startLoc);return t}parseDecorator(){this.expectOnePlugin([`decorators`,`decorators-legacy`]);let e=this.startNode();if(this.next(),this.hasPlugin(`decorators`)){let t=this.state.startLoc,n;if(this.match(6)){let t=this.state.startLoc;this.next(),n=this.parseExpression(),this.expect(7),n=this.wrapParenthesis(t,n);let r=this.state.startLoc;e.expression=this.parseMaybeDecoratorArguments(n,t),e.expression!==n&&this.raise(G.DecoratorArgumentsOutsideParentheses,r)}else{for(n=this.parseIdentifier(!1);this.eat(12);){let e=this.startNodeAt(t);e.object=n,this.match(134)?(this.classScope.usePrivateName(this.state.value,this.state.startLoc),e.property=this.parsePrivateName()):e.property=this.parseIdentifier(!0),e.computed=!1,n=this.finishNode(e,`MemberExpression`)}e.expression=this.parseMaybeDecoratorArguments(n,t)}}else this.state.canStartArrow=!1,e.expression=this.parseExprSubscripts();return this.finishNode(e,`Decorator`)}parseMaybeDecoratorArguments(e,t){if(this.eat(6)){let n=this.startNodeAt(t);return n.callee=e,n.arguments=this.parseCallExpressionArguments(),this.toReferencedList(n.arguments),this.finishNode(n,`CallExpression`)}return e}parseBreakContinueStatement(e,t){return this.next(),this.isLineTerminator()?e.label=null:(e.label=this.parseIdentifier(),this.semicolon()),this.verifyBreakContinue(e,t),this.finishNode(e,t?`BreakStatement`:`ContinueStatement`)}verifyBreakContinue(e,t){let n=0;for(;n<this.state.labels.length;++n){let r=this.state.labels[n];if((e.label==null||r.name===e.label.name)&&(r.kind!=null&&(t||r.kind===1)||e.label&&t))break}if(n===this.state.labels.length){let n=t?`BreakStatement`:`ContinueStatement`;this.raise(G.IllegalBreakContinue,e,{type:n})}}parseDebuggerStatement(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)}parseHeaderExpression(){this.expect(6);let e=this.parseExpression();return this.expect(7),e}parseDoWhileStatement(e){return this.next(),this.state.labels.push(op),e.body=this.parseStatement(),this.state.labels.pop(),this.expect(88),e.test=this.parseHeaderExpression(),this.eat(9),this.finishNode(e,`DoWhileStatement`)}parseForStatement(e){this.next(),this.state.labels.push(op);let t=null;if(this.isContextual(92)&&this.recordAwaitIfAllowed()&&(t=this.state.startLoc,this.next()),this.scope.enter(0),this.expect(6),this.match(9))return t!==null&&this.unexpected(t),this.parseFor(e,null);let n=this.isContextual(96);{let r=this.isAwaitUsing(),i=r||this.isForUsing(),a=n&&this.hasFollowingBindingAtom()||i;if(this.match(70)||this.match(71)||a){let n=this.startNode(),a;r?(a=`await using`,this.recordAwaitIfAllowed()||this.raise(G.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):a=this.state.value,this.next(),this.parseVar(n,!0,a);let o=this.finishNode(n,`VariableDeclaration`),s=this.match(54);return s&&i&&this.raise(G.ForInUsing,o),(s||this.isContextual(98))&&o.declarations.length===1?this.parseForX(e,o,t):(t!==null&&this.unexpected(t),this.parseFor(e,o))}}let r=this.isContextual(91),i=new $f,a=this.parseExpression(!0,i),o=this.isContextual(98);if(o&&(n&&this.raise(G.ForOfLet,a),t===null&&r&&a.type===`Identifier`&&this.raise(G.ForOfAsync,a)),o||this.match(54)){this.checkDestructuringPrivate(i),this.toAssignable(a,!0);let n=o?`ForOfStatement`:`ForInStatement`;return this.checkLVal(a,{type:n}),this.parseForX(e,a,t)}return this.checkExpressionErrors(i,!0),t!==null&&this.unexpected(t),this.parseFor(e,a)}parseFunctionStatement(e,t,n){return this.next(),this.parseFunction(e,1|(n?2:0)|(t?8:0))}parseIfStatement(e){return this.next(),e.test=this.parseHeaderExpression(),e.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),e.alternate=this.eat(62)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(e,`IfStatement`)}parseReturnStatement(e){return this.prodParam.hasReturn||this.raise(G.IllegalReturn,this.state.startLoc),this.next(),this.isLineTerminator()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)}parseSwitchStatement(e){this.next(),e.discriminant=this.parseHeaderExpression();let t=e.cases=[];this.expect(2),this.state.labels.push(sp),this.scope.enter(256);let n;for(let e;!this.match(4);)if(this.match(57)||this.match(61)){let r=this.match(57);n&&this.finishNode(n,`SwitchCase`),t.push(n=this.startNode()),n.consequent=[],this.next(),r?n.test=this.parseExpression():(e&&this.raise(G.MultipleDefaultsInSwitch,this.state.lastTokStartLoc),e=!0,n.test=null),this.expect(10)}else n?n.consequent.push(this.parseStatementListItem()):this.unexpected();return this.scope.exit(),n&&this.finishNode(n,`SwitchCase`),this.next(),this.state.labels.pop(),this.finishNode(e,`SwitchStatement`)}parseThrowStatement(e){return this.next(),this.hasPrecedingLineBreak()&&this.raise(G.NewlineAfterThrow,this.state.lastTokEndLoc),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)}parseCatchClauseParam(){let e=this.parseBindingAtom();return this.scope.enter(this.options.annexB&&e.type===`Identifier`?8:0),this.checkLVal(e,{type:`CatchClause`},9),e}parseTryStatement(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.match(58)){let t=this.startNode();this.next(),this.match(6)?(this.expect(6),t.param=this.parseCatchClauseParam(),this.expect(7)):(t.param=null,this.scope.enter(0)),t.body=this.parseBlock(!1,!1),this.scope.exit(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(63)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(G.NoCatchOrFinally,e),this.finishNode(e,`TryStatement`)}parseVarStatement(e,t,n=!1){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)}parseWhileStatement(e){return this.next(),e.test=this.parseHeaderExpression(),this.state.labels.push(op),e.body=this.parseStatement(),this.state.labels.pop(),this.finishNode(e,`WhileStatement`)}parseWithStatement(e){return this.state.strict&&this.raise(G.StrictWith,this.state.startLoc),this.next(),e.object=this.parseHeaderExpression(),e.body=this.parseStatement(),this.finishNode(e,`WithStatement`)}parseEmptyStatement(e){return this.next(),this.finishNode(e,`EmptyStatement`)}parseLabeledStatement(e,t,n,r){for(let e of this.state.labels)e.name===t&&this.raise(G.LabelRedeclaration,n,{labelName:t});let i=hd(this.state.type)?1:this.match(67)?2:null;for(let t=this.state.labels.length-1;t>=0;t--){let n=this.state.labels[t];if(n.statementStart===e.start)n.statementStart=this.sourceToOffsetPos(this.state.start),n.kind=i;else break}return this.state.labels.push({name:t,kind:i,statementStart:this.sourceToOffsetPos(this.state.start)}),e.body=r&8?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)}parseExpressionStatement(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)}parseBlock(e=!1,t=!0,n){let r=this.startNode();return e&&this.state.strictErrors.clear(),this.expect(2),t&&this.scope.enter(0),this.parseBlockBody(r,e,!1,4,n),t&&this.scope.exit(),this.finishNode(r,`BlockStatement`)}isValidDirective(e){return e.type===`ExpressionStatement`&&e.expression.type===`StringLiteral`&&!e.expression.extra.parenthesized}parseBlockBody(e,t,n,r,i){let a=e.body=[],o=e.directives=[];this.parseBlockOrModuleBlockBody(a,t?o:void 0,n,r,i)}parseBlockOrModuleBlockBody(e,t,n,r,i){let a=this.state.strict,o=!1,s=!1;for(;!this.match(r);){let r=n?this.parseModuleItem():this.parseStatementListItem();if(t&&!s){if(this.isValidDirective(r)){let e=this.stmtToDirective(r);t.push(e),!o&&e.value.value===`use strict`&&(o=!0,this.setStrict(!0));continue}s=!0,this.state.strictErrors.clear()}e.push(r)}i?.call(this,o),a||this.setStrict(!1),this.next()}parseFor(e,t){return e.init=t,this.semicolon(!1),e.test=this.match(9)?null:this.parseExpression(),this.semicolon(!1),e.update=this.match(7)?null:this.parseExpression(),this.expect(7),e.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(e,`ForStatement`)}parseForX(e,t,n){let r=this.match(54);return this.next(),r?n!==null&&this.unexpected(n):e.await=n!==null,t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!r||!this.options.annexB||this.state.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(G.ForInOfLoopInitializer,t,{type:r?`ForInStatement`:`ForOfStatement`}),t.type===`AssignmentPattern`&&this.raise(G.InvalidLhs,t,{ancestor:{type:`ForStatement`}}),e.left=t,e.right=r?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(7),e.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(e,r?`ForInStatement`:`ForOfStatement`)}parseVar(e,t,n,r=!1){let i=e.declarations=[];for(e.kind=n;;){let e=this.startNode();if(this.parseVarId(e,n),e.init=this.eat(25)?t?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn():null,e.init===null&&!r&&(e.id.type!==`Identifier`&&!(t&&(this.match(54)||this.isContextual(98)))?this.raise(G.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:`destructuring`}):(n===`const`||n===`using`||n===`await using`)&&!(this.match(54)||this.isContextual(98))&&this.raise(G.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:n})),i.push(this.finishNode(e,`VariableDeclarator`)),!this.eat(8))break}return e}parseVarId(e,t){let n=this.parseBindingAtom();t===`using`||t===`await using`?(n.type===`ArrayPattern`||n.type===`ObjectPattern`)&&this.raise(G.UsingDeclarationHasBindingPattern,n):n.type===`VoidPattern`&&this.raise(G.UnexpectedVoidPattern,n),this.checkLVal(n,{type:`VariableDeclarator`},t===`var`?5:8201),e.id=n}parseAsyncFunctionExpression(e){return this.parseFunction(e,8)}parseFunction(e,t=0){let n=t&2,r=!!(t&1),i=r&&!(t&4),a=!!(t&8);return this.initFunction(e,a),this.match(51)&&(n&&this.raise(G.GeneratorInSingleStatementContext,this.state.startLoc),this.next(),e.generator=!0),r&&(e.id=this.parseFunctionId(i)),this.scope.enter(514),this.prodParam.enter(Zf(a,e.generator)),r||(e.id=this.parseFunctionId()),this.parseFunctionParams(e,!1),this.parseFunctionBodyAndFinish(e,r?`FunctionDeclaration`:`FunctionExpression`),this.prodParam.exit(),this.scope.exit(),r&&!n&&this.registerFunctionStatementId(e),e}parseFunctionId(e){return e||sd(this.state.type)?this.parseIdentifier():null}parseFunctionParams(e,t){this.expect(6),this.expressionScope.enter(Kf()),e.params=this.parseBindingList(7,41,2|(t?4:0)),this.expressionScope.exit()}registerFunctionStatementId(e){e.id&&this.scope.declareName(e.id.name,!this.options.annexB||this.state.strict||e.generator||e.async?this.scope.treatFunctionsAsVar?5:8201:17,e.id.start)}parseClass(e,t,n){this.next();let r=this.state.strict;return this.state.strict=!0,this.parseClassId(e,t,n),this.parseClassSuper(e),e.body=this.parseClassBody(!!e.superClass,r),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)}isClassProperty(){return this.match(25)||this.match(9)||this.match(4)}isClassMethod(){return this.match(6)}nameIsConstructor(e){return e.type===`Identifier`&&e.name===`constructor`||e.type===`StringLiteral`&&e.value===`constructor`}isNonstaticConstructor(e){return!e.computed&&!e.static&&this.nameIsConstructor(e.key)}parseClassBody(e,t){this.classScope.enter();let n={hadConstructor:!1,hadSuperClass:e},r=[],i=this.startNode();for(i.body=[],this.expect(2);!this.match(4);){if(this.eat(9)){if(r.length>0)throw this.raise(G.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(22)){r.push(this.parseDecorator());continue}let e=this.startNode();r.length&&(e.decorators=r,this.resetStartLocationFromNode(e,r[0]),r=[]),this.parseClassMember(i,e,n)}if(this.state.strict=t,this.next(),r.length)throw this.raise(G.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(i,`ClassBody`)}parseClassMemberFromModifier(e,t){let n=this.parseIdentifier(!0);if(this.isClassMethod()){let r=t;return r.kind=`method`,r.computed=!1,r.key=n,r.static=!1,this.pushClassMethod(e,r,!1,!1,!1,!1),!0}if(this.isClassProperty()){let r=t;return r.computed=!1,r.key=n,r.static=!1,e.body.push(this.parseClassProperty(r)),!0}return this.resetPreviousNodeTrailingComments(n),!1}parseClassMember(e,t,n){let r=this.isContextual(102);if(r){if(this.parseClassMemberFromModifier(e,t))return;if(this.eat(2)){this.parseClassStaticBlock(e,t);return}}this.parseClassMemberWithIsStatic(e,t,n,r)}parseClassMemberWithIsStatic(e,t,n,r){let i=t,a=t,o=t,s=t,c=t,l=i,u=i;if(t.static=r,this.parsePropertyNamePrefixOperator(t),this.eat(51)){l.kind=`method`;let t=this.match(134);if(this.parseClassElementName(l),this.parsePostMemberNameModifiers(l),t){this.pushClassPrivateMethod(e,a,!0,!1);return}this.isNonstaticConstructor(i)&&this.raise(G.ConstructorIsGenerator,i.key),this.pushClassMethod(e,i,!0,!1,!1,!1);return}let d=!this.state.containsEsc&&sd(this.state.type),f=this.parseClassElementName(t),p=d?f.name:null,m=this.isPrivateName(f),h=this.state.startLoc;if(this.parsePostMemberNameModifiers(u),this.isClassMethod()){if(l.kind=`method`,m){this.pushClassPrivateMethod(e,a,!1,!1);return}let r=this.isNonstaticConstructor(i),o=!1;r&&(i.kind=`constructor`,i.decorators&&i.decorators.length>0&&this.raise(G.DecoratorConstructor,t),n.hadConstructor&&!this.hasPlugin(`typescript`)&&this.raise(G.DuplicateConstructor,f),r&&this.hasPlugin(`typescript`)&&t.override&&this.raise(G.OverrideOnConstructor,f),n.hadConstructor=!0,o=n.hadSuperClass),this.pushClassMethod(e,i,!1,!1,r,o)}else if(this.isClassProperty())m?this.pushClassPrivateProperty(e,s):this.pushClassProperty(e,o);else if(p===`async`&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(f);let t=this.eat(51);u.optional&&this.unexpected(h),l.kind=`method`;let n=this.match(134);this.parseClassElementName(l),this.parsePostMemberNameModifiers(u),n?this.pushClassPrivateMethod(e,a,t,!0):(this.isNonstaticConstructor(i)&&this.raise(G.ConstructorIsAsync,i.key),this.pushClassMethod(e,i,t,!0,!1,!1))}else if((p===`get`||p===`set`)&&!(this.match(51)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(f),l.kind=p;let t=this.match(134);this.parseClassElementName(i),t?this.pushClassPrivateMethod(e,a,!1,!1):(this.isNonstaticConstructor(i)&&this.raise(G.ConstructorIsAccessor,i.key),this.pushClassMethod(e,i,!1,!1,!1,!1)),this.checkGetterSetterParams(i)}else if(p===`accessor`&&!this.isLineTerminator()){this.expectPlugin(`decoratorAutoAccessors`),this.resetPreviousNodeTrailingComments(f);let t=this.match(134);this.parseClassElementName(o),this.pushClassAccessorProperty(e,c,t)}else this.isLineTerminator()?m?this.pushClassPrivateProperty(e,s):this.pushClassProperty(e,o):this.unexpected()}parseClassElementName(e){let{type:t,value:n}=this.state;if((t===128||t===130)&&e.static&&n===`prototype`&&this.raise(G.StaticPrototype,this.state.startLoc),t===134){n===`constructor`&&this.raise(G.ConstructorClassPrivateField,this.state.startLoc);let t=this.parsePrivateName();return e.key=t,t}return this.parsePropertyName(e),e.key}parseClassStaticBlock(e,t){this.scope.enter(720);let n=this.state.labels;this.state.labels=[],this.prodParam.enter(0);let r=t.body=[];this.parseBlockOrModuleBlockBody(r,void 0,!1,4),this.prodParam.exit(),this.scope.exit(),this.state.labels=n,e.body.push(this.finishNode(t,`StaticBlock`)),t.decorators?.length&&this.raise(G.DecoratorStaticBlock,t)}pushClassProperty(e,t){!t.computed&&this.nameIsConstructor(t.key)&&this.raise(G.ConstructorClassField,t.key),e.body.push(this.parseClassProperty(t))}pushClassPrivateProperty(e,t){let n=this.parseClassPrivateProperty(t);e.body.push(n),this.classScope.declarePrivateName(this.getPrivateNameSV(n.key),0,n.key.start)}pushClassAccessorProperty(e,t,n){!n&&!t.computed&&this.nameIsConstructor(t.key)&&this.raise(G.ConstructorClassField,t.key);let r=this.parseClassAccessorProperty(t);e.body.push(r),n&&this.classScope.declarePrivateName(this.getPrivateNameSV(r.key),0,r.key.start)}pushClassMethod(e,t,n,r,i,a){e.body.push(this.parseMethod(t,n,r,i,a,`ClassMethod`,!0))}pushClassPrivateMethod(e,t,n,r){let i=this.parseMethod(t,n,r,!1,!1,`ClassPrivateMethod`,!0);e.body.push(i);let a=i.kind===`get`?i.static?6:2:i.kind===`set`?i.static?5:1:0;this.declareClassPrivateMethodInScope(i,a)}declareClassPrivateMethodInScope(e,t){this.classScope.declarePrivateName(this.getPrivateNameSV(e.key),t,e.key.start)}parsePostMemberNameModifiers(e){}parseClassPrivateProperty(e){return this.parseInitializer(e),this.semicolon(),this.finishNode(e,`ClassPrivateProperty`)}parseClassProperty(e){return this.parseInitializer(e),this.semicolon(),this.finishNode(e,`ClassProperty`)}parseClassAccessorProperty(e){return this.parseInitializer(e),this.semicolon(),this.finishNode(e,`ClassAccessorProperty`)}parseInitializer(e){this.scope.enter(592),this.expressionScope.enter(Yf()),this.prodParam.enter(0),e.value=this.eat(25)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(e,t,n,r=8331){if(sd(this.state.type))e.id=this.parseIdentifier(),t&&this.declareNameFromIdentifier(e.id,r);else if(n||!t)e.id=null;else throw this.raise(G.MissingClassName,this.state.startLoc)}parseClassSuper(e){this.eat(77)?(this.state.canStartArrow=!1,e.superClass=this.parseExprSubscripts()):e.superClass=null}parseExport(e,t){let n=this.parseMaybeImportPhase(e,!0),r=this.maybeParseExportDefaultSpecifier(e,n),i=!r||this.eat(8),a=i&&this.eatExportStar(e),o=a&&this.maybeParseExportNamespaceSpecifier(e),s=i&&(!o||this.eat(8)),c=r||a;if(a&&!o){if(r&&this.unexpected(),t)throw this.raise(G.UnsupportedDecoratorExport,e);return this.parseExportFrom(e,!0),this.sawUnambiguousESM=!0,this.finishNode(e,`ExportAllDeclaration`)}let l=this.maybeParseExportNamedSpecifiers(e);r&&i&&!a&&!l&&this.unexpected(null,2),o&&s&&this.unexpected(null,94);let u;if(c||l){if(u=!1,t)throw this.raise(G.UnsupportedDecoratorExport,e);this.parseExportFrom(e,c)}else u=this.maybeParseExportDeclaration(e);if(c||l||u){let n=e;if(this.checkNamedExport(n,!!n.source),n.declaration?.type===`ClassDeclaration`)this.maybeTakeDecorators(t,n.declaration,n);else if(t)throw this.raise(G.UnsupportedDecoratorExport,e);return this.sawUnambiguousESM=!0,this.finishNode(n,`ExportNamedDeclaration`)}if(this.eat(61)){let n=e,r=this.parseExportDefaultExpression();if(n.declaration=r,r.type===`ClassDeclaration`)this.maybeTakeDecorators(t,r,n);else if(t)throw this.raise(G.UnsupportedDecoratorExport,e);return this.checkDuplicateExports(e,`default`),this.hasPlugin(`exportDefaultFrom`)&&r.type===`Identifier`&&r.name===`from`&&r.end-r.start===4&&!r.extra?.parenthesized&&this.raise(G.ExportDefaultFromAsIdentifier,r),this.sawUnambiguousESM=!0,this.finishNode(n,`ExportDefaultDeclaration`)}throw this.unexpected(null,2)}eatExportStar(e){return this.eat(51)}maybeParseExportDefaultSpecifier(e,t){if(t||this.isExportDefaultSpecifier()){this.expectPlugin(`exportDefaultFrom`,t?.start);let n=t||this.parseIdentifier(!0),r=this.startNodeAtNode(n);return r.exported=n,e.specifiers=[this.finishNode(r,`ExportDefaultSpecifier`)],!0}return!1}maybeParseExportNamespaceSpecifier(e){if(this.isContextual(89)){e.specifiers??=[];let t=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),t.exported=this.parseModuleExportName(),e.specifiers.push(this.finishNode(t,`ExportNamespaceSpecifier`)),!0}return!1}maybeParseExportNamedSpecifiers(e){if(this.match(2)){let t=e;t.specifiers||=[];let n=t.exportKind===`type`;return t.specifiers.push(...this.parseExportSpecifiers(n)),t.source=null,t.attributes=[],t.declaration=null,!0}return!1}maybeParseExportDeclaration(e){return this.shouldParseExportDeclaration()?(e.specifiers=[],e.source=null,e.attributes=[],e.declaration=this.parseExportDeclaration(e),!0):!1}isAsyncFunction(){if(!this.isContextual(91))return!1;let e=this.nextTokenInLineStart();return this.isUnparsedContextual(e,`function`)}parseExportDefaultExpression(){let e=this.startNode();if(this.match(64))return this.next(),this.parseFunction(e,5);if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(e,13);if(this.match(76))return this.parseClass(e,!0,!0);if(this.match(22))return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(71)||this.match(70)||this.isLet()||this.isUsing()||this.isAwaitUsing())throw this.raise(G.UnsupportedDefaultExport,this.state.startLoc);let t=this.parseMaybeAssignAllowIn();return this.semicolon(),t}parseExportDeclaration(e){return this.match(76)?this.parseClass(this.startNode(),!0,!1):this.parseStatementListItem()}isExportDefaultSpecifier(){let{type:e}=this.state;if(sd(e)){if(e===91&&!this.state.containsEsc||e===96)return!1;if((e===126||e===125)&&!this.state.containsEsc){let e=this.nextTokenStart(),t=this.input.charCodeAt(e);if(t===123||this.chStartsBindingIdentifier(t,e)&&!this.input.startsWith(`from`,e))return this.expectOnePlugin([`flow`,`typescript`]),!1}}else if(!this.match(61))return!1;let t=this.nextTokenStart(),n=this.isUnparsedContextual(t,`from`);if(this.input.charCodeAt(t)===44||sd(this.state.type)&&n)return!0;if(this.match(61)&&n){let e=this.input.charCodeAt(this.nextTokenStartSince(t+4));return e===34||e===39}return!1}parseExportFrom(e,t){this.eatContextual(94)?(e.source=this.parseImportSource(),this.maybeParseImportAttributes(e)):t&&this.unexpected(),this.semicolon()}shouldParseExportDeclaration(){let{type:e}=this.state;return e===22&&(this.expectOnePlugin([`decorators`,`decorators-legacy`]),this.hasPlugin(`decorators`))?!0:this.isUsing()||this.isAwaitUsing()?(this.raise(G.UsingDeclarationExport,this.state.startLoc),!0):e===70||e===71||e===64||e===76||this.isLet()||this.isAsyncFunction()}checkNamedExport(e,t){if(e.specifiers?.length)for(let n of e.specifiers){let{exported:e}=n,r=e.type===`Identifier`?e.name:e.value;if(this.checkDuplicateExports(n,r),!t&&n.type===`ExportSpecifier`){let{local:e}=n;e.type===`Identifier`?(this.checkReservedWord(e.name,e.start,!0,!1),this.scope.checkLocalExport(e)):this.raise(G.ExportBindingIsString,n,{localName:e.value,exportName:r})}}else if(e.declaration){let t=e.declaration;if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let{id:n}=t;if(!n)throw Error(`Assertion failure`);this.checkDuplicateExports(e,n.name)}else if(t.type===`VariableDeclaration`)for(let e of t.declarations)this.checkDeclaration(e.id)}}checkDeclaration(e){if(e.type===`Identifier`)this.checkDuplicateExports(e,e.name);else if(e.type===`ObjectPattern`)for(let t of e.properties)this.checkDeclaration(t);else if(e.type===`ArrayPattern`)for(let t of e.elements)t&&this.checkDeclaration(t);else e.type===`ObjectProperty`?this.checkDeclaration(e.value):e.type===`RestElement`?this.checkDeclaration(e.argument):e.type===`AssignmentPattern`&&this.checkDeclaration(e.left)}checkDuplicateExports(e,t){this.exportedIdentifiers.has(t)&&(t==="default"?this.raise(G.DuplicateDefaultExport,e):this.raise(G.DuplicateExport,e,{exportName:t})),this.exportedIdentifiers.add(t)}parseExportSpecifiers(e){let t=[],n=!0;for(this.expect(2);!this.eat(4);){if(n)n=!1;else if(this.expect(8),this.eat(4))break;let r=this.isContextual(126),i=this.match(130),a=this.startNode();a.local=this.parseModuleExportName(),t.push(this.parseExportSpecifier(a,i,e,r))}return t}parseExportSpecifier(e,t,n,r){return this.eatContextual(89)?e.exported=this.parseModuleExportName():t?e.exported=this.cloneStringLiteral(e.local):e.exported||=this.cloneIdentifier(e.local),this.finishNode(e,`ExportSpecifier`)}parseModuleExportName(){if(this.match(130)){let e=this.parseStringLiteral(this.state.value),t=cp.exec(e.value);return t&&this.raise(G.ModuleExportNameHasLoneSurrogate,e,{surrogateCharCode:t[0].charCodeAt(0)}),e}return this.parseIdentifier(!0)}checkImportPhase(e){let{specifiers:t}=e,n=t.length===1?t[0].type:null;e.phase===`source`?n!==`ImportDefaultSpecifier`&&this.raise(G.SourcePhaseImportRequiresDefault,t[0]):e.phase===`defer`&&n!==`ImportNamespaceSpecifier`&&this.raise(G.DeferImportRequiresNamespace,t[0])}isPotentialImportPhase(e){return e?!1:this.isContextual(101)||this.isContextual(93)}applyImportPhase(e,t,n,r){t||(n===`source`?(this.expectPlugin(`sourcePhaseImports`,r),e.phase=`source`):n===`defer`?(this.expectPlugin(`deferredImportEvaluation`,r),e.phase=`defer`):this.hasPlugin(`sourcePhaseImports`)&&(e.phase=null))}parseMaybeImportPhase(e,t){if(!this.isPotentialImportPhase(t))return this.applyImportPhase(e,t,null),null;let n=this.startNode(),r=this.parseIdentifierName(!0),{type:i}=this.state;return(ld(i)?i!==94||this.lookaheadCharCode()===102:i!==8)?(this.applyImportPhase(e,t,r,n.start),null):(this.applyImportPhase(e,t,null),this.createIdentifier(n,r))}isPrecedingIdImportPhase(e){let{type:t}=this.state;return sd(t)?t!==94||this.lookaheadCharCode()===102:t!==8}parseImport(e){return this.match(130)?this.parseImportSourceAndAttributes(e):this.parseImportSpecifiersAndAfter(e,this.parseMaybeImportPhase(e,!1))}parseImportSpecifiersAndAfter(e,t){e.specifiers=[];let n=!this.maybeParseDefaultImportSpecifier(e,t)||this.eat(8),r=n&&this.maybeParseStarImportSpecifier(e);return n&&!r&&this.parseNamedImportSpecifiers(e),this.expectContextual(94),this.parseImportSourceAndAttributes(e)}parseImportSourceAndAttributes(e){return e.specifiers??=[],e.source=this.parseImportSource(),this.maybeParseImportAttributes(e),this.checkImportPhase(e),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(e,`ImportDeclaration`)}parseImportSource(){return this.match(130)||this.unexpected(),this.parseExprAtom()}parseImportSpecifierLocal(e,t,n){t.local=this.parseIdentifier(),e.specifiers.push(this.finishImportSpecifier(t,n))}finishImportSpecifier(e,t,n=8201){return this.checkLVal(e.local,{type:t},n),this.finishNode(e,t)}parseImportAttributes(){this.expect(2);let e=[],t=new Set;do{if(this.match(4))break;let n=this.startNode(),r=this.state.value;if(t.has(r)&&this.raise(G.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:r}),t.add(r),n.key=this.match(130)?this.parseStringLiteral(r):this.parseIdentifier(!0),this.expect(10),!this.match(130))throw this.raise(G.ModuleAttributeInvalidValue,this.state.startLoc);n.value=this.parseStringLiteral(this.state.value),e.push(this.finishNode(n,`ImportAttribute`))}while(this.eat(8));return this.expect(4),e}maybeParseImportAttributes(e){let t;if(this.match(72)){if(this.hasPrecedingLineBreak()&&this.lookaheadCharCode()===40)return;this.next(),t=this.parseImportAttributes()}else t=[];e.attributes=t}maybeParseDefaultImportSpecifier(e,t){if(t){let n=this.startNodeAtNode(t);return n.local=t,e.specifiers.push(this.finishImportSpecifier(n,`ImportDefaultSpecifier`)),!0}return ld(this.state.type)?(this.parseImportSpecifierLocal(e,this.startNode(),`ImportDefaultSpecifier`),!0):!1}maybeParseStarImportSpecifier(e){if(this.match(51)){let t=this.startNode();return this.next(),this.expectContextual(89),this.parseImportSpecifierLocal(e,t,`ImportNamespaceSpecifier`),!0}return!1}parseNamedImportSpecifiers(e){let t=!0;for(this.expect(2);!this.eat(4);){if(t)t=!1;else{if(this.eat(10))throw this.raise(G.DestructureNamedImport,this.state.startLoc);if(this.expect(8),this.eat(4))break}let n=this.startNode(),r=this.match(130),i=this.isContextual(126);n.imported=this.parseModuleExportName();let a=this.parseImportSpecifier(n,r,e.importKind===`type`||e.importKind===`typeof`,i,void 0);e.specifiers.push(a)}}parseImportSpecifier(e,t,n,r,i){if(this.eatContextual(89))e.local=this.parseIdentifier();else{let{imported:n}=e;if(t)throw this.raise(G.ImportBindingIsString,e,{importName:n.value});this.checkReservedWord(n.name,e.start,!0,!0),e.local||=this.cloneIdentifier(n)}return this.finishImportSpecifier(e,`ImportSpecifier`,i)}isThisParam(e){return e.type===`Identifier`&&e.name===`this`}},fp=/in(?:stanceof)?|as|satisfies/y;function pp(e){if(e==null)throw Error(`Unexpected ${e} value.`);return e}function mp(e){if(!e)throw Error(`Assert fail`)}var q=Lu`typescript`({AbstractMethodHasImplementation:({methodName:e})=>`Method '${e}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:e})=>`Property '${e}' cannot have an initializer because it is marked abstract.`,AccessorCannotBeOptional:`An 'accessor' property cannot be declared optional.`,AccessorCannotDeclareThisParameter:`'get' and 'set' accessors cannot declare 'this' parameters.`,AccessorCannotHaveTypeParameters:`An accessor cannot have type parameters.`,ClassMethodHasDeclare:`Class methods cannot have the 'declare' modifier.`,ClassMethodHasReadonly:`Class methods cannot have the 'readonly' modifier.`,ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference:`A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.`,ConstructorHasTypeParameters:`Type parameters cannot appear on a constructor declaration.`,DeclaratorDefiniteAssertionRequiresTypeAnnotation:`Declarations with definite assignment assertions must also have type annotations.`,DeclaratorDefiniteAssertionWithInitializer:`Declarations with initializers cannot also have definite assignment assertions.`,DeclareAccessor:({kind:e})=>`'declare' is not allowed in ${e}ters.`,DeclareClassFieldHasInitializer:`Initializers are not allowed in ambient contexts.`,DeclareFunctionHasImplementation:`An implementation cannot be declared in ambient contexts.`,DecoratorAbstractMethod:({kind:e})=>`Decorators can't be used with ${e.startsWith(`a`)?`an`:`a`} ${e}.`,DuplicateAccessibilityModifier:({modifier:e})=>`Accessibility modifier already seen: '${e}'.`,DuplicateModifier:({modifier:e})=>`Duplicate modifier: '${e}'.`,EmptyHeritageClauseType:({token:e})=>`'${e}' list cannot be empty.`,EmptyNamespaceName:`Namespace must be given a name.`,EmptyTypeArguments:`Type argument list cannot be empty.`,EmptyTypeParameters:`Type parameter list cannot be empty.`,ExpectedAmbientAfterExportDeclare:`'export declare' must be followed by an ambient declaration.`,ExportAssignmentInTSNamespace:`An export assignment cannot be used in a namespace.`,ExportInTSNamespace:`Export declarations are not permitted in a namespace.`,ImportAliasHasImportType:`An import alias can not use 'import type'.`,ImportInTSNamespace:`Import declarations in a namespace cannot reference a module.`,IncompatibleModifiers:({modifiers:e})=>`'${e[0]}' modifier cannot be used with '${e[1]}' modifier.`,IndexSignatureHasAbstract:`Index signatures cannot have the 'abstract' modifier.`,IndexSignatureHasAccessibility:({modifier:e})=>`Index signatures cannot have an accessibility modifier ('${e}').`,IndexSignatureHasDeclare:`Index signatures cannot have the 'declare' modifier.`,IndexSignatureHasOverride:`'override' modifier cannot appear on an index signature.`,IndexSignatureHasStatic:`Index signatures cannot have the 'static' modifier.`,InitializerNotAllowedInAmbientContext:`Initializers are not allowed in ambient contexts.`,InlineModuleDeclarationMustUseString:"`module ... {}` declarations must have a string name. Use `namespace ... {}` instead.",InvalidHeritageClauseType:({token:e})=>`'${e}' list can only include identifiers or qualified-names with optional type arguments.`,InvalidModifierOnAwaitUsingDeclaration:e=>`'${e}' modifier cannot appear on an await using declaration.`,InvalidModifierOnTypeMember:({modifier:e})=>`'${e}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:e})=>`'${e}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:e})=>`'${e}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifierOnUsingDeclaration:e=>`'${e}' modifier cannot appear on a using declaration.`,InvalidModifiersOrder:({orderedModifiers:e})=>`'${e[0]}' modifier must precede '${e[1]}' modifier.`,InvalidNamespaceName:e=>`Namespace name cannot be '${e}'.`,InvalidPropertyAccessAfterInstantiationExpression:`Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.`,InvalidTupleMemberLabel:`Tuple members must be labeled with a simple identifier.`,MissingInterfaceName:`'interface' declarations must be followed by an identifier.`,NamespaceExportInTSNamespace:`Global module exports may only appear at top level.`,NonAbstractClassHasAbstractMethod:`Abstract methods can only appear within an abstract class.`,NonClassMethodPropertyHasAbstractModifier:`'abstract' modifier can only appear on a class, method, or property declaration.`,OptionalTypeBeforeRequired:`A required element cannot follow an optional element.`,OverrideNotInSubClass:`This member cannot have an 'override' modifier because its containing class does not extend another class.`,PatternIsOptional:`A binding pattern parameter cannot be optional in an implementation signature.`,PrivateElementHasAbstract:`Private elements cannot have the 'abstract' modifier.`,PrivateElementHasAccessibility:({modifier:e})=>`Private elements cannot have an accessibility modifier ('${e}').`,ReadonlyForMethodSignature:`'readonly' modifier can only appear on a property declaration or index signature.`,ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccessorCannotHaveOptionalParameter:`A 'set' accessor cannot have an optional parameter.`,SetAccessorCannotHaveRestParameter:`A 'set' accessor cannot have rest parameter.`,SetAccessorCannotHaveReturnType:`A 'set' accessor cannot have a return type annotation.`,SingleTypeParameterWithoutTrailingComma:({typeParameterName:e})=>`Single type parameter ${e} should have a trailing comma. Example usage: <${e},>.`,StaticBlockCannotHaveModifier:`Static class blocks cannot have any modifier.`,TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:`A type-only import can specify a default import or named bindings, but not both.`,TypeModifierIsUsedInTypeExports:`The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.`,TypeModifierIsUsedInTypeImports:`The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.`,UnexpectedParameterInitializer:`A parameter initializer is only allowed in a function or constructor implementation.`,UnexpectedParameterModifier:`A parameter property is only allowed in a constructor implementation.`,UnexpectedReadonly:`'readonly' type modifier is only permitted on array and tuple literal types.`,UnexpectedTypeAnnotation:`Did not expect a type annotation here.`,UnexpectedTypeCastInParameter:`Unexpected type cast in parameter position.`,UnexpectedTypeDeclaration:e=>`'${e}' declarations can only be declared inside a block.`,UnsupportedImportTypeArgument:`Argument in a type import must be a string literal.`,UnsupportedParameterPropertyKind:`A parameter property may not be declared using a binding pattern.`,UnsupportedSignatureParameterKind:({type:e})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${e}.`,UsingDeclarationInAmbientContext:e=>`'${e}' declarations are not allowed in ambient contexts.`});function hp(e){switch(e){case`any`:return`TSAnyKeyword`;case`boolean`:return`TSBooleanKeyword`;case`bigint`:return`TSBigIntKeyword`;case`never`:return`TSNeverKeyword`;case`number`:return`TSNumberKeyword`;case`object`:return`TSObjectKeyword`;case`string`:return`TSStringKeyword`;case`symbol`:return`TSSymbolKeyword`;case`undefined`:return`TSUndefinedKeyword`;case`unknown`:return`TSUnknownKeyword`;default:return}}function gp(e){return e===`private`||e===`public`||e===`protected`}function _p(e){return e===`in`||e===`out`}function vp(e){if(e.extra?.parenthesized)return!1;switch(e.type){case`Identifier`:return!0;case`MemberExpression`:return!e.computed&&vp(e.object);case`TSInstantiationExpression`:return vp(e.expression);default:return!1}}var yp=kp([`declare`,`private`,`public`,`protected`,`override`,`abstract`,`readonly`,`static`],[`in`,`out`]),bp=kp([`readonly`],[`declare`,`abstract`,`private`,`protected`,`public`,`static`,`override`]),xp=kp([`public`,`private`,`protected`,`override`,`readonly`]),Sp=kp([`private`,`public`,`protected`]),Cp=e=>class extends e{getScopeHandler(){return yf}tsIsIdentifier(){return sd(this.state.type)}tsTokenCanFollowModifier(){return this.match(0)||this.match(2)||this.match(51)||this.match(17)||this.match(134)||this.isLiteralPropertyName()}tsNextTokenOnSameLineAndCanFollowModifier(){return this.next(),!this.hasPrecedingLineBreak()&&this.tsTokenCanFollowModifier()}tsNextTokenCanFollowModifier(){return this.match(102)?(this.next(),this.tsTokenCanFollowModifier()):this.tsNextTokenOnSameLineAndCanFollowModifier()}tsParseModifier(e,t,n){if(!sd(this.state.type)&&this.state.type!==54&&this.state.type!==71)return;let r=this.state.value;if(e.has(r)){if(n&&this.match(102)||t&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return r}}tsParseModifiers(e,t=q.InvalidModifierOnTypeMember,n,r=!1){let i=(e,t,r,i)=>{t===r&&n[i]&&this.raise(q.InvalidModifiersOrder,e,{orderedModifiers:[r,i]})},a=(e,t,r,i)=>{(n[r]&&t===i||n[i]&&t===r)&&this.raise(q.IncompatibleModifiers,e,{modifiers:[r,i]})};for(;;){let{startLoc:o}=this.state,s=this.tsParseModifier(e,r,n.static);if(!s)break;gp(s)?n.accessibility?this.raise(q.DuplicateAccessibilityModifier,o,{modifier:s}):(i(o,s,s,`override`),i(o,s,s,`static`),i(o,s,s,`readonly`),n.accessibility=s):_p(s)?(n[s]&&this.raise(q.DuplicateModifier,o,{modifier:s}),n[s]=!0,i(o,s,`in`,`out`)):(Object.hasOwn(n,s)?this.raise(q.DuplicateModifier,o,{modifier:s}):(i(o,s,`static`,`readonly`),i(o,s,`static`,`override`),i(o,s,`override`,`readonly`),i(o,s,`abstract`,`override`),a(o,s,`declare`,`override`),a(o,s,`static`,`abstract`)),n[s]=!0),e.get(s)||this.raise(t,o,{modifier:s})}}tsIsListTerminator(e){switch(e){case`EnumMembers`:case`TypeMembers`:return this.match(4);case`HeritageClauseElement`:return this.match(2);case`TupleElementTypes`:return this.match(1);case`TypeParametersOrArguments`:return this.match(44)}}tsParseList(e,t){let n=[];for(;!this.tsIsListTerminator(e);)n.push(t());return n}tsParseDelimitedList(e,t,n){return pp(this.tsParseDelimitedListWorker(e,t,!0,n))}tsParseDelimitedListWorker(e,t,n,r){let i=[],a=-1;for(;!this.tsIsListTerminator(e);){a=-1;let r=t();if(r==null)return;if(i.push(r),this.eat(8)){a=this.state.lastTokStartLoc.index;continue}if(this.tsIsListTerminator(e))break;n&&this.expect(8);return}return r&&(r.value=a),i}tsParseBracketedList(e,t,n,r,i){r||(n?this.expect(0):this.expect(43));let a=this.tsParseDelimitedList(e,t,i);return n?this.expect(1):this.expect(44),a}tsParseImportType(){let e=this.startNode();return this.expect(79),this.expect(6),this.match(130)?e.source=this.parseStringLiteral(this.state.value):(this.raise(q.UnsupportedImportTypeArgument,this.state.startLoc),e.source=this.tsParseNonConditionalType()),e.options=this.eat(8)?this.tsParseImportTypeOptions():null,this.expect(7),this.eat(12)&&(e.qualifier=this.tsParseEntityName(3)),this.match(43)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,`TSImportType`)}tsParseImportTypeOptions(){let e=this.startNode();this.expect(2);let t=this.startNode();return this.isContextual(72)?(t.method=!1,t.key=this.parseIdentifier(!0),t.computed=!1,t.shorthand=!1):this.unexpected(null,72),this.expect(10),t.value=this.tsParseImportTypeWithPropertyValue(),e.properties=[this.finishObjectProperty(t)],this.eat(8),this.expect(4),this.finishNode(e,`ObjectExpression`)}tsParseImportTypeWithPropertyValue(){let e=this.startNode(),t=[];for(this.expect(2);!this.match(4);){let e=this.state.type;sd(e)||e===130?t.push(super.parsePropertyDefinition(null)):this.unexpected(),this.eat(8)}return e.properties=t,this.next(),this.finishNode(e,`ObjectExpression`)}tsParseEntityName(e){let t;if(e&1&&this.match(74)){if(e&2)t=this.parseIdentifier(!0);else{let e=this.startNode();this.next(),t=this.finishNode(e,`ThisExpression`)}}else t=this.parseIdentifier(!!(e&1));for(;this.eat(12);){let n=this.startNodeAtNode(t);n.left=t,n.right=this.parseIdentifier(!!(e&1)),t=this.finishNode(n,`TSQualifiedName`)}return t}tsParseTypeReference(){let e=this.startNode();return e.typeName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(43)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,`TSTypeReference`)}tsParseThisTypePredicate(e){this.next();let t=this.startNodeAtNode(e);return t.parameterName=e,t.typeAnnotation=this.tsParseTypeAnnotation(!1),t.asserts=!1,this.finishNode(t,`TSTypePredicate`)}tsParseThisTypeNode(){let e=this.startNode();return this.next(),this.finishNode(e,`TSThisType`)}tsParseTypeQuery(){let e=this.startNode();return this.expect(83),e.exprName=this.match(79)?this.tsParseImportType():this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(43)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,`TSTypeQuery`)}tsParseInOutModifiers=this.tsParseModifiers.bind(this,kp([`in`,`out`],[`const`,`public`,`private`,`protected`,`readonly`,`declare`,`abstract`,`override`]),q.InvalidModifierOnTypeParameter);tsParseConstModifier=this.tsParseModifiers.bind(this,kp([`const`],[`in`,`out`]),q.InvalidModifierOnTypeParameterPositions);tsParseInOutConstModifiers=this.tsParseModifiers.bind(this,kp([`in`,`out`,`const`],[`public`,`private`,`protected`,`readonly`,`declare`,`abstract`,`override`]),q.InvalidModifierOnTypeParameter);tsParseTypeParameter(e){let t=this.startNode();return e(t),t.name=this.tsParseTypeParameterName(),t.constraint=this.tsEatThenParseType(77),t.default=this.tsEatThenParseType(25),this.finishNode(t,`TSTypeParameter`)}tsTryParseTypeParameters(e){if(this.match(43))return this.tsParseTypeParameters(e)}tsParseTypeParameters(e){let t=this.startNode();this.match(43)||this.match(138)?this.next():this.unexpected();let n={value:-1};return t.params=this.tsParseBracketedList(`TypeParametersOrArguments`,this.tsParseTypeParameter.bind(this,e),!1,!0,n),t.params.length===0&&this.raise(q.EmptyTypeParameters,t),n.value!==-1&&this.addExtra(t,`trailingComma`,n.value),this.finishNode(t,`TSTypeParameterDeclaration`)}tsFillSignature(e,t){let n=e===15;t.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),this.expect(6),t.params=this.tsParseBindingListForSignature(),(n||this.match(e))&&(t.returnType=this.tsParseTypeOrTypePredicateAnnotation(e))}tsParseBindingListForSignature(){let e=super.parseBindingList(7,41,2);for(let t of e){let{type:e}=t;(e===`AssignmentPattern`||e===`TSParameterProperty`)&&this.raise(q.UnsupportedSignatureParameterKind,t,{type:e})}return e}tsParseTypeMemberSemicolon(){!this.eat(8)&&!this.isLineTerminator()&&this.expect(9)}tsParseSignatureMember(e,t){return this.tsFillSignature(10,t),this.tsParseTypeMemberSemicolon(),this.finishNode(t,e)}tsIsUnambiguouslyIndexSignature(){return this.next(),sd(this.state.type)?(this.next(),this.match(10)):!1}tsTryParseIndexSignature(e){if(!(this.match(0)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))))return;this.expect(0);let t=this.parseIdentifier();t.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(t),this.expect(1),e.parameters=[t];let n=this.tsTryParseTypeAnnotation();return n&&(e.typeAnnotation=n),this.tsParseTypeMemberSemicolon(),this.finishNode(e,`TSIndexSignature`)}tsParsePropertyOrMethodSignature(e,t){if(this.eat(13)&&(e.optional=!0),this.match(6)||this.match(43)){t&&this.raise(q.ReadonlyForMethodSignature,e);let n=e;if(n.kind&&this.match(43)&&this.raise(q.AccessorCannotHaveTypeParameters,this.state.curPosition()),this.tsFillSignature(10,n),this.tsParseTypeMemberSemicolon(),n.kind===`get`)n.params.length>0&&(this.raise(G.BadGetterArity,this.state.curPosition()),this.isThisParam(n.params[0])&&this.raise(q.AccessorCannotDeclareThisParameter,this.state.curPosition()));else if(n.kind===`set`){if(n.params.length!==1)this.raise(G.BadSetterArity,this.state.curPosition());else{let e=n.params[0];this.isThisParam(e)&&this.raise(q.AccessorCannotDeclareThisParameter,this.state.curPosition()),e.type===`Identifier`&&e.optional&&this.raise(q.SetAccessorCannotHaveOptionalParameter,this.state.curPosition()),e.type===`RestElement`&&this.raise(q.SetAccessorCannotHaveRestParameter,this.state.curPosition())}n.returnType&&this.raise(q.SetAccessorCannotHaveReturnType,n.returnType)}else n.kind=`method`;return this.finishNode(n,`TSMethodSignature`)}{let n=e;t&&(n.readonly=!0);let r=this.tsTryParseTypeAnnotation();return r&&(n.typeAnnotation=r),this.tsParseTypeMemberSemicolon(),this.finishNode(n,`TSPropertySignature`)}}tsParseTypeMember(){let e=this.startNode();if(this.match(6)||this.match(43))return this.tsParseSignatureMember(`TSCallSignatureDeclaration`,e);if(this.match(73)){let t=this.startNode();return this.next(),this.match(6)||this.match(43)?this.tsParseSignatureMember(`TSConstructSignatureDeclaration`,e):(e.key=this.createIdentifier(t,`new`),this.tsParsePropertyOrMethodSignature(e,!1))}return this.tsParseModifiers(bp,void 0,e),this.tsTryParseIndexSignature(e)||(super.parsePropertyName(e),!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.tsTokenCanFollowModifier()&&(e.kind=e.key.name,super.parsePropertyName(e),!this.match(6)&&!this.match(43)&&this.unexpected(null,6)),this.tsParsePropertyOrMethodSignature(e,!!e.readonly))}tsParseTypeLiteral(){let e=this.startNode();return e.members=this.tsParseObjectTypeMembers(),this.finishNode(e,`TSTypeLiteral`)}tsParseObjectTypeMembers(){this.expect(2);let e=this.tsParseList(`TypeMembers`,this.tsParseTypeMember.bind(this));return this.expect(4),e}tsIsStartOfMappedType(){return this.next(),this.eat(49)?this.isContextual(118):(this.isContextual(118)&&this.next(),!this.match(0)||(this.next(),!this.tsIsIdentifier())?!1:(this.next(),this.match(54)))}tsParseMappedType(){let e=this.startNode();return this.expect(2),this.match(49)?(e.readonly=this.state.value,this.next(),this.expectContextual(118)):this.eatContextual(118)&&(e.readonly=!0),this.expect(0),e.key=this.tsParseTypeParameterName(),e.constraint=this.tsExpectThenParseType(54),e.nameType=this.eatContextual(89)?this.tsParseType():null,this.expect(1),this.match(49)?(e.optional=this.state.value,this.next(),this.expect(13)):this.eat(13)&&(e.optional=!0),e.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(4),this.finishNode(e,`TSMappedType`)}tsParseTupleType(){let e=this.startNode();e.elementTypes=this.tsParseBracketedList(`TupleElementTypes`,this.tsParseTupleElementType.bind(this),!0,!1);let t=!1;return e.elementTypes.forEach(e=>{let{type:n}=e;t&&n!==`TSRestType`&&n!==`TSOptionalType`&&!(n===`TSNamedTupleMember`&&e.optional)&&this.raise(q.OptionalTypeBeforeRequired,e),t||=n===`TSNamedTupleMember`&&e.optional||n===`TSOptionalType`}),this.finishNode(e,`TSTupleType`)}tsParseTupleElementType(){let e=this.state.startLoc,t=this.eat(17),{startLoc:n}=this.state,r,i,a,o,s=ld(this.state.type)?this.lookaheadCharCode():null;if(s===58)r=!0,a=!1,i=this.parseIdentifier(!0),this.expect(10),o=this.tsParseType();else if(s===63){a=!0;let e=this.state.value,t=this.tsParseNonArrayType();this.lookaheadCharCode()===58?(r=!0,i=this.createIdentifier(this.startNodeAt(n),e),this.expect(13),this.expect(10),o=this.tsParseType()):(r=!1,o=t,this.expect(13))}else o=this.tsParseType(),a=this.eat(13),r=this.eat(10);if(r){let e;i?(e=this.startNodeAt(n),e.optional=a,e.label=i,e.elementType=o,this.eat(13)&&(e.optional=!0,this.raise(q.TupleOptionalAfterType,this.state.lastTokStartLoc))):(e=this.startNodeAt(n),e.optional=a,this.raise(q.InvalidTupleMemberLabel,o),e.label=o,e.elementType=this.tsParseType()),o=this.finishNode(e,`TSNamedTupleMember`)}else if(a){let e=this.startNodeAt(n);e.typeAnnotation=o,o=this.finishNode(e,`TSOptionalType`)}if(t){let t=this.startNodeAt(e);t.typeAnnotation=o,o=this.finishNode(t,`TSRestType`)}return o}tsParseParenthesizedType(){let e=this.startNode();return this.expect(6),e.typeAnnotation=this.tsParseType(),this.expect(7),this.finishNode(e,`TSParenthesizedType`)}tsParseFunctionOrConstructorType(e,t){let n=this.startNode();return e===`TSConstructorType`&&(n.abstract=!!t,t&&this.next(),this.next()),this.tsInAllowConditionalTypesContext(()=>this.tsFillSignature(15,n)),this.finishNode(n,e)}tsParseLiteralTypeNode(){let e=this.startNode();switch(this.state.type){case 131:case 132:case 130:case 81:case 82:e.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode(e,`TSLiteralType`)}tsParseTemplateLiteralType(){let e=this.state.startLoc,t=this.parseTemplateElement(!1),n=[t];if(t.tail){let t=this.startNodeAt(e),r=this.startNodeAt(e);return r.expressions=[],r.quasis=n,t.literal=this.finishNode(r,`TemplateLiteral`),this.finishNode(t,`TSLiteralType`)}{let r=[];for(;!t.tail;)r.push(this.tsParseType()),this.readTemplateContinuation(),n.push(t=this.parseTemplateElement(!1));let i=this.startNodeAt(e);return i.types=r,i.quasis=n,this.finishNode(i,`TSTemplateLiteralType`)}}parseTemplateSubstitution(){return this.state.inType?this.tsParseType():super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){let e=this.tsParseThisTypeNode();return this.isContextual(112)&&!this.hasPrecedingLineBreak()?this.tsParseThisTypePredicate(e):e}tsParseNonArrayType(){switch(this.state.type){case 130:case 131:case 132:case 81:case 82:return this.tsParseLiteralTypeNode();case 49:if(this.state.value===`-`){let e=this.startNode(),t=this.lookahead();return t.type!==131&&t.type!==132&&this.unexpected(),e.literal=this.parseMaybeUnary(),this.finishNode(e,`TSLiteralType`)}break;case 74:return this.tsParseThisTypeOrThisTypePredicate();case 83:return this.tsParseTypeQuery();case 79:return this.tsParseImportType();case 2:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.tsParseTupleType();case 6:if(!(this.optionFlags&2048)){let e=this.state.startLoc;this.next();let t=this.tsParseType();return this.expect(7),this.addExtra(t,`parenthesized`,!0),this.addExtra(t,`parenStart`,e.index),t}return this.tsParseParenthesizedType();case 21:case 20:return this.tsParseTemplateLiteralType();default:{let{type:e}=this.state;if(sd(e)||e===84||e===80){let t=e===84?`TSVoidKeyword`:e===80?`TSNullKeyword`:hp(this.state.value);if(t!==void 0&&this.lookaheadCharCode()!==46){let e=this.startNode();return this.next(),this.finishNode(e,t)}return this.tsParseTypeReference()}}}throw this.unexpected()}tsParseArrayTypeOrHigher(){let{startLoc:e}=this.state,t=this.tsParseNonArrayType();for(;!this.hasPrecedingLineBreak()&&this.eat(0);)if(this.match(1)){let n=this.startNodeAt(e);n.elementType=t,this.expect(1),t=this.finishNode(n,`TSArrayType`)}else{let n=this.startNodeAt(e);n.objectType=t,n.indexType=this.tsParseType(),this.expect(1),t=this.finishNode(n,`TSIndexedAccessType`)}return t}tsParseTypeOperator(){let e=this.startNode(),t=this.state.value;return this.next(),e.operator=t,e.typeAnnotation=this.tsParseTypeOperatorOrHigher(),t===`readonly`&&this.tsCheckTypeAnnotationForReadOnly(e),this.finishNode(e,`TSTypeOperator`)}tsCheckTypeAnnotationForReadOnly(e){switch(e.typeAnnotation.type){case`TSTupleType`:case`TSArrayType`:return;default:this.raise(q.UnexpectedReadonly,e)}}tsParseInferType(){let e=this.startNode();this.expectContextual(111);let t=this.startNode();return t.name=this.tsParseTypeParameterName(),t.constraint=this.tsTryParse(()=>this.tsParseConstraintForInferType()),e.typeParameter=this.finishNode(t,`TSTypeParameter`),this.finishNode(e,`TSInferType`)}tsParseConstraintForInferType(){if(this.eat(77)){let e=this.tsInDisallowConditionalTypesContext(()=>this.tsParseType());if(this.state.inDisallowConditionalTypesContext||!this.match(13))return e}}tsParseTypeOperatorOrHigher(){return bd(this.state.type)&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(111)?this.tsParseInferType():this.tsInAllowConditionalTypesContext(()=>this.tsParseArrayTypeOrHigher())}tsParseUnionOrIntersectionType(e,t,n){let r=this.startNode(),i=this.eat(n),a=[];do a.push(t());while(this.eat(n));return a.length===1&&!i?a[0]:(r.types=a,this.finishNode(r,e))}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType(`TSIntersectionType`,this.tsParseTypeOperatorOrHigher.bind(this),41)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType(`TSUnionType`,this.tsParseIntersectionTypeOrHigher.bind(this),39)}tsIsStartOfFunctionType(){return this.match(43)?!0:this.match(6)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(sd(this.state.type)||this.match(74))return this.next(),!0;if(this.match(2)){let{errors:e}=this.state,t=e.length;try{return this.parseObjectLike(4,!0),e.length===t}catch{return!1}}if(this.match(0)){this.next();let{errors:e}=this.state,t=e.length;try{return super.parseBindingList(1,93,1),e.length===t}catch{return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){return this.next(),!!(this.match(7)||this.match(17)||this.tsSkipParameterStart()&&(this.match(10)||this.match(8)||this.match(13)||this.match(25)||this.match(7)&&(this.next(),this.match(15))))}tsParseTypeOrTypePredicateAnnotation(e){return this.tsInType(()=>{let t=this.startNode();this.expect(e);let n=this.startNode(),r=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(r&&this.match(74)){let e=this.tsParseThisTypeOrThisTypePredicate();return e.type===`TSThisType`?(n.parameterName=e,n.asserts=!0,n.typeAnnotation=null,e=this.finishNode(n,`TSTypePredicate`)):(this.resetStartLocationFromNode(e,n),e.asserts=!0),t.typeAnnotation=e,this.finishNode(t,`TSTypeAnnotation`)}let i=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!i)return r?(n.parameterName=this.parseIdentifier(),n.asserts=r,n.typeAnnotation=null,t.typeAnnotation=this.finishNode(n,`TSTypePredicate`),this.finishNode(t,`TSTypeAnnotation`)):this.tsParseTypeAnnotation(!1,t);let a=this.tsParseTypeAnnotation(!1);return n.parameterName=i,n.typeAnnotation=a,n.asserts=r,t.typeAnnotation=this.finishNode(n,`TSTypePredicate`),this.finishNode(t,`TSTypeAnnotation`)})}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(10))return this.tsParseTypeOrTypePredicateAnnotation(10)}tsTryParseTypeAnnotation(){if(this.match(10))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(10)}tsParseTypePredicatePrefix(){let e=this.parseIdentifier();if(this.isContextual(112)&&!this.hasPrecedingLineBreak())return this.next(),e}tsParseTypePredicateAsserts(){if(this.state.type!==105)return!1;let e=this.state.containsEsc;return this.next(),!sd(this.state.type)&&!this.match(74)?!1:(e&&this.raise(G.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:`asserts`}),!0)}tsParseTypeAnnotation(e=!0,t=this.startNode()){return this.tsInType(()=>{e&&this.expect(10),t.typeAnnotation=this.tsParseType()}),this.finishNode(t,`TSTypeAnnotation`)}tsParseType(){mp(this.state.inType);let e=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(77))return e;let t=this.startNodeAtNode(e);return t.checkType=e,t.extendsType=this.tsInDisallowConditionalTypesContext(()=>this.tsParseNonConditionalType()),this.expect(13),t.trueType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.expect(10),t.falseType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.finishNode(t,`TSConditionalType`)}isAbstractConstructorSignature(){return this.isContextual(120)&&this.isLookaheadContextual(`new`)}tsParseNonConditionalType(){return this.tsIsStartOfFunctionType()?this.tsParseFunctionOrConstructorType(`TSFunctionType`):this.match(73)?this.tsParseFunctionOrConstructorType(`TSConstructorType`):this.isAbstractConstructorSignature()?this.tsParseFunctionOrConstructorType(`TSConstructorType`,!0):this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){this.getPluginOption(`typescript`,`disallowAmbiguousJSXLike`)&&this.raise(q.ReservedTypeAssertion,this.state.startLoc);let e=this.startNode();return e.typeAnnotation=this.tsInType(()=>(this.next(),this.match(71)?this.tsParseTypeReference():this.tsParseType())),this.expect(44),e.expression=this.parseMaybeUnary(),this.finishNode(e,`TSTypeAssertion`)}tsParseHeritageClause(e){let t=this.state.startLoc,n=this.tsParseDelimitedList(`HeritageClauseElement`,()=>{let t=(this.state.canStartArrow=!1,super.parseExprSubscripts());vp(t)||this.raise(q.InvalidHeritageClauseType,t.start,{token:e});let n=e===`extends`?`TSInterfaceHeritage`:`TSClassImplements`;if(t.type===`TSInstantiationExpression`)return t.type=n,t;let r=this.startNodeAtNode(t);return r.expression=t,(this.match(43)||this.match(47))&&(r.typeArguments=this.tsParseTypeArgumentsInExpression()),this.finishNode(r,n)});return n.length||this.raise(q.EmptyHeritageClauseType,t,{token:e}),n}tsParseInterfaceDeclaration(e,t={}){if(this.hasFollowingLineBreak())return null;this.expectContextual(125),t.declare&&(e.declare=!0),sd(this.state.type)?(e.id=this.parseIdentifier(),this.checkIdentifier(e.id,130)):(e.id=null,this.raise(q.MissingInterfaceName,this.state.startLoc)),e.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(77)&&(e.extends=this.tsParseHeritageClause(`extends`));let n=this.startNode();return n.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),e.body=this.finishNode(n,`TSInterfaceBody`),this.finishNode(e,`TSInterfaceDeclaration`)}tsParseTypeAliasDeclaration(e){return e.id=this.parseIdentifier(),this.checkIdentifier(e.id,2),e.typeAnnotation=this.tsInType(()=>{if(e.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(25),this.isContextual(110)&&this.lookaheadCharCode()!==46){let e=this.startNode();return this.next(),this.finishNode(e,`TSIntrinsicKeyword`)}return this.tsParseType()}),this.semicolon(),this.finishNode(e,`TSTypeAliasDeclaration`)}tsInTopLevelContext(e){if(this.curContext()!==Od.brace){let t=this.state.context;this.state.context=[t[0]];try{return e()}finally{this.state.context=t}}else return e()}tsInType(e){let t=this.state.inType;this.state.inType=!0;try{return e()}finally{this.state.inType=t}}tsInDisallowConditionalTypesContext(e){let t=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return e()}finally{this.state.inDisallowConditionalTypesContext=t}}tsInAllowConditionalTypesContext(e){let t=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return e()}finally{this.state.inDisallowConditionalTypesContext=t}}tsEatThenParseType(e){if(this.match(e))return this.tsNextThenParseType()}tsExpectThenParseType(e){return this.tsInType(()=>(this.expect(e),this.tsParseType()))}tsNextThenParseType(){return this.tsInType(()=>(this.next(),this.tsParseType()))}tsParseEnumMember(){let e=this.startNode();return e.id=this.match(130)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(25)&&(e.initializer=super.parseMaybeAssignAllowIn()),this.finishNode(e,`TSEnumMember`)}tsParseEnumDeclaration(e,t={}){return t.const&&(e.const=!0),t.declare&&(e.declare=!0),this.expectContextual(122),e.id=this.parseIdentifier(),this.checkIdentifier(e.id,e.const?8971:8459),e.body=this.tsParseEnumBody(),this.finishNode(e,`TSEnumDeclaration`)}tsParseEnumBody(){let e=this.startNode();return this.expect(2),e.members=this.tsParseDelimitedList(`EnumMembers`,this.tsParseEnumMember.bind(this)),this.expect(4),this.finishNode(e,`TSEnumBody`)}tsParseModuleBlock(e){let t=this.startNode();return e||this.scope.enter(0),this.expect(2),super.parseBlockOrModuleBlockBody(t.body=[],void 0,!0,4),e||this.scope.exit(),this.finishNode(t,`TSModuleBlock`)}tsParseNamespaceDeclaration(e){return e.id=this.tsParseEntityName(0),e.id.type===`Identifier`&&this.checkIdentifier(e.id,1024),this.scope.enter(2048),this.prodParam.enter(0),e.body=this.tsParseModuleBlock(!1),this.prodParam.exit(),this.scope.exit(),this.finishNode(e,`TSModuleDeclaration`)}tsParseAmbientExternalModuleDeclaration(e){let t=this.isContextual(108);if(t)e.kind=`global`,e.id=this.parseIdentifier();else{e.kind=`module`;let{type:t,value:n}=this.state;t===130?e.id=super.parseStringLiteral(n):sd(t)?(this.raise(q.InlineModuleDeclarationMustUseString,this.state.startLoc),e.id=this.tsParseEntityName(0)):t===2?this.raise(q.EmptyNamespaceName,this.state.startLoc):(this.raise(q.InvalidNamespaceName,this.state.startLoc,n),e.id=super.parseExprAtom())}return this.match(2)?(t||this.scope.enter(1024),this.prodParam.enter(0),e.body=this.tsParseModuleBlock(t),this.prodParam.exit(),t||this.scope.exit()):this.semicolon(),this.finishNode(e,`TSModuleDeclaration`)}tsParseImportEqualsDeclaration(e,t){e.id=t||this.parseIdentifier(),this.checkIdentifier(e.id,4096),this.expect(25);let n=this.tsParseModuleReference();return e.importKind===`type`&&n.type!==`TSExternalModuleReference`&&this.raise(q.ImportAliasHasImportType,n),e.moduleReference=n,this.semicolon(),this.finishNode(e,`TSImportEqualsDeclaration`)}tsIsExternalModuleReference(){return this.isContextual(115)&&this.lookaheadCharCode()===40}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(0)}tsParseExternalModuleReference(){let e=this.startNode();return this.expectContextual(115),this.expect(6),this.match(130)||this.unexpected(),e.expression=super.parseExprAtom(),this.expect(7),this.sawUnambiguousESM=!0,this.finishNode(e,`TSExternalModuleReference`)}tsLookAhead(e){let t=this.state.clone(),n=e();return this.state=t,n}tsTryParseAndCatch(e){let t=this.tryParse(t=>e()||t());if(!t.aborted&&t.node)return t.error&&(this.state=t.failState),t.node}tsTryParse(e){let t=this.state.clone(),n=e();if(n!==void 0&&n!==!1)return n;this.state=t}tsTryParseDeclare(e){if(this.isLineTerminator())return;let t=this.state.type;return this.tsInAmbientContext(()=>{switch(t){case 64:return e.declare=!0,super.parseFunctionStatement(e,!1,!1);case 76:return e.declare=!0,this.parseClass(e,!0,!1);case 122:return this.tsParseEnumDeclaration(e,{declare:!0});case 108:return this.tsParseAmbientExternalModuleDeclaration(e);case 96:if(this.state.containsEsc)return;case 71:case 70:return!this.match(71)||!this.isLookaheadContextual(`enum`)?(e.declare=!0,this.parseVarStatement(e,this.state.value,!0)):(this.expect(71),this.tsParseEnumDeclaration(e,{const:!0,declare:!0}));case 103:if(this.isUsing())return this.raise(q.InvalidModifierOnUsingDeclaration,this.state.startLoc,`declare`),e.declare=!0,this.parseVarStatement(e,`using`,!0);break;case 92:if(this.isAwaitUsing())return this.raise(q.InvalidModifierOnAwaitUsingDeclaration,this.state.startLoc,`declare`),e.declare=!0,this.next(),this.parseVarStatement(e,`await using`,!0);break;case 125:{let t=this.tsParseInterfaceDeclaration(e,{declare:!0});if(t)return t}default:if(sd(t))return this.tsParseDeclaration(e,this.state.type,!0,null)}})}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.state.type,!0,null)}tsParseDeclaration(e,t,n,r){switch(t){case 120:if(this.tsCheckLineTerminator(n)&&(this.match(76)||sd(this.state.type)))return this.tsParseAbstractDeclaration(e,r);break;case 123:if(this.tsCheckLineTerminator(n))return this.tsParseAmbientExternalModuleDeclaration(e);break;case 124:if(this.tsCheckLineTerminator(n)&&sd(this.state.type))return e.kind=`namespace`,this.tsParseNamespaceDeclaration(e);break;case 126:if(this.tsCheckLineTerminator(n)&&sd(this.state.type))return this.tsParseTypeAliasDeclaration(e)}}tsCheckLineTerminator(e){return e?!this.hasFollowingLineBreak()&&(this.next(),!0):!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction(e){if(!this.match(43))return;let t=this.tsTryParseAndCatch(()=>{let t=this.startNodeAt(e);return t.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(t),t.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(15),t});if(t)return super.parseArrowExpression(t,null,!0)}tsParseTypeArgumentsInExpression(){if(this.reScan_lt()===43)return this.tsParseTypeArguments()}tsParseTypeArguments(){let e=this.startNode();return e.params=this.tsInType(()=>this.tsInTopLevelContext(()=>(this.expect(43),this.tsParseDelimitedList(`TypeParametersOrArguments`,this.tsParseType.bind(this))))),e.params.length===0?this.raise(q.EmptyTypeArguments,e):!this.state.inType&&this.curContext()===Od.brace&&this.reScan_lt_gt(),this.expect(44),this.finishNode(e,`TSTypeParameterInstantiation`)}tsIsDeclarationStart(){return xd(this.state.type)}isExportDefaultSpecifier(){return!this.tsIsDeclarationStart()&&super.isExportDefaultSpecifier()}parseBindingElement(e,t){let n=t.length?null:this.state.startLoc,r={};this.tsParseModifiers(xp,void 0,r);let i=r.accessibility,a=r.override,o=r.readonly;!(e&4)&&(i||o||a)&&this.raise(q.UnexpectedParameterModifier,n||t[0]);let s=this.state.startLoc,c=this.parseMaybeDefault(s);e&2&&this.parseFunctionParamType(c);let l=this.parseMaybeDefault(s,c);if(i||o||a){let e=n?this.startNodeAt(n):this.startNodeAtNode(t[0]);return t.length?e.decorators=t:this.setLoc(n),i&&(e.accessibility=i),o&&(e.readonly=o),a&&(e.override=a),l.type!==`Identifier`&&l.type!==`AssignmentPattern`&&this.raise(q.UnsupportedParameterPropertyKind,n||t[0]),e.parameter=l,this.finishNode(e,`TSParameterProperty`)}return t.length&&(c.decorators=t),l}isSimpleParameter(e){return e.type===`TSParameterProperty`&&super.isSimpleParameter(e.parameter)||super.isSimpleParameter(e)}tsDisallowOptionalPattern(e){for(let t of e.params)t.type!==`Identifier`&&t.optional&&!this.state.isAmbientContext&&this.raise(q.PatternIsOptional,t)}setArrowFunctionParameters(e,t,n){super.setArrowFunctionParameters(e,t,n),this.tsDisallowOptionalPattern(e)}parseFunctionBodyAndFinish(e,t,n=!1){this.match(10)&&(e.returnType=this.tsParseTypeOrTypePredicateAnnotation(10));let r=t===`FunctionDeclaration`?`TSDeclareFunction`:t===`ClassMethod`||t===`ClassPrivateMethod`?`TSDeclareMethod`:void 0;if(r&&!this.match(2)&&this.isLineTerminator()){if(r===`TSDeclareMethod`&&e.kind===`constructor`)for(let t of e.params)t.type===`TSParameterProperty`?this.raise(q.UnexpectedParameterModifier,t):t.type===`AssignmentPattern`&&this.raise(q.UnexpectedParameterInitializer,t);else for(let t of e.params)t.type===`AssignmentPattern`&&this.raise(q.UnexpectedParameterInitializer,t);return this.finishNode(e,r)}return r&&this.state.isAmbientContext&&(this.raise(q.DeclareFunctionHasImplementation,this.state.startLoc),r===`TSDeclareFunction`&&e.declare)?super.parseFunctionBodyAndFinish(e,r,n):(this.tsDisallowOptionalPattern(e),super.parseFunctionBodyAndFinish(e,t,n))}registerFunctionStatementId(e){!e.body&&e.id?this.checkIdentifier(e.id,1024):super.registerFunctionStatementId(e)}tsCheckForInvalidTypeCasts(e){e.forEach(e=>{e?.type===`TSTypeCastExpression`&&this.raise(q.UnexpectedTypeAnnotation,e.typeAnnotation)})}toReferencedList(e,t){return this.tsCheckForInvalidTypeCasts(e),e}parseArrayLike(e,t){let n=super.parseArrayLike(e,t);return n.type===`ArrayExpression`&&this.tsCheckForInvalidTypeCasts(n.elements),n}parseSubscript(e,t,n,r){if(!this.hasPrecedingLineBreak()&&this.match(31)){this.state.canStartJSXElement=!1,this.next();let n=this.startNodeAt(t);return n.expression=e,this.finishNode(n,`TSNonNullExpression`)}let i=!1;if(this.match(14)&&this.lookaheadCharCode()===60){if(n)return r.stop=!0,e;r.optionalChainMember=i=!0,this.next()}if(this.match(43)||this.match(47)){let a,o=this.tsTryParseAndCatch(()=>{if(!n&&this.atPossibleAsyncArrow(e)){let e=this.tsTryParseGenericAsyncArrowFunction(t);if(e)return r.stop=!0,e}let o=this.tsParseTypeArgumentsInExpression();if(!o)return;if(i&&!this.match(6)){a=this.state.curPosition();return}if(Td(this.state.type)){let n=super.parseTaggedTemplateExpression(e,t,r);return n.typeArguments=o,n}if(!n&&this.eat(6)){let n=this.startNodeAt(t);return n.callee=e,n.arguments=this.parseCallExpressionArguments(),this.tsCheckForInvalidTypeCasts(n.arguments),n.typeArguments=o,r.optionalChainMember&&(n.optional=i),this.finishCallExpression(n,r.optionalChainMember)}let s=this.state.type;if(s===44||s===48||s!==6&&s!==89&&s!==116&&fd(s)&&!this.hasPrecedingLineBreak())return;let c=this.startNodeAt(t);return c.expression=e,c.typeArguments=o,this.finishNode(c,`TSInstantiationExpression`)});if(a&&this.unexpected(a,6),o)return o.type===`TSInstantiationExpression`&&((this.match(12)||this.match(14)&&this.lookaheadCharCode()!==40)&&this.raise(q.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc),!this.match(12)&&!this.match(14)&&(o.expression=super.stopParseSubscript(e,r))),o}return super.parseSubscript(e,t,n,r)}parseNewCallee(e){super.parseNewCallee(e);let{callee:t}=e;t.type===`TSInstantiationExpression`&&!t.extra?.parenthesized&&(e.typeArguments=t.typeArguments,e.callee=t.expression)}parseExprOp(e,t,n){let r;if(Cd(54)>n&&!this.hasPrecedingLineBreak()&&(this.isContextual(89)||(r=this.isContextual(116)))){let i=this.startNodeAt(t);i.expression=e,i.typeAnnotation=this.tsInType(()=>(this.next(),this.match(71)?(r&&this.raise(G.UnexpectedKeyword,this.state.startLoc,{keyword:`const`}),this.tsParseTypeReference()):this.tsParseType()));let a=this.finishNode(i,r?`TSSatisfiesExpression`:`TSAsExpression`);return this.reScan_lt_gt(),this.parseExprOp(a,t,n)}return super.parseExprOp(e,t,n)}checkReservedWord(e,t,n,r){this.state.isAmbientContext||super.checkReservedWord(e,t,n,r)}checkDuplicateExports(){}isPotentialImportPhase(e){if(super.isPotentialImportPhase(e))return!0;if(this.isContextual(126)){let t=this.lookaheadCharCode();return e?t===123||t===42:t!==61}return!e&&this.isContextual(83)}applyImportPhase(e,t,n,r){super.applyImportPhase(e,t,n,r),t?e.exportKind=n===`type`?`type`:`value`:e.importKind=n===`type`||n===`typeof`?n:`value`}parseImport(e){if(this.match(130))return e.importKind=`value`,this.scope.inTSNamespace&&this.raise(q.ImportInTSNamespace,e),super.parseImport(e);let t;if(sd(this.state.type)&&this.lookaheadCharCode()===61){e.importKind=`value`;let t=this.tsParseImportEqualsDeclaration(e);return this.scope.inTSNamespace&&t.moduleReference.type===`TSExternalModuleReference`&&this.raise(q.ImportInTSNamespace,e),t}if(this.isContextual(126)){let n=this.parseMaybeImportPhase(e,!1);if(this.lookaheadCharCode()===61)return this.scope.inTSNamespace&&this.raise(q.ImportInTSNamespace,e),this.tsParseImportEqualsDeclaration(e,n);t=super.parseImportSpecifiersAndAfter(e,n)}else t=super.parseImport(e);return t.importKind===`type`&&t.specifiers.length>1&&t.specifiers[0].type===`ImportDefaultSpecifier`?this.raise(q.TypeImportCannotSpecifyDefaultAndNamed,t):this.scope.inTSNamespace&&this.raise(q.ImportInTSNamespace,t),t}parseExport(e,t){if(this.match(79)){let t=this.startNode();this.next();let n=null;this.isContextual(126)&&this.isPotentialImportPhase(!1)?n=this.parseMaybeImportPhase(t,!1):t.importKind=`value`;let r=this.tsParseImportEqualsDeclaration(t,n);return e.attributes=[],e.declaration=r,e.exportKind=`value`,e.source=null,e.specifiers=[],this.finishNode(e,`ExportNamedDeclaration`)}if(this.eat(25)){let t=e;return t.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.scope.inTSNamespace&&this.raise(q.ExportAssignmentInTSNamespace,t),this.finishNode(t,`TSExportAssignment`)}if(this.eatContextual(89)){let t=e;return this.expectContextual(124),t.id=this.parseIdentifier(),this.checkIdentifier(t.id,8201),this.semicolon(),this.scope.inTSNamespace&&this.raise(q.NamespaceExportInTSNamespace,t),this.finishNode(t,`TSNamespaceExportDeclaration`)}{let n=super.parseExport(e,t);return this.scope.inTSNamespace&&(n.type!==`ExportNamedDeclaration`||n.source||!n.declaration&&!this.state.isAmbientContext)&&this.raise(q.ExportInTSNamespace,n),n}}isAbstractClass(){return this.isContextual(120)&&this.isLookaheadContextual(`class`)}parseExportDefaultExpression(){if(this.isAbstractClass()){let e=this.startNode();return this.next(),e.abstract=!0,this.parseClass(e,!0,!0)}if(this.match(125)){let e=this.tsParseInterfaceDeclaration(this.startNode());if(e)return e}return super.parseExportDefaultExpression()}parseVarStatement(e,t,n=!1){let{isAmbientContext:r}=this.state,i=super.parseVarStatement(e,t,n||r);if(r&&!e.declare&&(t===`using`||t===`await using`))return this.raiseOverwrite(q.UsingDeclarationInAmbientContext,e,t),i;for(let e of i.declarations){let{id:n,init:i,definite:a}=e;a&&(i?this.raise(q.DeclaratorDefiniteAssertionWithInitializer,n):n.typeAnnotation||this.raise(q.DeclaratorDefiniteAssertionRequiresTypeAnnotation,n)),r&&i&&(t===`var`||t===`let`||n.typeAnnotation?this.raise(q.InitializerNotAllowedInAmbientContext,i):Tp(i,this.hasPlugin(`estree`))||this.raise(q.ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference,i))}return i}parseStatementContent(e,t){let n=!!(e&2);if(!this.state.containsEsc)switch(this.state.type){case 71:if(this.isLookaheadContextual(`enum`)){let e=this.startNode();return this.next(),this.tsParseEnumDeclaration(e,{const:!0})}break;case 120:case 121:if(this.nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine()){let e=this.state.type,n=this.startNode();this.next();let r=e===121?this.tsTryParseDeclare(n):this.tsParseAbstractDeclaration(n,t);return r?(e===121&&(r.declare=!0),r):(n.expression=this.createIdentifier(this.startNodeAtNode(n),e===121?`declare`:`abstract`),this.semicolon(!1),this.finishNode(n,`ExpressionStatement`))}break;case 122:return this.tsParseEnumDeclaration(this.startNode());case 108:if(this.lookaheadCharCode()===123){let e=this.startNode();return this.tsParseAmbientExternalModuleDeclaration(e)}break;case 125:{let e=this.tsParseInterfaceDeclaration(this.startNode());if(e)return n||this.raise(q.UnexpectedTypeDeclaration,e,`interface`),e;break}case 123:if(this.nextTokenIsStringLiteralOnSameLine()){let e=this.startNode();return this.next(),this.tsParseDeclaration(e,123,!1,t)}if(this.nextTokenIsIdentifierOnSameLine()){this.raise(q.InlineModuleDeclarationMustUseString,this.state.startLoc);let e=this.startNode();return this.next(),this.tsParseDeclaration(e,124,!1,t)}break;case 124:if(this.nextTokenIsIdentifierOnSameLine()){let e=this.startNode();return this.next(),this.tsParseDeclaration(e,124,!1,t)}break;case 126:if(this.nextTokenIsIdentifierOnSameLine()){let e=this.startNode();return n||this.raise(q.UnexpectedTypeDeclaration,e,`type`),this.next(),this.tsParseTypeAliasDeclaration(e)}}return super.parseStatementContent(e,t)}parseAccessModifier(){return this.tsParseModifier(Sp)}tsHasSomeModifiers(e,t){return t.some(t=>gp(t)?e.accessibility===t:!!e[t])}tsIsStartOfStaticBlocks(){return this.isContextual(102)&&this.lookaheadCharCode()===123}parseClassMember(e,t,n){this.tsParseModifiers(yp,q.InvalidModifierOnTypeParameterPositions,t,!0);let r=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(t,[`declare`,`private`,`public`,`protected`,`override`,`abstract`,`readonly`,`static`])&&this.raise(q.StaticBlockCannotHaveModifier,this.state.curPosition()),super.parseClassStaticBlock(e,t)):this.parseClassMemberWithIsStatic(e,t,n,!!t.static)};t.declare?this.tsInAmbientContext(r):r(),t.decorators&&t.decorators.length>0&&!this.hasPlugin(`decorators-legacy`)&&(t.type===`TSAbstractMethodDefinition`||t.type===`TSDeclareMethod`?this.raise(q.DecoratorAbstractMethod,t,{kind:`abstract method`}):(t.type===`ClassProperty`&&t.abstract||t.type===`ClassProperty`&&t.declare||t.type===`TSAbstractPropertyDefinition`||t.type===`PropertyDefinition`&&t.declare)&&this.raise(q.DecoratorAbstractMethod,t,{kind:t.declare?`declare field`:`abstract field`}))}parseClassMemberWithIsStatic(e,t,n,r){let i=this.tsTryParseIndexSignature(t);if(i){e.body.push(i),t.abstract&&this.raise(q.IndexSignatureHasAbstract,t),t.accessibility&&this.raise(q.IndexSignatureHasAccessibility,t,{modifier:t.accessibility}),t.declare&&this.raise(q.IndexSignatureHasDeclare,t),t.override&&this.raise(q.IndexSignatureHasOverride,t);return}!this.state.inAbstractClass&&t.abstract&&this.raise(q.NonAbstractClassHasAbstractMethod,t),t.override&&(n.hadSuperClass||this.raise(q.OverrideNotInSubClass,t)),super.parseClassMemberWithIsStatic(e,t,n,r)}parsePostMemberNameModifiers(e){this.eat(13)&&(e.optional=!0),e.readonly&&this.match(6)&&this.raise(q.ClassMethodHasReadonly,e),e.declare&&this.match(6)&&this.raise(q.ClassMethodHasDeclare,e)}shouldParseExportDeclaration(){return this.tsIsDeclarationStart()?!0:super.shouldParseExportDeclaration()}parseConditional(e,t,n){if(!this.match(13))return e;if(n!=null){let t=this.lookaheadCharCode();if(t===44||t===61||t===58||t===41)return this.setOptionalParametersError(n),e}this.next();let r=this.startNodeAt(t);r.test=e;let i=this.state.inConditionalConsequent;return this.state.inConditionalConsequent=!0,r.consequent=this.parseMaybeAssignAllowIn(),this.state.inConditionalConsequent=i,this.expect(10),r.alternate=this.parseMaybeAssign(),this.finishNode(r,`ConditionalExpression`)}parseParenItem(e,t){let n=super.parseParenItem(e,t);if(this.eat(13)&&(n.optional=!0,this.resetEndLocation(e)),this.match(10)){let n=this.startNodeAt(t);return n.expression=e,n.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(n,`TSTypeCastExpression`)}return e}parseExportDeclaration(e){if(!this.state.isAmbientContext&&this.isContextual(121))return this.tsInAmbientContext(()=>this.parseExportDeclaration(e));let t=this.state.startLoc,n=this.eatContextual(121);if(n&&(this.isContextual(121)||!this.shouldParseExportDeclaration()))throw this.raise(q.ExpectedAmbientAfterExportDeclare,this.state.startLoc);let r=sd(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration(e);return r?((r.type===`TSInterfaceDeclaration`||r.type===`TSTypeAliasDeclaration`||n)&&(e.exportKind=`type`),n&&r.type!==`TSImportEqualsDeclaration`&&(this.resetStartLocation(r,t),r.declare=!0),r):null}parseClassId(e,t,n,r){if((!t||n)&&this.isContextual(109)){e.id=null;return}super.parseClassId(e,t,n,e.declare?1024:8331);let i=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);i&&(e.typeParameters=i)}parseClassPropertyAnnotation(e){e.optional||(this.eat(31)?e.definite=!0:this.eat(13)&&(e.optional=!0));let t=this.tsTryParseTypeAnnotation();t&&(e.typeAnnotation=t),e.definite&&(this.match(25)?this.raise(q.DeclaratorDefiniteAssertionWithInitializer,e):t||this.raise(q.DeclaratorDefiniteAssertionRequiresTypeAnnotation,e))}parseClassProperty(e){if(this.parseClassPropertyAnnotation(e),this.state.isAmbientContext&&(!e.readonly||e.typeAnnotation)&&this.match(25)&&this.raise(q.DeclareClassFieldHasInitializer,this.state.startLoc),e.abstract&&this.match(25)){let{key:t}=e;this.raise(q.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:t.type===`Identifier`&&!e.computed?t.name:`[${this.input.slice(this.offsetToSourcePos(t.start),this.offsetToSourcePos(t.end))}]`})}return super.parseClassProperty(e)}parseClassPrivateProperty(e){return e.abstract&&this.raise(q.PrivateElementHasAbstract,e),e.accessibility&&this.raise(q.PrivateElementHasAccessibility,e,{modifier:e.accessibility}),this.parseClassPropertyAnnotation(e),super.parseClassPrivateProperty(e)}parseClassAccessorProperty(e){return this.parseClassPropertyAnnotation(e),e.optional&&this.raise(q.AccessorCannotBeOptional,e),super.parseClassAccessorProperty(e)}pushClassMethod(e,t,n,r,i,a){let o=this.tsTryParseTypeParameters(this.tsParseConstModifier);o&&i&&this.raise(q.ConstructorHasTypeParameters,o);let{declare:s=!1,kind:c}=t;s&&(c===`get`||c===`set`)&&this.raise(q.DeclareAccessor,t,{kind:c}),o&&(t.typeParameters=o),super.pushClassMethod(e,t,n,r,i,a)}pushClassPrivateMethod(e,t,n,r){let i=this.tsTryParseTypeParameters(this.tsParseConstModifier);i&&(t.typeParameters=i),super.pushClassPrivateMethod(e,t,n,r)}declareClassPrivateMethodInScope(e,t){e.type!==`TSDeclareMethod`&&(e.type!==`MethodDefinition`||e.value.body!=null)&&super.declareClassPrivateMethodInScope(e,t)}parseClassSuper(e){if(super.parseClassSuper(e),e.superClass){if(e.superClass.type===`TSInstantiationExpression`){let t=e.superClass,n=t.expression;this.takeSurroundingComments(n,n.start,n.end);let r=t.typeArguments;this.takeSurroundingComments(r,r.start,r.end),e.superClass=n,e.superTypeArguments=r}else(this.match(43)||this.match(47))&&(e.superTypeArguments=this.tsParseTypeArgumentsInExpression())}this.eatContextual(109)&&(e.implements=this.tsParseHeritageClause(`implements`))}parseObjPropValue(e,t,n,r,i,a,o){let s=this.tsTryParseTypeParameters(this.tsParseConstModifier);return s&&(e.typeParameters=s),super.parseObjPropValue(e,t,n,r,i,a,o)}parseFunctionParams(e,t){let n=this.tsTryParseTypeParameters(this.tsParseConstModifier);n&&(e.typeParameters=n),super.parseFunctionParams(e,t)}parseVarId(e,t){super.parseVarId(e,t),e.id.type===`Identifier`&&!this.hasPrecedingLineBreak()&&this.eat(31)&&(e.definite=!0);let n=this.tsTryParseTypeAnnotation();n&&(e.id.typeAnnotation=n,this.resetEndLocation(e.id))}parseAsyncArrowFromCallExpression(e,t){return this.match(10)&&(e.returnType=this.tsParseTypeAnnotation()),super.parseAsyncArrowFromCallExpression(e,t)}parseMaybeAssign(e,t){let n,r,i;if(this.hasPlugin(`jsx`)&&(this.match(138)||this.match(43))){if(n=this.state.clone(),r=this.tryParse(()=>super.parseMaybeAssign(e,t),n),!r.error)return r.node;let{context:i}=this.state,a=i[i.length-1];(a===Od.j_oTag||a===Od.j_expr)&&i.pop()}if(!r?.error&&!this.match(43))return super.parseMaybeAssign(e,t);(!n||n===this.state)&&(n=this.state.clone());let a,o=this.tryParse(n=>{a=this.tsParseTypeParameters(this.tsParseConstModifier);let r=super.parseMaybeAssign(e,t);if((r.type!==`ArrowFunctionExpression`||r.extra?.parenthesized)&&n(),a?.params.length!==0&&this.resetStartLocationFromNode(r,a),r.typeParameters=a,this.hasPlugin(`jsx`)&&r.typeParameters.params.length===1&&!r.typeParameters.extra?.trailingComma){let e=r.typeParameters.params[0];e.constraint||this.raise(q.SingleTypeParameterWithoutTrailingComma,this.optionFlags&256?wu(e.loc.end,1):e,{typeParameterName:e.name.name})}return r},n);if(!o.error&&!o.aborted)return a&&this.reportReservedArrowTypeParam(a),o.node;if(!r&&(mp(!this.hasPlugin(`jsx`)),i=this.tryParse(()=>super.parseMaybeAssign(e,t),n),!i.error))return i.node;if(r?.node)return this.state=r.failState,r.node;if(o.node)return this.state=o.failState,a&&this.reportReservedArrowTypeParam(a),o.node;if(i?.node)return this.state=i.failState,i.node;throw r?.error||o.error||i?.error}reportReservedArrowTypeParam(e){e.params.length===1&&!e.params[0].constraint&&!e.extra?.trailingComma&&this.getPluginOption(`typescript`,`disallowAmbiguousJSXLike`)&&this.raise(q.ReservedArrowTypeParam,e)}parseMaybeUnary(e,t){return!this.hasPlugin(`jsx`)&&this.match(43)?this.tsParseTypeAssertion():super.parseMaybeUnary(e,t)}parseArrow(e){if(this.match(10)){let t=this.tryParse(e=>{let t=this.tsParseTypeOrTypePredicateAnnotation(10);return(this.canInsertSemicolon()||!this.match(15))&&e(),t});if(t.aborted)return;t.thrown||(t.error&&(this.state=t.failState),e.returnType=t.node)}return super.parseArrow(e)}parseFunctionParamType(e){this.eat(13)&&(e.optional=!0);let t=this.tsTryParseTypeAnnotation();return t&&(e.typeAnnotation=t),this.resetEndLocation(e),e}isAssignable(e,t){switch(e.type){case`TSTypeCastExpression`:return this.isAssignable(e.expression,t);case`TSParameterProperty`:return!0;default:return super.isAssignable(e,t)}}toAssignable(e,t=!1){switch(e.type){case`ParenthesizedExpression`:this.toAssignableParenthesizedExpression(e,t);break;case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSNonNullExpression`:case`TSTypeAssertion`:t?this.expressionScope.recordArrowParameterBindingError(q.UnexpectedTypeCastInParameter,e):this.raise(q.UnexpectedTypeCastInParameter,e),this.toAssignable(e.expression,t);break;case`AssignmentExpression`:!t&&e.left.type===`TSTypeCastExpression`&&(e.left=this.typeCastToParameter(e.left));default:super.toAssignable(e,t)}}toAssignableParenthesizedExpression(e,t){switch(e.expression.type){case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSNonNullExpression`:case`TSTypeAssertion`:case`ParenthesizedExpression`:this.toAssignable(e.expression,t);break;default:super.toAssignable(e,t)}}checkToRestConversion(e,t){switch(e.type){case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSTypeAssertion`:case`TSNonNullExpression`:this.checkToRestConversion(e.expression,!1);break;default:super.checkToRestConversion(e,t)}}isValidLVal(e,t,n,r){switch(e){case`TSTypeCastExpression`:return!0;case`TSParameterProperty`:return`parameter`;case`TSNonNullExpression`:return`expression`;case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSTypeAssertion`:return(r!==64||!n)&&[`expression`,!0];default:return super.isValidLVal(e,t,n,r)}}parseBindingAtom(){return this.state.type===74?this.parseIdentifier(!0):super.parseBindingAtom()}parseMaybeDecoratorArguments(e,t){if(this.match(43)||this.match(47)){let n=this.tsParseTypeArgumentsInExpression();if(this.match(6)){let r=super.parseMaybeDecoratorArguments(e,t);return r.typeArguments=n,r}this.unexpected(null,6)}return super.parseMaybeDecoratorArguments(e,t)}checkCommaAfterRest(e){return this.state.isAmbientContext&&this.match(8)&&this.lookaheadCharCode()===e?(this.next(),!1):super.checkCommaAfterRest(e)}isClassMethod(){return this.match(43)||super.isClassMethod()}isClassProperty(){return this.match(31)||this.match(10)||super.isClassProperty()}parseMaybeDefault(e,t){let n=super.parseMaybeDefault(e,t);return n.type===`AssignmentPattern`&&n.typeAnnotation&&n.right.start<n.typeAnnotation.start&&this.raise(q.TypeAnnotationAfterAssign,n.typeAnnotation),n}getTokenFromCode(e){if(this.state.inType){if(e===62){this.finishOp(44,1);return}if(e===60){this.finishOp(43,1);return}}super.getTokenFromCode(e)}reScan_lt_gt(){let{type:e}=this.state;e===43?(--this.state.pos,this.readToken_lt()):e===44&&(--this.state.pos,this.readToken_gt())}reScan_lt(){let{type:e}=this.state;return e===47?(this.state.pos-=2,this.finishOp(43,1),43):e}toAssignableListItem(e,t,n){let r=e[t];r.type===`TSTypeCastExpression`&&(e[t]=this.typeCastToParameter(r)),super.toAssignableListItem(e,t,n)}typeCastToParameter(e){return e.expression.typeAnnotation=e.typeAnnotation,this.resetEndLocationFromNode(e.expression,e.typeAnnotation),e.expression}shouldParseArrow(e){return this.match(10)?e.every(e=>this.isAssignable(e,!0)):super.shouldParseArrow(e)}shouldParseAsyncArrow(){return this.match(10)?!this.state.inConditionalConsequent:super.shouldParseAsyncArrow()}parseParenAndDistinguishExpression(e){let t=this.state.inConditionalConsequent;this.state.inConditionalConsequent=!1;let n=super.parseParenAndDistinguishExpression(e);return this.state.inConditionalConsequent=t,n}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName(e){if(this.match(43)||this.match(47)){let t=this.tsTryParseAndCatch(()=>this.tsParseTypeArgumentsInExpression());t&&(e.typeArguments=t)}return super.jsxParseOpeningElementAfterName(e)}getGetterSetterExpectedParamCount(e){let t=super.getGetterSetterExpectedParamCount(e),n=this.getObjectOrClassMethodParams(e)[0];return n&&this.isThisParam(n)?t+1:t}parseCatchClauseParam(){let e=super.parseCatchClauseParam(),t=this.tsTryParseTypeAnnotation();return t&&(e.typeAnnotation=t,this.resetEndLocation(e)),e}tsInAmbientContext(e){let{isAmbientContext:t,strict:n}=this.state;this.state.isAmbientContext=!0,this.state.strict=!1;try{return e()}finally{this.state.isAmbientContext=t,this.state.strict=n}}parseClass(e,t,n){let r=this.state.inAbstractClass;this.state.inAbstractClass=!!e.abstract;try{return super.parseClass(e,t,n)}finally{this.state.inAbstractClass=r}}tsParseAbstractDeclaration(e,t){if(this.match(76))return e.abstract=!0,this.maybeTakeDecorators(t,this.parseClass(e,!0,!1));if(this.isContextual(125))return this.hasFollowingLineBreak()?null:(e.abstract=!0,this.raise(q.NonClassMethodPropertyHasAbstractModifier,e),this.tsParseInterfaceDeclaration(e));throw this.unexpected(null,76)}parseMethod(e,t,n,r,i,a,o){let s=super.parseMethod(e,t,n,r,i,a,o);if((s.abstract||s.type===`TSAbstractMethodDefinition`)&&(this.hasPlugin(`estree`)?s.value:s).body){let{key:e}=s;this.raise(q.AbstractMethodHasImplementation,s,{methodName:e.type===`Identifier`&&!s.computed?e.name:`[${this.input.slice(this.offsetToSourcePos(e.start),this.offsetToSourcePos(e.end))}]`})}return s}tsParseTypeParameterName(){return this.parseIdentifier()}shouldParseAsAmbientContext(){return!!this.getPluginOption(`typescript`,`dts`)}parse(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.parse()}getExpression(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.getExpression()}parseExportSpecifier(e,t,n,r){return!t&&r?(this.parseTypeOnlyExportSpecifier(e,n),this.finishNode(e,`ExportSpecifier`)):(e.exportKind=`value`,super.parseExportSpecifier(e,t,n,r))}parseImportSpecifier(e,t,n,r,i){return!t&&r?(this.parseTypeOnlyImportSpecifier(e,n),this.finishNode(e,`ImportSpecifier`)):(e.importKind=`value`,super.parseImportSpecifier(e,t,n,r,n?4098:4096))}parseTypeOnlyImportSpecifier(e,t){let n=e.imported,r=!1;if(this.isContextual(89)){let t=this.parseIdentifier();if(this.isContextual(89)){let i=this.parseIdentifier();ld(this.state.type)?(r=!0,n=t,e.local=this.parseIdentifier()):e.local=i}else ld(this.state.type)?e.local=this.parseIdentifier():(r=!0,n=t)}else ld(this.state.type)&&(r=!0,n=this.parseIdentifier(!0),this.isContextual(89)||this.checkReservedWord(n.name,n.start,!0,!0));r&&t&&this.raise(q.TypeModifierIsUsedInTypeImports,e.imported),e.imported=n,e.importKind=r?`type`:`value`,this.checkIdentifier(e.local??=this.eatContextual(89)?this.parseIdentifier():this.cloneIdentifier(e.imported),r?4098:4096)}parseTypeOnlyExportSpecifier(e,t){let n=e.local,r=!1;if(this.isContextual(89)){let t=this.parseIdentifier();if(this.isContextual(89)){let n=this.parseIdentifier();ld(this.state.type)?(r=!0,e.local=t,e.exported=this.parseModuleExportName()):e.exported=n}else ld(this.state.type)?e.exported=this.parseModuleExportName():(r=!0,e.local=t)}else ld(this.state.type)&&(r=!0,e.local=this.parseModuleExportName());r&&t&&this.raise(q.TypeModifierIsUsedInTypeExports,n),e.exportKind=r?`type`:`value`,e.exported??=this.eatContextual(89)?this.parseModuleExportName():this.cloneIdentifier(e.local)}fillOptionalPropertiesForTSESLint(e){switch(e.type){case`ImportDeclaration`:e.phase??=null;return;case`ExpressionStatement`:e.directive??=void 0;return;case`RestElement`:e.value=void 0;case`Identifier`:case`ArrayPattern`:case`AssignmentPattern`:case`ObjectPattern`:e.decorators??=[],e.optional??=!1,e.typeAnnotation??=void 0;return;case`TSParameterProperty`:e.accessibility??=void 0,e.decorators??=[],e.override??=!1,e.readonly??=!1,e.static??=!1;return;case`TSEmptyBodyFunctionExpression`:e.body=null;case`TSDeclareFunction`:case`FunctionDeclaration`:case`FunctionExpression`:case`ClassMethod`:case`ClassPrivateMethod`:e.declare??=!1,e.returnType??=void 0,e.typeParameters??=void 0;return;case`Property`:e.optional??=!1;return;case`TSMethodSignature`:case`TSPropertySignature`:e.optional??=!1;case`TSIndexSignature`:e.accessibility??=void 0,e.readonly??=!1,e.static??=!1;return;case`TSAbstractPropertyDefinition`:case`PropertyDefinition`:case`TSAbstractAccessorProperty`:case`AccessorProperty`:e.declare??=!1,e.definite??=!1,e.readonly??=!1,e.typeAnnotation??=void 0;case`TSAbstractMethodDefinition`:case`MethodDefinition`:e.accessibility??=void 0,e.decorators??=[],e.override??=!1,e.optional??=!1;return;case`ClassExpression`:e.id??=null;case`ClassDeclaration`:e.abstract??=!1,e.declare??=!1,e.decorators??=[],e.implements??=[],e.superTypeArguments??=void 0,e.typeParameters??=void 0;return;case`TSTypeAliasDeclaration`:case`VariableDeclaration`:e.declare??=!1;return;case`VariableDeclarator`:e.definite??=!1;return;case`TSEnumDeclaration`:e.const??=!1,e.declare??=!1;return;case`TSEnumMember`:e.computed??=!1;return;case`TSImportType`:e.qualifier??=null,e.options??=null,e.typeArguments??=null;return;case`TSInterfaceDeclaration`:e.declare??=!1,e.extends??=[];return;case`TSMappedType`:e.optional??=!1,e.readonly??=void 0;return;case`TSModuleDeclaration`:e.declare??=!1,e.global??=e.kind===`global`;return;case`TSTypeParameter`:e.const??=!1,e.in??=!1,e.out??=!1;return}}chStartsBindingIdentifierAndNotRelationalOperator(e,t){if(Pd(e)){if(fp.lastIndex=t,fp.test(this.input)){let e=this.codePointAtPos(fp.lastIndex);if(!Fd(e)&&e!==92)return!1}return!0}return e===92}nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine(){let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);return this.chStartsBindingIdentifierAndNotRelationalOperator(t,e)}nextTokenIsStringLiteralOnSameLine(){let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);return t===34||t===39}};function wp(e){if(e.type!==`MemberExpression`)return!1;let{computed:t,property:n}=e;return t&&n.type!==`StringLiteral`&&(n.type!==`TemplateLiteral`||n.expressions.length>0)?!1:Op(e.object)}function Tp(e,t){let{type:n}=e;if(e.extra?.parenthesized)return!1;if(t){if(n===`Literal`){let{value:t}=e;if(typeof t==`string`||typeof t==`boolean`)return!0}}else if(n===`StringLiteral`||n===`BooleanLiteral`)return!0;return!!(Ep(e,t)||Dp(e,t)||n===`TemplateLiteral`&&e.expressions.length===0||wp(e))}function Ep(e,t){return t?e.type===`Literal`&&(typeof e.value==`number`||`bigint`in e):e.type===`NumericLiteral`||e.type===`BigIntLiteral`}function Dp(e,t){if(e.type===`UnaryExpression`){let{operator:n,argument:r}=e;if(n===`-`&&Ep(r,t))return!0}return!1}function Op(e){return e.type===`Identifier`?!0:e.type!==`MemberExpression`||e.computed?!1:Op(e.object)}function kp(e,t=[]){let n=new Map;for(let t of e)n.set(t,!0);for(let e of t)n.set(e,!1);return n}var Ap=Lu`placeholders`({ClassNameIsRequired:`A class name is required.`,UnexpectedSpace:`Unexpected space in placeholder.`}),jp=e=>class extends e{parsePlaceholder(e){if(this.match(129)){let t=this.startNode();return this.next(),this.assertNoSpace(),t.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(129),this.finishPlaceholder(t,e)}}finishPlaceholder(e,t){let n=e;return(!n.expectedNode||!n.type)&&(n=this.finishNode(n,`Placeholder`)),n.expectedNode=t,n}getTokenFromCode(e){e===37&&this.input.charCodeAt(this.state.pos+1)===37?this.finishOp(129,2):super.getTokenFromCode(e)}parseExprAtom(e){return this.parsePlaceholder(`Expression`)||super.parseExprAtom(e)}parseIdentifier(e){return this.parsePlaceholder(`Identifier`)||super.parseIdentifier(e)}checkReservedWord(e,t,n,r){e!==void 0&&super.checkReservedWord(e,t,n,r)}cloneIdentifier(e){let t=super.cloneIdentifier(e);return t.type===`Placeholder`&&(t.expectedNode=e.expectedNode),t}cloneStringLiteral(e){return e.type===`Placeholder`?this.cloneIdentifier(e):super.cloneStringLiteral(e)}parseBindingAtom(){return this.parsePlaceholder(`Pattern`)||super.parseBindingAtom()}isValidLVal(e,t,n,r){return e===`Placeholder`||super.isValidLVal(e,t,n,r)}toAssignable(e,t){e&&e.type===`Placeholder`&&e.expectedNode===`Expression`?e.expectedNode=`Pattern`:super.toAssignable(e,t)}chStartsBindingIdentifier(e,t){if(super.chStartsBindingIdentifier(e,t))return!0;let n=this.nextTokenStart();return this.input.charCodeAt(n)===37&&this.input.charCodeAt(n+1)===37}verifyBreakContinue(e,t){e.label?.type!==`Placeholder`&&super.verifyBreakContinue(e,t)}parseExpressionStatement(e,t){if(t.type!==`Placeholder`||t.extra?.parenthesized)return super.parseExpressionStatement(e,t);if(this.match(10)){let n=e;return n.label=this.finishPlaceholder(t,`Identifier`),this.next(),n.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(n,`LabeledStatement`)}this.semicolon();let n=e;return n.name=t.name,this.finishPlaceholder(n,`Statement`)}parseBlock(e,t,n){return this.parsePlaceholder(`BlockStatement`)||super.parseBlock(e,t,n)}parseFunctionId(e){return this.parsePlaceholder(`Identifier`)||super.parseFunctionId(e)}parseClass(e,t,n){let r=t?`ClassDeclaration`:`ClassExpression`;this.next();let i=this.state.strict,a=this.parsePlaceholder(`Identifier`);if(a){if(this.match(77)||this.match(129)||this.match(2))e.id=a;else if(n||!t)return e.id=null,e.body=this.finishPlaceholder(a,`ClassBody`),this.finishNode(e,r);else throw this.raise(Ap.ClassNameIsRequired,this.state.startLoc)}else this.parseClassId(e,t,n);return super.parseClassSuper(e),e.body=this.parsePlaceholder(`ClassBody`)||super.parseClassBody(!!e.superClass,i),this.finishNode(e,r)}parseExport(e,t){let n=this.parsePlaceholder(`Identifier`);if(!n)return super.parseExport(e,t);let r=e;if(!this.isContextual(94)&&!this.match(8))return r.specifiers=[],r.source=null,r.declaration=this.finishPlaceholder(n,`Declaration`),this.finishNode(r,`ExportNamedDeclaration`);this.expectPlugin(`exportDefaultFrom`);let i=this.startNode();return i.exported=n,r.specifiers=[this.finishNode(i,`ExportDefaultSpecifier`)],super.parseExport(r,t)}isExportDefaultSpecifier(){if(this.match(61)){let e=this.nextTokenStart();if(this.isUnparsedContextual(e,`from`)&&this.input.startsWith(Sd(129),this.nextTokenStartSince(e+4)))return!0}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier(e,t){return e.specifiers?.length?!0:super.maybeParseExportDefaultSpecifier(e,t)}checkNamedExport(){}parseImport(e){let t=this.parsePlaceholder(`Identifier`);if(!t)return super.parseImport(e);if(e.specifiers=[],!this.isContextual(94)&&!this.match(8))return e.source=this.finishPlaceholder(t,`StringLiteral`),this.semicolon(),this.finishNode(e,`ImportDeclaration`);let n=this.startNodeAtNode(t);return n.local=t,e.specifiers.push(this.finishNode(n,`ImportDefaultSpecifier`)),this.eat(8)&&(this.maybeParseStarImportSpecifier(e)||this.parseNamedImportSpecifiers(e)),this.expectContextual(94),e.source=this.parseImportSource(),this.semicolon(),this.finishNode(e,`ImportDeclaration`)}parseImportSource(){return this.parsePlaceholder(`StringLiteral`)||super.parseImportSource()}assertNoSpace(){this.state.start>this.offsetToSourcePos(this.state.lastTokEndLoc.index)&&this.raise(Ap.UnexpectedSpace,this.state.lastTokEndLoc)}},Mp=e=>class extends e{parseV8Intrinsic(){if(this.match(50)){let e=this.state.startLoc,t=this.startNode();if(this.next(),sd(this.state.type)){let e=this.parseIdentifierName(),n=this.createIdentifier(t,e);if(this.castNodeTo(n,`V8IntrinsicIdentifier`),this.match(6))return n}this.unexpected(e)}}parseExprAtom(e){return this.parseV8Intrinsic()||super.parseExprAtom(e)}},Np=[`fsharp`,`hack`],Pp=[`^^`,`@@`,`^`,`%`,`#`];function Fp(e){if(e.has(`decorators`)&&e.has(`decorators-legacy`))throw Error(`Cannot use the decorators and decorators-legacy plugin together`);if(e.has(`flow`)&&e.has(`typescript`))throw Error(`Cannot combine flow and typescript plugins.`);if(e.has(`placeholders`)&&e.has(`v8intrinsic`))throw Error(`Cannot combine placeholders and v8intrinsic plugins.`);if(e.has(`pipelineOperator`)){let t=e.get(`pipelineOperator`).proposal;if(!Np.includes(t)){let e=Np.map(e=>`"${e}"`).join(`, `);throw Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${e}.`)}if(t===`hack`){if(e.has(`placeholders`))throw Error(`Cannot combine placeholders plugin and Hack-style pipes.`);if(e.has(`v8intrinsic`))throw Error(`Cannot combine v8intrinsic plugin and Hack-style pipes.`);let t=e.get(`pipelineOperator`).topicToken;if(!Pp.includes(t)){let e=Pp.map(e=>`"${e}"`).join(`, `);throw Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${e}.`)}}}if(e.has(`moduleAttributes`))throw Error("`moduleAttributes` has been removed in Babel 8, please migrate to import attributes instead.");if(e.has(`importAssertions`))throw Error("`importAssertions` has been removed in Babel 8, please use import attributes instead.");if(e.has(`deprecatedImportAssert`)?console.warn("`deprecatedImportAssert` has been removed in Babel 8, please use import attributes instead."):e.has(`importAttributes`)&&e.get(`importAttributes`).deprecatedAssertSyntax&&console.warn("The 'importAttributes' plugin has been removed in Babel 8. Please migrate any usage of `assert`-style attributes to `with`."),e.has(`recordAndTuple`))throw Error(`The 'recordAndTuple' plugin has been removed in Babel 8. Please remove it from your configuration.`);if(e.has(`asyncDoExpressions`)&&!e.has(`doExpressions`)){let e=Error(`'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.`);throw e.missingPlugins=`doExpressions`,e}if(e.has(`optionalChainingAssign`)&&e.get(`optionalChainingAssign`).version!==`2023-07`)throw Error(`The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.`);if(e.has(`discardBinding`)&&e.get(`discardBinding`).syntaxType!==`void`)throw Error(`The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.`);if(e.has(`decimal`))throw Error(`The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.`);if(e.has(`importReflection`))throw Error(`The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.`)}var Ip={estree:Vu,jsx:_f,flow:of,typescript:Cp,v8intrinsic:Mp,placeholders:jp},Lp=Object.keys(Ip),Rp=class extends dp{constructor(e,t,n){let r=zu(e);super(r,t),this.options=r,this.initializeScopes(),this.plugins=n,this.filename=r.sourceFilename,this.startIndex=r.startIndex;let i=0;r.allowAwaitOutsideFunction&&(i|=1),r.allowReturnOutsideFunction&&(i|=2),r.allowImportExportEverywhere&&(i|=8),r.allowSuperOutsideMethod&&(i|=16),r.allowUndeclaredExports&&(i|=64),r.allowNewTargetOutsideFunction&&(i|=4),r.allowYieldOutsideFunction&&(i|=32),r.ranges&&(i|=128),r.locations===!0&&(i|=256),r.tokens&&(i|=512),r.createImportExpressions&&(i|=1024),r.createParenthesizedExpressions&&(i|=2048),r.errorRecovery&&(i|=4096),r.attachComment&&(i|=8192),r.annexB&&(i|=16384),this.optionFlags=i}getScopeHandler(){return Yd}parse(){this.enterInitialScopes();let e=this.startNode(),t=this.startNode();this.nextToken(),e.errors=[];let n=this.parseTopLevel(e,t);return n.errors=this.state.errors,n.comments.length=this.state.commentsLen,n}};function zp(e,t){if(t?.sourceType===`unambiguous`){t={...t};try{t.sourceType=`module`;let n=Vp(t,e),r=n.parse();if(n.sawUnambiguousESM)return r;if(n.ambiguousScriptDifferentAst)try{return t.sourceType=`script`,Vp(t,e).parse()}catch{}else r.program.sourceType=`script`;return r}catch(n){try{return t.sourceType=`script`,Vp(t,e).parse()}catch{}throw n}}return Vp(t,e).parse()}function Bp(e){let t={};for(let n of Object.keys(e))t[n]=Ed(e[n]);return t}Bp(od);function Vp(e,t){let n=Rp,r=new Map;if(e?.plugins){for(let t of e.plugins){let e,n;typeof t==`string`?e=t:[e,n]=t,r.has(e)||r.set(e,n||{})}Fp(r),n=Up(r)}return new n(e,t,r)}var Hp=new Map;function Up(e){let t=[];for(let n of Lp)e.has(n)&&t.push(n);let n=t.join(`|`),r=Hp.get(n);if(!r){r=Rp;for(let e of t)r=Ip[e](r);Hp.set(n,r)}return r}var Wp=e=>e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``,Gp=(e,t)=>{let n=t.startsWith(`/`)||e===``?[]:e.split(`/`);for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(n.length===0)return;n.pop()}else n.push(e)}return n.length===0?void 0:n.join(`/`)},Kp=class{items=[];locate(e,t){let n=e.position(t.start);return{fileName:e.path,lineNumber:n.line,columnNumber:n.column}}add(e,t,n,r,i,a=`error`){this.report({code:n,severity:a,message:r,...i===void 0?{}:{fix:i},origins:[this.locate(e,t)]})}report(e){let t=Ss[e.code];this.items.push({...e,...t.upgrade===void 0?{}:{upgrade:t.upgrade}})}get blocking(){return this.items.some(e=>e.severity===`error`)}},qp=e=>{let t=0,n=e.flatMap(e=>{let n=t;return t+=e.rules.length+1,e.rules.map(e=>({...e,order:n+e.order}))}),r={},i=[],a=new Map,o=e.flatMap(e=>e.diagnostics);for(let t of e){Object.assign(r,t.variables),i.push(...t.headAtRules);for(let e of t.fontFaces)a.set(e.css,e)}return{rules:n,headAtRules:i,fontFaces:[...a.values()],variables:r,diagnostics:o}},Jp=e=>is(e)&&typeof e.type==`string`&&typeof e.start==`number`&&typeof e.end==`number`,J=(e,t)=>{let n=e[t];return Jp(n)?n:void 0},Yp=(e,t)=>{let n=e[t];return Array.isArray(n)?n.filter(Jp):[]},Y=(e,t)=>{let n=e[t];return typeof n==`string`?n:void 0},Xp=e=>{if(e!==void 0){if(e.type===`Identifier`)return Y(e,`name`);if(e.type===`StringLiteral`)return Y(e,`value`)}},Zp=e=>{let t=e;for(;;){if(t.type===`ParenthesizedExpression`||t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`||t.type===`TSTypeAssertion`||t.type===`TypeCastExpression`){let e=J(t,`expression`);if(e===void 0)return t;t=e;continue}return t}},Qp=class extends Error{path;line;column;constructor(e,t,n,r){super(t),this.name=`SourceSyntaxError`,this.path=e,this.line=n,this.column=r}},$p=(e,t)=>{let n=bs(t),r=e=>xs(n,e),i;try{i=zp(t,{plugins:[`typescript`,`jsx`],sourceType:`module`}).program}catch(t){let n=is(t)&&is(t.loc)?t.loc:void 0,r=typeof n?.line==`number`?n.line:1,i=typeof n?.column==`number`?n.column+1:1;throw new Qp(e,t instanceof Error?t.message.replace(/\s*\(\d+:\d+\)\s*$/,``):``,r,i)}if(!Jp(i))throw new Qp(e,`The file did not parse to a program.`,1,1);return{path:e,source:t,program:i,position:r}},em=(e,t)=>e===``?t:`${e}.${t}`,tm=e=>{switch(e.k){case`path`:return e.path===``?void 0:{bind:e.path};case`value`:return e.value;default:return}},nm=e=>e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`,rm=e=>typeof e!=`object`||!e||!(`el`in e||`each`in e||`raw`in e||`preheader`in e||`if`in e&&Array.isArray(e.then)),im=[`transactional`,`promotional`,`service_implicit`],am=[`marketing`,`utility`,`authentication`],om=[`text`,`image`,`video`,`document`],sm=[`category`],cm=[`name`,`language`,`category`],lm=e=>typeof e==`object`&&!!e&&`concat`in e,um=e=>{let t=[],n=[],r=``,i=e=>{if(e===null||typeof e==`boolean`)return;if(typeof e==`string`){r+=e;return}if(typeof e==`number`){r+=String(e);return}if(typeof e==`object`&&lm(e)){for(let t of e.concat)i(t);return}if(typeof e==`object`&&(`el`in e||`each`in e||`raw`in e))throw TypeError(`A WhatsApp text part holds text and values only.`);if(typeof e==`object`&&`if`in e&&Array.isArray(e.then))throw TypeError(`A WhatsApp text part cannot branch.`);let a=e,o=JSON.stringify(a),s=n.indexOf(o);s<0&&(s=n.length,n.push(o),t.push(a)),r+=`{{${s+1}}}`};for(let t of e)i(t);return{template:r,params:t}},dm=(e,t,n)=>{if(Math.abs(e.length-t.length)>n)return n+1;let r=Array.from({length:t.length+1},(e,t)=>t);for(let n=1;n<=e.length;n++){let i=[n];for(let a=1;a<=t.length;a++)i[a]=Math.min(i[a-1]+1,r[a]+1,r[a-1]+(e[n-1]===t[a-1]?0:1));r=i}return r[t.length]},fm=(e,t)=>{let n=e.toLowerCase(),r=t.find(e=>e.toLowerCase()===n);if(r!==void 0&&r!==e)return r;let i=Math.max(1,Math.min(3,Math.floor(e.length/3))),a,o=i+1;for(let e of t){let t=dm(n,e.toLowerCase(),i);t<o&&(a=e,o=t)}return a},pm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),mm=(e,t,n=0)=>{let r=t.$ref;if(typeof r!=`string`||n>16)return t;if(r===`#`)return e;let i=e;for(let e of r.replace(/^#\//,``).split(`/`)){if(!pm(i))return t;i=i[e.replace(/~1/g,`/`).replace(/~0/g,`~`)]}return pm(i)?mm(e,i,n+1):t},hm=(e,t)=>{let n=mm(e,t);return[n,...[n.anyOf,n.oneOf,n.allOf].flatMap(t=>Array.isArray(t)?t.filter(pm).flatMap(t=>hm(e,t)):[])]},gm=(e,t)=>{if(t===void 0)return`unknown`;let n=new Set;for(let r of hm(e,t)){let e=r.type;if(typeof e==`string`)n.add(e);else if(Array.isArray(e))for(let t of e)typeof t==`string`&&n.add(t);if(r.const!==void 0&&n.add(typeof r.const),Array.isArray(r.enum))for(let e of r.enum)n.add(typeof e)}if(n.delete(`null`),n.size!==1)return`unknown`;let[r]=n;switch(r){case`string`:return`string`;case`number`:case`integer`:return`number`;case`boolean`:return`boolean`;case`array`:return`array`;case`object`:return`object`;default:return`unknown`}},_m=(e,t,n)=>{let r=[],i=!0,a;for(let o of hm(e,t)){if(pm(o.properties)&&(i=!1,r.push(...Object.keys(o.properties)),Object.hasOwn(o.properties,n))){let e=o.properties[n],t=Array.isArray(o.required)&&o.required.includes(n);a={schema:pm(e)?e:void 0,required:a?.required===!0||t}}if(o.type===`object`&&!pm(o.properties)&&o.additionalProperties===!1&&(i=!1),(Array.isArray(o.items)||pm(o.items))&&/^\d+$/.test(n))return i=!1,{found:!0,schema:pm(o.items)?o.items:void 0,required:!0,names:r,open:!1};pm(o.additionalProperties)&&a===void 0&&(a={schema:o.additionalProperties,required:!1},i=!1)}return a===void 0?{found:!1,schema:void 0,required:!1,names:r,open:i}:{found:!0,schema:a.schema,required:a.required,names:r,open:!1}},vm=(e,t)=>t.size===0?e:{...e,guards:new Set([...e.guards,...t])},ym=e=>{let t=e.split(`.`);return t.map((e,n)=>t.slice(0,n+1).join(`.`))},bm=e=>typeof e==`object`&&e&&`bind`in e?e.bind:void 0,xm=(e,t)=>{let n=e=>e===void 0?new Set:new Set(ym(e));if(`present`in e)return t?n(e.present):new Set;if(`truthy`in e){let r=e.truthy,i=bm(r)??(typeof r==`object`&&r&&`length`in r?bm(r.length):void 0);return t?n(i):new Set}if(`not`in e)return xm(e.not,!t);if(`and`in e||`or`in e){let n=`and`in e?e.and:e.or,r=`and`in e?t:!t,i=n.map(e=>xm(e,t));if(r)return new Set(i.flatMap(e=>[...e]));let[a,...o]=i;return new Set([...a??[]].filter(e=>o.every(t=>t.has(e))))}let[r,i]=e.args,a=bm(r)??bm(i),o=bm(r)===void 0?r:i;if(a===void 0)return new Set;let s=o===null,c=typeof o!=`object`||!o||`concat`in o||`format`in o||`op`in o||`length`in o||`count`in o;return e.cmp===`eq`?!c||t===s?new Set:n(a):e.cmp===`ne`?!c||t!==s?new Set:n(a):t?n(a):new Set},Sm=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=`${e.code}\0${e.message}\0${e.src?.join(`,`)??``}`;i.has(t)||(i.add(t),r.push(e))},o=e=>e.startsWith(`$`)?e.slice(1):`input.${e}`,s=(t,n,r)=>{let i=t.split(`.`),a=i[0],o;if(a.startsWith(`$`)){if(!n.variables.has(a.slice(1)))return;o=n.variables.get(a.slice(1))}else{let i=_m(e,e,a);if(!i.found)return c(a,i,``,r,t);!i.required&&!n.guards.has(a)&&l(a,r),o=i.schema}for(let a=1;a<i.length;a++){if(o===void 0)return;let s=i[a],u=_m(e,o,s),d=i.slice(0,a).join(`.`);if(!u.found)return u.open?void 0:c(s,u,d,r,t);let f=i.slice(0,a+1).join(`.`);!u.required&&!n.guards.has(f)&&l(f,r),o=u.schema}return o},c=(e,t,n,r,i)=>{if(t.open)return;let s=fm(e,t.names),c=n===``?`input`:o(n);a({code:`unknown-field`,message:`\`${n===``?`input`:o(n)}.${e}\` is not in the schema${t.names.length===0?``:` (${c} has ${t.names.map(e=>`\`${e}\``).join(`, `)})`}.`,...s===void 0?{fix:`Add \`${e}\` to the schema, or bind a field it declares.`}:{fix:`Did you mean \`${n===``?`input`:o(n)}.${s}\`?`},src:r})},l=(e,t)=>{a({code:`unguarded-optional`,message:`\`${o(e)}\` is optional and is read outside a guard, so a send without it would render a blank.`,fix:`Guard it: {${o(e)} && …}, or make the field required in the schema.`,src:t})},u=(t,n,r)=>{if(typeof t==`string`)return`string`;if(typeof t==`number`)return`number`;if(typeof t==`boolean`)return`boolean`;if(t===null)return`unknown`;if(`bind`in t)return gm(e,s(t.bind,n,r));if(`lit`in t)return`unknown`;if(`concat`in t){for(let e of t.concat)u(e,n,r);return`string`}if(`format`in t)return f(t.format,t.args,n,r),`string`;if(`if`in t){p(t.if,n,r);let e=u(t.then,vm(n,xm(t.if,!0)),r);return u(t.else,vm(n,xm(t.if,!1)),r),e}if(`op`in t){for(let e of t.args)d(e,`number`,n,r,`arithmetic`);return`number`}if(`length`in t)return u(t.length,n,r),`number`;if(`count`in t){let i=bm(t.count),a;if(i===void 0)u(t.count,n,r);else{let t=s(i,n,r);if(t!==void 0)for(let n of hm(e,t))pm(n.items)&&(a=mm(e,n.items))}let o=new Map(n.variables).set(t.as.replace(/^\$/,``),a);return p(t.where,{...n,variables:o},r),`number`}return`unknown`},d=(e,t,n,r,i)=>{let s=u(e,n,r);if(s===`unknown`||s===t)return;let c=bm(e);a({code:`invalid-binding-type`,message:`${c===void 0?`This value`:`\`${o(c)}\``} is ${s===`array`?`an array`:`a ${s}`}, and ${i} needs ${t===`array`?`an array`:`a ${t}`}.`,fix:t===`number`?`Bind a number field, or send the number in the payload.`:`Bind a ${t} field.`,src:r})},f=(e,t,n,r)=>{let i={money:[`number`,`string`,`string`],number:[`number`,void 0,`string`],date:[`string`,`string`,`string`],time:[`string`,`string`,`string`],plural:[`number`,void 0,`string`],list:[`array`,`string`]};for(let[a,o]of t.entries()){let t=i[e]?.[a];t===void 0?u(o,n,r):d(o,t,n,r,`\`fmt.${e}\``)}},p=(e,t,n)=>{if(`present`in e){m(e.present,t,n);return}if(`truthy`in e){let r=e.truthy,i=bm(r);i===void 0?h(r,t,n):m(i,t,n);return}if(`not`in e){p(e.not,t,n);return}if(`and`in e){let r=t;for(let t of e.and)p(t,r,n),r=vm(r,xm(t,!0));return}if(`or`in e){let r=t;for(let t of e.or)p(t,r,n),r=vm(r,xm(t,!1));return}let r=e.cmp===`lt`||e.cmp===`gt`||e.cmp===`le`||e.cmp===`ge`,i=r&&e.args.every(e=>u(e,t,n)===`string`);for(let a of e.args){let e=bm(a);i||(e!==void 0&&!r?m(e,t,n):r?d(a,`number`,t,n,`a comparison`):h(a,t,n))}},m=(e,t,n)=>{s(e,{...t,guards:new Set([...t.guards,...ym(e)])},n)},h=(e,t,n)=>{if(typeof e==`object`&&e&&`length`in e){let r=bm(e.length);if(r!==void 0){m(r,t,n);return}}u(e,t,n)},g=(e,t,n,r)=>{let i=u(e,t,n);if(i===`array`||i===`object`){let t=bm(e);a({code:`invalid-binding-type`,message:`${t===void 0?`This value`:`\`${o(t)}\``} is ${i===`array`?`an array`:`an object`}, and ${r} takes a string or a number.`,fix:i===`array`?`Render the items with .map, or bind one of their fields.`:`Bind one of its fields.`,src:n})}},_=(e,t,n)=>{if(e===void 0||typeof e==`string`)return;if(Array.isArray(e)){for(let[,r]of e)g(r,t,n,`a style value`);return}let r=e;p(r.if,t,n),_(r.then,vm(t,xm(r.if,!0)),n),_(r.else,vm(t,xm(r.if,!1)),n)},v=(t,n,r)=>{for(let i of t){if(rm(i)){g(i,n,r,`text`);continue}if(`el`in i){for(let e of Object.values(i.attrs??{}))g(e,n,i.src,`an attribute`);_(i.style,n,i.src),v(i.children??[],n,i.src)}else if(`if`in i)p(i.if,n,i.src),v(i.then,vm(n,xm(i.if,!0)),i.src??r),v(i.else??[],vm(n,xm(i.if,!1)),i.src??r);else if(`each`in i){let t=bm(i.each),c;if(t!==void 0){c=s(t,n,i.src);let r=gm(e,c);r!==`array`&&r!==`unknown`&&a({code:`invalid-binding-type`,message:`\`${o(t)}\` is ${r===`object`?`an object`:`a ${r}`}, and a loop needs an array.`,fix:`Loop over an array field.`,src:i.src})}else u(i.each,n,i.src);let l;if(c!==void 0)for(let t of hm(e,c))pm(t.items)&&(l=mm(e,t.items));let d=i.as.replace(/^\$/,``);i.where!==void 0&&p(i.where,{...n,variables:new Map(n.variables).set(d,l)},i.src??r);let f=new Map(n.variables);f.set(d,i.chunk===void 0||l===void 0?l:{type:`array`,items:l}),i.index!==void 0&&f.set(i.index.replace(/^\$/,``),{type:`integer`});let m=i.where===void 0?n:vm(n,xm(i.where,!0));v(i.children,{...m,variables:f},i.src??r)}else if(`raw`in i)for(let e of i.raw)typeof e!=`string`&&g(`attr`in e?e.attr:e.text,n,i.src,`markup`)}},y={variables:new Map,guards:new Set};v(t,y);for(let e of n)g(e,y,void 0,`the subject or preheader`);return r},Cm=(e,t)=>{let n=e=>e.flatMap(e=>rm(e)?[e]:`if`in e?[...n(e.then),...n(e.else??[])]:`each`in e?n(e.children):[e]),r=e=>{for(let t of e)rm(t)||(`el`in t?i(t):`if`in t?(r(t.then),r(t.else??[])):`each`in t&&r(t.children))},i=e=>{let i=Wc(e.el),a=n(e.children??[]);if(i!==void 0){if(i.content===`void`&&a.length>0)t({code:`void-element-children`,message:`<${e.el}> cannot have children.`,src:e.src});else if(i.content===`text`||i.content===`raw`)for(let n of a)!rm(n)&&!(`raw`in n)&&t({code:`invalid-content`,message:`<${e.el}> accepts text only.`,src:e.src});else if(i.childElements!==void 0)for(let n of a)if(rm(n)){if(typeof n==`string`&&n.trim()===``)continue;t({code:`invalid-content`,message:`<${e.el}> cannot contain text directly; put it inside <${i.childElements[0]}>.`,src:e.src})}else`el`in n&&!i.childElements.includes(n.el)&&t({code:`invalid-content`,message:`<${e.el}> accepts only ${i.childElements.map(e=>`<${e}>`).join(`, `)}; found <${n.el}>.`,src:n.src??e.src});r(e.children??[])}};r(e)},wm=``,Tm=``,Em=/(\d+)/g,Dm=class{entries=[];value(e){return typeof e==`string`?e:(this.entries.push({value:e}),`${wm}${this.entries.length-1}${Tm}`)}nodes(e){return this.entries.push({nodes:e}),`${wm}${this.entries.length-1}${Tm}`}parse(e){let t=[],n=0;for(let r of e.matchAll(Em)){r.index>n&&t.push(e.slice(n,r.index));let i=this.entries[Number(r[1])];i!==void 0&&t.push(i),n=r.index+r[0].length}return n<e.length&&t.push(e.slice(n)),t}toValue(e){let t=this.parse(e);if(t.length===0)return``;let n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(`value`in e)n.push(e.value);else return;return n.length===1?n[0]:{concat:n}}},Om=(e,t)=>nm(t)?t:e.value(t),km=e=>e===void 0?{}:{src:e},Am=(e,t)=>{let n=[],r=!1,i,a=``,o=()=>{a!==``&&n.push(a),a=``};for(let s=0;s<t.length;s++){let c=t[s];if(c===wm){let i=t.indexOf(Tm,s),a=e.parse(t.slice(s,i+1))[0];if(i>s&&a!==void 0&&typeof a!=`string`&&`value`in a){o(),n.push(r?{attr:a.value}:{text:a.value}),s=i;continue}}!r&&c===`<`?r=!0:r&&i===void 0&&(c===`"`||c===`'`)?i=c:r&&i===c?i=void 0:r&&i===void 0&&c===`>`&&(r=!1),a+=c}return o(),n},jm=(e,t)=>{if(!is(t))return;let n=[];for(let[r,i]of Object.entries(t))if(i!=null){if(typeof i==`number`)n.push([r,i]);else if(typeof i==`string`){let t=e.toValue(i);t!==void 0&&n.push([r,t])}}return n},Mm=(e,t,n)=>{if(e===null)return[];switch(e.type){case`Text`:{let n=[];for(let r of t.parse(e.value))typeof r==`string`?n.push(r):`value`in r?n.push(r.value):n.push(...r.nodes);return n}case`Fragment`:return e.children.flatMap(e=>Mm(e,t,n));case`Raw`:return[{raw:Am(t,e.html),...e.text===``?{}:{text:e.text},...km(n)}];case`Element`:{let r={},i;for(let[n,a]of Object.entries(e.props)){if(n===`key`||a==null||a===!1)continue;if(n===`style`){i=jm(t,a);continue}let e=n===`className`?`class`:n;typeof a==`string`?r[e]=t.toValue(a)??a:(typeof a==`number`||a===!0)&&(r[e]=a)}let a=e.props[Ac]===!0;return[{el:e.tag,...Object.keys(r).length===0?{}:{attrs:r},...i===void 0||Array.isArray(i)&&i.length===0?{}:{style:i},...e.children.length===0?{}:{children:e.children.flatMap(e=>Mm(e,t,n))},...a?{reserved:!0}:{},...km(n)}]}}},Nm={Button:[`height`,`paddingX`,`borderRadius`,`borderWidth`,`fontSize`,`width`],Spacer:[`height`],Divider:[`thickness`],BrandLogo:[`width`]},Pm={Email:gl,Section:_l,Columns:bl,Column:xl,Button:Ol,Spacer:kl,Divider:Al,Image:jl,Link:Ml},Fm=(e,t,n,r)=>{switch(r.k){case`object`:{let n={};for(let[i,a]of r.fields)n[i]=Fm(e,t,i,a);return n}case`nodes`:e.lowerer.error(e.ctx,e.node,`dynamic-expression`,`<${e.name} ${n}> takes text, not markup.`);return;default:{let i=tm(r);if(i===void 0){e.lowerer.error(e.ctx,e.node,`dynamic-expression`,`<${e.name} ${n}> cannot be the input as a whole.`,`Bind one field.`);return}return Om(t,i)}}},Im=(e,t)=>{let n=t.length===1?t[0]:void 0;return n!==void 0&&rm(n)&&n!==null&&typeof n!=`boolean`?typeof n==`string`?n:e.value(n):t.map(t=>rm(t)?typeof t==`string`?t:e.value(t):e.nodes([t]))},Lm=(e,t)=>{if(e!==void 0)return vl(e);let n={length:t};return{concat:[{op:`/`,args:[{op:`-`,args:[100,{op:`%`,args:[100,n]}]},n]},`%`]}},Rm=(e,t)=>{let{lowerer:n,ctx:r,node:i}=e,a=t.get(`each`),o=a===void 0?void 0:tm(a);if(o===void 0){n.error(r,i,`invalid-columns-each`,`<Columns each> takes a list from the input.`,`Write each={input.items}.`);return}let s=t.get(`per`),c=s?.k===`value`?s.value:void 0;if(s!==void 0&&!(typeof c==`number`&&Number.isInteger(c)&&c>=1)){n.error(r,i,`invalid-columns-per`,`<Columns per> is a whole number of cells, one or more.`,`Write per={2}.`);return}let l=typeof c==`number`?c:void 0,u=Yp(i,`children`).filter(e=>e.type!==`JSXText`||(Y(e,`value`)??``).trim()!==``),d=u.length===1?u[0]:void 0,f=d?.type===`JSXExpressionContainer`?J(d,`expression`):void 0,p=f===void 0?void 0:Zp(f);if(p===void 0||!/Function/.test(p.type)){n.error(r,i,`invalid-columns-each`,`<Columns each> takes a function of one item as its only child.`,`Write {(item) => <Column>…</Column>}.`);return}let m=l===void 0?void 0:n.freshName(r,`row`),h={...r,loops:m===void 0?r.loops:[...r.loops,m],columnWidth:Lm(l,o)},g=n.eachOver(h,i,m===void 0?o:{bind:`$${m}`},p);if(g!==void 0)return{cells:g,wrap:e=>m===void 0||l===void 0?e:[{each:o,as:m,chunk:l,children:e,src:n.src(r.module,i)}]}},zm=e=>{let{lowerer:t,ctx:n,node:r,binding:i}=e,a=i.specifier;if(i.kind===`markup`&&(a===`@samva/markup/sms`||a===`@samva/markup/whatsapp`)){let i=e.channel?.(e);return i===void 0?(t.error(n,r,`wrong-channel`,`<${e.name}> belongs in the ${a.split(`/`).pop()} body of a template.`,"Write it in the `sms` or `whatsapp` function of defineTemplate."),[]):i}let o=i.imported,s=i.kind===`markup`&&a===`@samva/markup/email`,c=i.kind===`brand`;if(!(s||c))return t.error(n,r,`unknown-component`,`<${e.name}> is not a component the profile can read.`,`Import components from @samva/markup/email, ${e.brandPlugin.specifier}, or the project.`),[];let l;if(s)l=Pm[o];else{if(e.brand===void 0)return t.error(n,r,`brand-unavailable`,`<${e.name}> comes from ${i.specifier}, and this build has no brand to resolve it.`,`Compile with a brand, or remove the brand components.`),[];let a=bu(e.brand,e.brandPlugin);l=o===`BrandLogo`?a.BrandLogo:o===`BrandFooter`?a.BrandFooter:void 0}if(l===void 0||!Object.hasOwn(Pm,o)&&s)return t.error(n,r,`unknown-component`,`\`${o}\` is not an email component.`,`Use one of ${Object.keys(Pm).join(`, `)}, BrandLogo or BrandFooter.`),[];let u=t.attributeBindings(n,e.attributes);if(u===void 0)return[];let d=u,f=e=>e,p,m={...n,columnWidth:void 0};if(o===`Columns`&&u.has(`each`)){let t=Rm(e,u);if(t===void 0)return[];d=new Map([...u].filter(([e])=>e!==`each`&&e!==`per`)),p=[t.cells],f=t.wrap}else p=t.jsxChildren(m,r);let h=new Dm,g={};for(let[t,n]of d)g[t]=Fm(e,h,t,n);for(let i of Nm[o]??[]){let a=g[i];if(typeof a==`string`&&!/^-?\d+(\.\d+)?$/.test(a)&&a!==void 0)return t.error(n,r,`dynamic-numeric-prop`,`<${e.name} ${i}> sizes the layout at compile time, so it must be a number literal.`,`Write ${i}={44}.`),[]}if(o===`Column`&&g.width===void 0&&n.columnWidth!==void 0&&(g.width=Om(h,n.columnWidth)),p.length>0&&(g.children=Im(h,p)),o===`Button`&&typeof g.children==`string`&&g.children!==``&&g.width===void 0&&g.height!==void 0&&h.toValue(g.children)!==g.children)return t.error(n,r,`button-dynamic-label`,`Classic Outlook draws the button from a fixed box, and a label read at render time cannot size it.`,`Give the button a width: <Button width={200} …>.`),[];gs();let _=l(g),v=t.findings.locate(n.module.parsed,r);for(let e of gs())t.findings.items.push({...e,origins:[v]});return _!==null&&(!is(_)||typeof _.type!=`string`)?[]:f([...Mm(_,h,t.src(n.module,r))])},Bm=(e,t,n)=>({ok:!1,node:t,module:e,reason:n}),Vm=e=>{if(e.type===`ObjectProperty`&&e.computed!==!0){let t=J(e,`key`);if(t===void 0)return;if(t.type===`Identifier`)return Y(t,`name`);if(t.type===`StringLiteral`)return Y(t,`value`);if(t.type===`NumericLiteral`)return String(t.value)}},Hm=(e,t,n,r=new Set)=>{let i=`${t.path}\0${n}`;if(r.has(i))return;r.add(i);let a=t.declarations.get(n);if(a!==void 0)return{module:t,value:a.value};let o=t.imports.get(n);if(o===void 0)return;if(o.kind===`asset`)return{asset:o.path};if(o.kind!==`project`)return;let s=e.project.modules.get(o.path);if(s===void 0)return;if(o.imported==="default"){let e=s.defaultExport;return e===void 0?void 0:{module:s,value:e}}let c=s.exports.get(o.imported);return c===void 0?void 0:Hm(e,s,c,r)},Um=(e,t,n,r=new Set)=>{let i=Zp(n);switch(i.type){case`StringLiteral`:return{ok:!0,value:i.value};case`NumericLiteral`:return{ok:!0,value:i.value};case`BooleanLiteral`:return{ok:!0,value:i.value};case`NullLiteral`:return{ok:!0,value:null};case`TemplateLiteral`:{if(Yp(i,`expressions`).length>0)return Bm(t,i,"a template string with a `${}` part is computed at run time");let e=Yp(i,`quasis`)[0]?.value,n=e?.cooked??e?.raw;return{ok:!0,value:typeof n==`string`?n:``}}case`UnaryExpression`:{let e=J(i,`argument`);return Y(i,`operator`)===`-`&&e!==void 0&&e.type===`NumericLiteral`&&typeof e.value==`number`?{ok:!0,value:-e.value}:Bm(t,i,`only a negative number literal is data`)}case`Identifier`:{let n=Y(i,`name`)??``;if(n===`undefined`)return{ok:!0,value:void 0};let a=Hm(e,t,n);if(a===void 0)return Bm(t,i,`\`${n}\` is not a constant in the project`);if(`asset`in a){let r=e.assetUrl(a.asset);return r===void 0?Bm(t,i,`\`${n}\` names an asset the build did not address`):{ok:!0,value:r}}let o=`${a.module.path}\0${n}\0${a.value.start}`;if(r.has(o))return Bm(t,i,`\`${n}\` refers to itself`);r.add(o);let s=Um(e,a.module,a.value,r);return r.delete(o),s}case`ArrayExpression`:{let n=[];for(let a of Array.isArray(i.elements)?i.elements:[]){if(typeof a!=`object`||!a)return Bm(t,i,`an array hole`);let o=a;if(o.type===`SpreadElement`){let i=J(o,`argument`);if(i===void 0)return Bm(t,o,`an empty spread`);let a=Um(e,t,i,r);if(!a.ok)return a;if(!Array.isArray(a.value))return Bm(t,o,`a spread of a non-array`);n.push(...a.value);continue}let s=Um(e,t,o,r);if(!s.ok)return s;n.push(s.value)}return{ok:!0,value:n}}case`ObjectExpression`:{let n={};for(let a of Yp(i,`properties`)){if(a.type===`SpreadElement`){let i=J(a,`argument`);if(i===void 0)return Bm(t,a,`an empty spread`);let o=Um(e,t,i,r);if(!o.ok)return o;if(typeof o.value!=`object`||o.value===null||Array.isArray(o.value))return Bm(t,a,`a spread of a non-object`);Object.assign(n,o.value);continue}let i=Vm(a);if(i===void 0)return Bm(t,a,`a computed or method property`);let o=J(a,`value`);if(o===void 0)return Bm(t,a,`a property without a value`);let s=Um(e,t,o,r);if(!s.ok)return s;s.value!==void 0&&(n[i]=s.value)}return{ok:!0,value:n}}case`CallExpression`:{let n=J(i,`callee`),a=Yp(i,`arguments`)[0];return n?.type===`Identifier`&&Y(n,`name`)===`jsonSchema`&&a!==void 0?Um(e,t,a,r):Bm(t,i,`a call is computed at run time`)}default:return Bm(t,i,`${i.type} is not data`)}},Wm=40,Gm={"+":`+`,"-":`-`,"*":`*`,"/":`/`,"%":`%`},Km={"===":`eq`,"!==":`ne`,"<":`lt`,">":`gt`,"<=":`le`,">=":`ge`},qm={money:[2,3],number:[1,3],date:[1,3],time:[1,3],plural:[2,3],list:[1,2]},Jm=new Set([`reduce`,`filter`,`slice`,`join`,`sort`,`concat`,`flatMap`,`find`,`some`,`every`,`toFixed`,`toLocaleString`,`toLocaleDateString`,`toUpperCase`,`toLowerCase`,`trim`,`split`,`replace`,`padStart`,`includes`,`indexOf`,`at`]),Ym=e=>{let t=e.split(/\r\n|\n|\r/),n=0;for(let[e,r]of t.entries())/[^ \t]/.test(r)&&(n=e);let r=``;for(let[e,i]of t.entries()){let a=i.replace(/\t/g,` `);e!==0&&(a=a.replace(/^ +/,``)),e!==t.length-1&&(a=a.replace(/ +$/,``)),a!==``&&(e!==n&&(a+=` `),r+=a)}return r},Xm=e=>e.type===`JSXIdentifier`?Y(e,`name`)??``:e.type===`JSXNamespacedName`?`${Y(J(e,`namespace`)??e,`name`)??``}:${Y(J(e,`name`)??e,`name`)??``}`:e.type===`JSXMemberExpression`?`${Xm(J(e,`object`)??e)}.${Y(J(e,`property`)??e,`name`)??``}`:``,Zm=e=>e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`,Qm=e=>e===`VariableDeclaration`?"`const`":e===`IfStatement`?"`if`":/For|While/.test(e)?`a loop`:`a statement`,$m=class{options;sources=[];uniqueId=0;reservedAttributes;constructor(e){this.options=e,this.reservedAttributes=Fc(e.brandPlugin)}get findings(){return this.options.findings}src(e,t){let n=e.parsed.position(t.start);if(e.path===this.options.project.entry.path)return[n.line,n.column];let r=this.sources.indexOf(e.path);return r<0&&(r=this.sources.length,this.sources.push(e.path)),[n.line,n.column,r+1]}error(e,t,n,r,i){this.findings.add(e.module.parsed,t,n,r,i)}dynamic(e,t,n,r){this.error(e,t,`dynamic-expression`,`${n} runs code, and templates render without running code.`,r)}functionExpression(e,t){let n=J(t,`body`);if(n===void 0)return;if(n.type!==`BlockStatement`)return n;let r=Yp(n,`body`),i=r[0];if(r.length===1&&i?.type===`ReturnStatement`){let e=J(i,`argument`);if(e!==void 0)return e}let a=r.find(e=>e.type!==`ReturnStatement`)??n,o=Qm(a.type);this.error(e,a,`statement-in-body`,`A body is one expression, and ${o} is a statement.`,"Write the value where it is used: `cond && <X />` or `cond ? <A /> : <B />` for branches, `.map` for lists. Compute anything else in the caller and send it in the payload.")}bindPattern(e,t,n,r,i){switch(t.type){case`Identifier`:{let e=Y(t,`name`)??``;r.set(e,n??{k:`value`,value:null});return}case`AssignmentPattern`:{let a=J(t,`left`),o=J(t,`right`);if(a===void 0||o===void 0)return;if(!i){this.error(e,t,`unsupported-pattern`,`A default value on the input is never inserted, so it is not part of the profile.`,`Remove the default; declare the field as required or guard it where it is read.`);return}let s=n;if(s===void 0){let t=Um(this.options.staticContext,e.module,o);if(!t.ok){this.error(e,o,`dynamic-expression`,`A default prop value must be a literal.`,`Use a string, number or boolean literal.`);return}s={k:`value`,value:t.value}}this.bindPattern(e,a,s,r,i);return}case`ObjectPattern`:for(let a of Yp(t,`properties`)){if(a.type===`RestElement`){this.error(e,a,`unsupported-pattern`,`A rest element gathers props at run time.`,`Name each prop you use.`);continue}let t=J(a,`key`),o=J(a,`value`),s=Xp(t);if(s===void 0||o===void 0||a.computed===!0){this.error(e,a,`unsupported-pattern`,`A computed key cannot be read statically.`);continue}let c=n===void 0?void 0:this.field(e,n,s,a);this.bindPattern(e,o,c,r,i)}return;default:this.error(e,t,`unsupported-pattern`,`A parameter is a name or an object pattern of names.`,"Write `(input) =>` or `({ name, items }) =>`.")}}field(e,t,n,r){switch(t.k){case`path`:return n===`length`&&t.path!==``?{k:`value`,value:{length:{bind:t.path}}}:{k:`path`,path:em(t.path,n)};case`object`:return t.fields.get(n);case`value`:if(n===`length`)return{k:`value`,value:{length:t.value}};if(t.value===null)return{k:`value`,value:null};this.error(e,r,`dynamic-expression`,`\`.${n}\` reads a property of a computed value.`,`Read fields of the input directly.`);return;case`nodes`:this.error(e,r,`dynamic-expression`,"`children` has no fields.","Render `{children}` as is.");return}}binding(e,t){let n=Zp(t);if(n.type===`Identifier`){let t=Y(n,`name`)??``;if(t===`undefined`)return{k:`value`,value:null};let r=e.env.get(t);if(r!==void 0)return r;let i=e.module.imports.get(t);if(i?.kind===`asset`){let e=this.options.assetUrl(i.path);if(e!==void 0)return{k:`value`,value:e}}this.error(e,n,`dynamic-expression`,`\`${t}\` is not a binding the template declared.`,"Read the input through the function's parameter, for example `input.name`.");return}if(n.type===`MemberExpression`){let t=J(n,`object`),r=J(n,`property`);if(t===void 0||r===void 0)return;if(n.computed!==!0&&Y(r,`name`)===`length`&&this.filterChain(e,t)!==void 0){let n=this.filterChain(e,t);if(n.list===void 0)return;let r=n.filters[0],i=r===void 0?void 0:Yp(r,`params`)[0],a=this.uniqueName(e,i?.type===`Identifier`?Y(i,`name`)??`item`:`item`),o=this.whereClause({...e,loops:[...e.loops,a]},a,n.filters);return o===void 0?void 0:{k:`value`,value:{count:n.list,as:a,where:o}}}let i=this.binding(e,t);if(i===void 0)return;let a;if(n.computed===!0){if(r.type===`StringLiteral`?a=Y(r,`value`):r.type===`NumericLiteral`&&(a=String(r.value)),a===void 0){this.dynamic(e,n,`A computed property`,"Use `.name`, or a numeric index such as `[0]`.");return}}else a=Y(r,`name`);return a===void 0?void 0:this.field(e,i,a,n)}if(n.type===`OptionalMemberExpression`||n.type===`OptionalCallExpression`){this.dynamic(e,n,`Optional chaining`,"Guard the field: `input.discount && <p>{input.discount.label}</p>`.");return}let r=this.value(e,n,!1);return r===void 0?void 0:{k:`value`,value:r}}value(e,t,n){let r=Zp(t);switch(r.type){case`StringLiteral`:return this.checkedText(e,r,Y(r,`value`)??``);case`NumericLiteral`:return typeof r.value==`number`?r.value:void 0;case`BooleanLiteral`:return r.value===!0;case`NullLiteral`:return null;case`Identifier`:case`MemberExpression`:case`OptionalMemberExpression`:{let t=this.binding(e,r);if(t===void 0)return;let n=tm(t);if(n!==void 0)return n;this.error(e,r,`dynamic-expression`,t.k===`path`?`The input as a whole is not a value.`:"An object or `children` is not text.",t.k===`path`?"Read one field: `input.name`.":"Render `{children}` as content, or read one field.");return}case`TemplateLiteral`:return this.template(e,r,n);case`ConditionalExpression`:{let t=J(r,`test`),i=J(r,`consequent`),a=J(r,`alternate`);if(t===void 0||i===void 0||a===void 0)return;let o=this.predicate(e,t),s=this.value(e,i,n),c=this.value(e,a,n);return o===void 0||s===void 0||c===void 0?void 0:{if:o,then:s,else:c}}case`LogicalExpression`:{let t=Y(r,`operator`),i=J(r,`left`),a=J(r,`right`);if(i===void 0||a===void 0)return;if(t===`||`){let t=this.value(e,i,n),r=this.value(e,a,n);return t===void 0||r===void 0?void 0:{if:{truthy:t},then:t,else:r}}if(t===`??`){this.error(e,r,`dynamic-expression`,"`??` is not one of the conditions the profile reads.",'Write the condition out: `input.name === null ? "there" : input.name`, or `input.name || "there"`.');return}this.error(e,r,`dynamic-expression`,"`&&` in a value position yields its left operand when that is falsy.","Use a conditional: `cond ? value : fallback`, or `cond && <X />` in content.");return}case`CallExpression`:return this.call(e,r);case`BinaryExpression`:{let t=Y(r,`operator`)??``,i=Gm[t],a=J(r,`left`),o=J(r,`right`);if(i===void 0||a===void 0||o===void 0){this.error(e,r,`dynamic-expression`,`\`${t}\` produces a condition, not a value.`,"Use it as the test of `&&`, `? :` or `||`.");return}if(!n){this.error(e,r,`dynamic-expression`,"Arithmetic runs code, and it is allowed only inside a `fmt.*` argument or a condition.","Wrap it: `fmt.number(item.price * item.qty)`, or send the computed value in the payload.");return}if(i===`+`&&[a,o].some(e=>/StringLiteral|TemplateLiteral/.test(Zp(e).type))){this.error(e,r,`dynamic-expression`,"`+` with a string joins text at run time.","Use a template string: `${a} ${b}`.");return}let s=this.value(e,a,!0),c=this.value(e,o,!0);return s===void 0||c===void 0?void 0:{op:i,args:[s,c]}}case`UnaryExpression`:{let t=Y(r,`operator`),i=J(r,`argument`);if(t===`-`&&i!==void 0){let t=Zp(i);if(t.type===`NumericLiteral`&&typeof t.value==`number`)return-t.value;if(n){let t=this.value(e,i,!0);return t===void 0?void 0:{op:`-`,args:[0,t]}}}if(t===`!`){this.error(e,r,`dynamic-expression`,"`!` produces a condition, not a value.","Use it as the test of `&&`, `? :` or `||`.");return}return this.dynamic(e,r,`\`${t??`?`}\``,`Send the computed value in the payload.`)}case`JSXElement`:case`JSXFragment`:this.error(e,r,`dynamic-expression`,`Markup is not a text value.`,`Use it as content.`);return;case`ArrowFunctionExpression`:case`FunctionExpression`:return this.dynamic(e,r,`A function`,`Write the value directly.`);case`NewExpression`:case`AwaitExpression`:case`AssignmentExpression`:case`UpdateExpression`:case`SequenceExpression`:case`ObjectExpression`:case`ArrayExpression`:case`SpreadElement`:return this.dynamic(e,r,`\`${r.type}\``,`Send the computed value in the payload.`);default:return this.dynamic(e,r,`\`${r.type}\``,`Send the computed value in the payload.`)}}checkedText(e,t,n){return/[-]/.test(n)&&this.error(e,t,`reserved-character`,`This text contains a private-use character the compiler reserves.`,`Remove the characters U+E000 to U+E003.`),n}template(e,t,n){let r=Yp(t,`quasis`),i=Yp(t,`expressions`),a=[],o=!0;for(let[t,s]of r.entries()){let r=nh(s);r!==``&&a.push(this.checkedText(e,s,r));let c=i[t];if(c!==void 0){let t=this.value(e,c,n);t===void 0?o=!1:a.push(t)}}if(o)return rh(a)}call(e,t){let n=J(t,`callee`),r=Yp(t,`arguments`);if(n===void 0)return;let i=Zp(n);if(i.type===`MemberExpression`&&i.computed!==!0){let n=J(i,`object`),a=J(i,`property`),o=a===void 0?void 0:Y(a,`name`);if(n!==void 0&&o!==void 0&&this.isFmt(e,n)){if(!Oc.includes(o)){this.error(e,t,`unknown-formatter`,`\`fmt.${o}\` is not a formatter.`,`Use one of ${Oc.map(e=>`fmt.${e}`).join(`, `)}.`);return}let n=o,[i,a]=qm[n];if(r.length<i||r.length>a){this.error(e,t,`formatter-arguments`,`\`fmt.${n}\` takes ${i===a?i:`${i} to ${a}`} arguments.`,`Check the formatter table in the reference.`);return}let s=[];for(let t of r){let n=Zp(t);if(n.type===`ObjectExpression`){let t=Um(this.options.staticContext,e.module,n);if(!t.ok){this.error(e,n,`dynamic-expression`,`Formatter options are literal.`,`Write plain string and number values.`);return}s.push({lit:t.value});continue}if(n.type===`ArrayExpression`){let t=Um(this.options.staticContext,e.module,n);if(t.ok){s.push({lit:t.value});continue}}let r=this.value(e,t,!0);if(r===void 0)return;s.push(r)}return{format:n,args:s}}if(o!==void 0&&Jm.has(o))return this.dynamic(e,t,`\`.${o}(…)\``,"Send the computed value in the payload and bind it, or format with `fmt.*`.")}if(i.type===`Identifier`&&/^use[A-Z]/.test(Y(i,`name`)??``)){this.error(e,t,`hook-call`,`\`${Y(i,`name`)}\` is a hook, and a template has no state, effects or context.`,`Read the input through the function's parameter; send anything else in the payload.`);return}let a=i.type===`Identifier`?Y(i,`name`)??``:i.type===`MemberExpression`?`${eh(J(i,`object`))}.${Y(J(i,`property`)??i,`name`)??``}`:`a call`;return this.dynamic(e,t,`\`${a}(…)\``,"Send the computed value in the payload and bind it, or format with `fmt.money`, `fmt.number`, `fmt.date`, `fmt.time`, `fmt.plural` or `fmt.list`.")}isFmt(e,t){let n=Zp(t);if(n.type!==`Identifier`)return!1;let r=e.module.imports.get(Y(n,`name`)??``);return r?.kind===`markup`&&r.specifier===`@samva/markup/fmt`}predicate(e,t){let n=Zp(t);if(n.type===`LogicalExpression`){let t=Y(n,`operator`),r=J(n,`left`),i=J(n,`right`);if(r!==void 0&&i!==void 0&&(t===`&&`||t===`||`)){let n=this.predicate(e,r),a=this.predicate(e,i);if(n===void 0||a===void 0)return;if(t===`&&`){let e=e=>`and`in e?e.and:[e];return{and:[...e(n),...e(a)]}}let o=e=>`or`in e?e.or:[e];return{or:[...o(n),...o(a)]}}}if(n.type===`UnaryExpression`&&Y(n,`operator`)===`!`){let t=J(n,`argument`),r=t===void 0?void 0:this.predicate(e,t);return r===void 0?void 0:{not:r}}if(n.type===`BinaryExpression`){let t=Y(n,`operator`)??``,r=Km[t],i=J(n,`left`),a=J(n,`right`);if(r===void 0||i===void 0||a===void 0){this.error(e,n,`dynamic-expression`,t===`==`||t===`!=`?`\`${t}\` coerces types at run time.`:`\`${t}\` is not a comparison the profile reads.`,"Use `===`, `!==`, `<`, `>`, `<=` or `>=`.");return}let o=this.value(e,i,!0),s=this.value(e,a,!0);return o===void 0||s===void 0?void 0:{cmp:r,args:[o,s]}}let r=this.value(e,n,!0);if(r!==void 0)return typeof r==`object`&&r&&`bind`in r?{present:r.bind}:{truthy:r}}jsxChildren(e,t){let n=[];for(let r of Yp(t,`children`))switch(r.type){case`JSXText`:{let t=Ym(Y(r,`value`)??``);t!==``&&n.push(this.checkedText(e,r,t));break}case`JSXExpressionContainer`:{let t=J(r,`expression`);if(t===void 0||t.type===`JSXEmptyExpression`)break;n.push(...this.content(e,t));break}case`JSXElement`:case`JSXFragment`:n.push(...this.element(e,r));break;case`JSXSpreadChild`:this.dynamic(e,r,`A spread child`,`List the children.`)}return n}content(e,t){if(e.depth>Wm)return this.error(e,t,`nesting-limit`,`The template nests too deeply.`,`Flatten it.`),[];let n=Zp(t);switch(n.type){case`JSXElement`:case`JSXFragment`:return this.element(e,n);case`StringLiteral`:{let t=Y(n,`value`)??``;return t===``?[]:[this.checkedText(e,n,t)]}case`NumericLiteral`:return typeof n.value==`number`?[n.value]:[];case`BooleanLiteral`:case`NullLiteral`:return[];case`Identifier`:{let t=Y(n,`name`)??``;if(t===`undefined`)return[];let r=e.env.get(t);if(r?.k===`nodes`)return[...r.nodes];break}case`LogicalExpression`:{let t=Y(n,`operator`),r=J(n,`left`),i=J(n,`right`);if(t===`&&`&&r!==void 0&&i!==void 0){let t=this.predicate(e,r),a=this.content(e,i);return t===void 0?[]:[{if:t,then:a,src:this.src(e.module,n)}]}break}case`ConditionalExpression`:{let t=J(n,`test`),r=J(n,`consequent`),i=J(n,`alternate`);if(t===void 0||r===void 0||i===void 0)return[];let a=this.predicate(e,t),o=this.content(e,r),s=this.content(e,i);return a===void 0?[]:[{if:a,then:o,...s.length===0?{}:{else:s},src:this.src(e.module,n)}]}case`CallExpression`:{let t=J(n,`callee`),r=t===void 0?void 0:Zp(t),i=r===void 0?void 0:J(r,`property`);if(r?.type===`MemberExpression`&&r.computed!==!0&&i!==void 0&&Y(i,`name`)===`map`)return this.each(e,n,r);break}}let r=this.value(e,n,!1);return r===void 0?[]:[r]}freshName(e,t){return this.uniqueName(e,t)}uniqueName(e,t){return e.loops.includes(t)?(this.uniqueId+=1,`${t}_${this.uniqueId}`):t}each(e,t,n){let r=J(n,`object`),i=Yp(t,`arguments`)[0];if(r===void 0||i===void 0)return[];let a=this.filterChain(e,r),o=a===void 0?this.value(e,r,!1):a.list,s=Zp(i);if(s.type!==`ArrowFunctionExpression`&&s.type!==`FunctionExpression`)return this.dynamic(e,i,`A callback that is not an inline function`,"Write `.map((item) => <Row item={item} />)`."),[];if(o===void 0)return[];let c=this.eachOver(e,t,o,s,a?.filters??[]);return c===void 0?[]:[c]}filterChain(e,t){let n=[],r=Zp(t);for(;r.type===`CallExpression`;){let e=J(r,`callee`),t=e===void 0?void 0:Zp(e),i=t===void 0?void 0:J(t,`property`);if(t?.type!==`MemberExpression`||t.computed===!0||i===void 0||Y(i,`name`)!==`filter`)break;let a=Yp(r,`arguments`)[0],o=J(t,`object`);if(a===void 0||o===void 0)return;n.unshift(Zp(a)),r=Zp(o)}if(n.length!==0)return{list:this.value(e,r,!1),filters:n}}whereClause(e,t,n){let r=[];for(let i of n){if(!/Function/.test(i.type)){this.dynamic(e,i,"A `.filter` callback that is not an inline function","Write `.filter((item) => item.done)`.");return}let n=Yp(i,`params`);if(n.length>1){this.error(e,i,`dynamic-expression`,"A `.filter` callback reads the item; its index and the array are not part of the profile.",`Remove the extra parameters.`);return}let a=new Map(e.env);n[0]!==void 0&&this.bindPattern(e,n[0],{k:`path`,path:`$${t}`},a,!1);let o={...e,env:a},s=this.functionExpression(o,i),c=s===void 0?void 0:this.predicate(o,s);if(c===void 0)return;r.push(c)}if(r.length!==0)return r.length===1?r[0]:{and:r}}eachOver(e,t,n,r,i=[],a={}){let o=Yp(r,`params`);if(o.length>2){this.error(e,r,`dynamic-expression`,"`.map` callbacks read the item and its index; a third parameter is the whole array.",`Remove the third parameter.`);return}let s=new Map(e.env),c=[...e.loops],l=``,u,d=o[0];if(d!==void 0){let t=d.type===`Identifier`?Y(d,`name`)??`item`:`item`;l=this.uniqueName({...e,loops:c},a.name??t),c.push(l),this.bindPattern({...e,loops:c},d,{k:`path`,path:`$${l}`},s,!1)}else l=this.uniqueName(e,a.name??`item`),c.push(l);let f=o[1];f!==void 0&&(f.type===`Identifier`?(u=this.uniqueName({...e,loops:c},Y(f,`name`)??`index`),c.push(u),s.set(Y(f,`name`)??`index`,{k:`value`,value:{bind:`$${u}`}})):this.error(e,f,`unsupported-pattern`,`The index is a plain name.`));let p=i.length===0?void 0:this.whereClause(e,l,i);if(i.length>0&&p===void 0)return;let m={...e,env:s,loops:c,depth:e.depth+1},h=this.functionExpression(m,r);if(h===void 0)return;let g=this.content(m,h);return{each:n,as:l,...u===void 0?{}:{index:u},...p===void 0?{}:{where:p},...a.chunk===void 0?{}:{chunk:a.chunk},children:g,src:this.src(e.module,t)}}element(e,t){if(t.type===`JSXFragment`)return this.jsxChildren({...e,depth:e.depth+1},t);let n=J(t,`openingElement`),r=n===void 0?void 0:J(n,`name`);if(n===void 0||r===void 0)return[];let i=Xm(r),a={...e,depth:e.depth+1};return a.depth>Wm?(this.error(e,t,`nesting-limit`,`The template nests too deeply.`,`Flatten it.`),[]):/^[a-z]/.test(i)&&!i.includes(`.`)?this.intrinsic(a,t,n,i):this.component(a,t,n,i)}attributeName(e){let t=J(e,`name`);return t===void 0?``:Xm(t)}intrinsic(e,t,n,r){let i=Wc(r);if(i===void 0){let n=fm(r,Object.keys(Uc));return this.error(e,t,`unsupported-element`,`<${r}> is not part of the supported email vocabulary.`,n===void 0?`Use one of: ${Object.keys(Uc).join(`, `)}.`:`Did you mean <${n}>? Supported elements: ${Object.keys(Uc).join(`, `)}.`),[]}let a={},o,s=[this.findings.locate(e.module.parsed,t)];for(let t of Yp(n,`attributes`)){if(t.type===`JSXSpreadAttribute`){this.dynamic(e,t,`A spread attribute`,`Write each attribute.`);continue}let n=this.attributeName(t),c=J(t,`value`);if(n===`key`)continue;if(n===`ref`||n===`dangerouslySetInnerHTML`||/^on[A-Z]/.test(n)){let r=n===`dangerouslySetInnerHTML`;this.error(e,t,r?`dangerous-html`:n===`ref`?`unsupported-attribute`:`event-handler`,r?"`dangerouslySetInnerHTML` injects unescaped markup.":n===`ref`?"A `ref` needs a running component.":`\`${n}\` is an event handler; email clients strip scripting and Samva refuses it.`,r?`Write the markup as elements.`:`Remove it.`);continue}if(this.reservedAttributes.has(n)){this.error(e,t,`reserved-attribute`,`\`${n}\` is written only by BrandFooter from ${this.options.brandPlugin.specifier}.`,`Render <BrandFooter /> instead of marking an element as the footer.`);continue}if(n===`className`||n===`class`){let t=c===void 0?``:this.classValue(e,c);t!==void 0&&t!==``&&(a.class=t);continue}if(n===`style`){o=this.styleAttribute(e,c);continue}let l;if(c===void 0)l=!0;else if(c.type===`StringLiteral`)l=this.checkedText(e,c,Y(c,`value`)??``);else if(c.type===`JSXExpressionContainer`){let t=J(c,`expression`);l=t===void 0?void 0:this.value(e,t,!1)}else{this.error(e,c,`dynamic-expression`,`An attribute value is text, a number or a binding.`);continue}if(l!==void 0&&l!==!1&&l!==null){if(l===this.options.brandPlugin.unsubscribeUrlPlaceholder){this.error(e,t,`reserved-url`,`That URL is the unsubscribe placeholder only BrandFooter can write.`,`Render <BrandFooter /> instead.`);continue}if(Zm(l)){let a=ml(r,n,l,s);if(a.text===void 0&&a.diagnostics.length===0){let a=fm(n,Object.keys({...i.attributes,id:0,title:0,lang:0,dir:0,role:0}));this.error(e,t,`unsupported-attribute`,`<${r}> does not support the ${n} attribute.`,a===void 0?`Supported: ${Object.keys(i.attributes).join(`, `)||`none`}, plus id, title, lang, dir, role, class, style, data-* and aria-*.`:`Did you mean \`${a}\`?`);continue}this.findings.items.push(...a.diagnostics)}a[n]=l}}let c=i.content===`void`?[]:this.jsxChildren(e,t);return[{el:r,...Object.keys(a).length===0?{}:{attrs:a},...o===void 0?{}:{style:o},...c.length===0?{}:{children:c},src:this.src(e.module,t)}]}classValue(e,t){let n=t.type===`JSXExpressionContainer`?J(t,`expression`):t;if(n===void 0)return;let r=this.classExpression(e,n);return r===void 0&&this.error(e,t,`dynamic-class`,`This class is built at run time, and Tailwind cannot see class names it does not read.`,'Write the classes literally, or choose between literal classes: `input.vip ? "bg-amber-100" : "bg-white"`.'),r}classExpression(e,t){let n=Zp(t);switch(n.type){case`StringLiteral`:return Y(n,`value`)??``;case`NullLiteral`:return``;case`BooleanLiteral`:return``;case`Identifier`:case`MemberExpression`:{if(n.type===`Identifier`&&Y(n,`name`)===`undefined`)return``;let t=this.binding(e,n);return t?.k===`value`&&th(t.value)?t.value:void 0}case`TemplateLiteral`:{let t=Yp(n,`quasis`),r=Yp(n,`expressions`),i=[];for(let[n,a]of t.entries()){let t=nh(a);t!==``&&i.push(t);let o=r[n];if(o!==void 0){let t=this.classExpression(e,o);if(t===void 0)return;i.push(t)}}return rh(i)}case`ConditionalExpression`:{let t=J(n,`test`),r=J(n,`consequent`),i=J(n,`alternate`);if(t===void 0||r===void 0||i===void 0)return;let a=this.predicate(e,t),o=this.classExpression(e,r),s=this.classExpression(e,i);return a===void 0||o===void 0||s===void 0?void 0:{if:a,then:o,else:s}}case`LogicalExpression`:{let t=J(n,`left`),r=J(n,`right`);if(Y(n,`operator`)!==`&&`||t===void 0||r===void 0)return;let i=this.predicate(e,t),a=this.classExpression(e,r);return i===void 0||a===void 0?void 0:{if:i,then:a,else:``}}case`BinaryExpression`:{let t=J(n,`left`),r=J(n,`right`);if(Y(n,`operator`)!==`+`||t===void 0||r===void 0)return;let i=this.classExpression(e,t),a=this.classExpression(e,r);return i===void 0||a===void 0?void 0:rh([i,a])}default:return}}styleAttribute(e,t){let n=t===void 0?void 0:J(t,`expression`),r=n===void 0?void 0:Zp(n);if(r===void 0||r.type!==`ObjectExpression`){t!==void 0&&this.error(e,t,`invalid-style`,"`style` is an object literal of CSS properties.",`Write style={{ backgroundColor: "#fff" }}, or use Tailwind classes.`);return}return this.styleObject(e,r)}styleObject(e,t){let n=[];for(let r of Yp(t,`properties`)){if(r.type!==`ObjectProperty`||r.computed===!0){this.dynamic(e,r,`A spread or computed style entry`,`Write each property.`);continue}let t=J(r,`key`),i=J(r,`value`),a=Xp(t);if(a===void 0||i===void 0)continue;let o=this.value(e,i,!1);o!=null&&n.push([a,o])}return n}component(e,t,n,r){let i=r.split(`.`)[0]??r,a=e.module.imports.get(i),o=e.module.declarations.get(i),s=Yp(n,`attributes`);if(a?.kind===`markup`||a?.kind===`brand`)return zm({lowerer:this,ctx:e,node:t,attributes:s,name:r,binding:a,brand:this.options.brand,brandPlugin:this.options.brandPlugin,channel:this.options.channel});let c;if(a?.kind===`project`){let e=this.options.project.modules.get(a.path);e!==void 0&&(c=this.exportedFunction(e,a.imported,new Set))}else o!==void 0&&(c={module:e.module,value:o.value});return c===void 0||!/Function|Arrow/.test(c.value.type)?(this.error(e,t,`unknown-component`,`<${r}> is not a component the profile can read.`,`Import it from @samva/markup/email, or from a project file that exports it as a function.`),[]):this.partial(e,t,s,r,c.module,c.value)}exportedFunction(e,t,n){let r=`${e.path}\0${t}`;if(n.has(r))return;if(n.add(r),t==="default"){let t=e.defaultExport;if(t===void 0)return;if(t.type===`Identifier`){let n=e.declarations.get(Y(t,`name`)??``);return n===void 0?void 0:{module:e,value:n.value}}return{module:e,value:t}}let i=e.exports.get(t);if(i===void 0)return;let a=e.declarations.get(i);if(a!==void 0)return{module:e,value:a.value};let o=e.imports.get(i);if(o?.kind===`project`){let e=this.options.project.modules.get(o.path);return e===void 0?void 0:this.exportedFunction(e,o.imported,n)}}attributeBindings(e,t){let n=new Map,r=!0;for(let i of t){if(i.type===`JSXSpreadAttribute`){this.dynamic(e,i,`A spread attribute`,`Write each prop.`),r=!1;continue}let t=this.attributeName(i);if(t===`key`)continue;let a=J(i,`value`);if(a===void 0){n.set(t,{k:`value`,value:!0});continue}if(a.type===`StringLiteral`){n.set(t,{k:`value`,value:this.checkedText(e,a,Y(a,`value`)??``)});continue}let o=a.type===`JSXExpressionContainer`?J(a,`expression`):void 0;if(o===void 0){this.error(e,a,`dynamic-expression`,`A prop value is text, a number, a binding or an object.`),r=!1;continue}let s=this.propBinding(e,o);s===void 0?r=!1:n.set(t,s)}return r?n:void 0}propBinding(e,t){let n=Zp(t);if(n.type===`ObjectExpression`){let t=new Map;for(let r of Yp(n,`properties`)){if(r.type!==`ObjectProperty`||r.computed===!0){this.dynamic(e,r,`A spread or computed entry`,`Write each field.`);return}let n=J(r,`key`),i=J(r,`value`),a=n===void 0?void 0:n.type===`Identifier`?Y(n,`name`):Y(n,`value`);if(a===void 0||i===void 0)return;let o=this.propBinding(e,i);if(o===void 0)return;t.set(a,o)}return{k:`object`,fields:t}}if(n.type===`Identifier`||n.type===`MemberExpression`)return this.binding(e,n);if(n.type===`JSXElement`||n.type===`JSXFragment`)return{k:`nodes`,nodes:this.element(e,n)};let r=this.value(e,n,!1);return r===void 0?void 0:{k:`value`,value:r}}partial(e,t,n,r,i,a){let o=`${i.path}#${a.start}`;if(e.stack.includes(o))return this.error(e,t,`recursive-partial`,`<${r}> renders itself, and the compiler inlines partials.`,"Flatten the recursion, or repeat the structure with `.map`."),[];let s=this.attributeBindings(e,n);if(s===void 0)return[];let c=this.jsxChildren(e,t);c.length>0&&s.set(`children`,{k:`nodes`,nodes:c});let l={module:i,env:new Map,stack:[...e.stack,o],loops:e.loops,depth:e.depth+1},u=new Map,d=Yp(a,`params`)[0];if(d!==void 0){let e={k:`object`,fields:s};d.type===`Identifier`?u.set(Y(d,`name`)??`props`,e):this.bindPattern(l,d,e,u,!0)}let f={...l,env:u},p=this.functionExpression(f,a);return p===void 0?[]:this.content(f,p)}},eh=e=>e===void 0?``:e.type===`Identifier`?Y(e,`name`)??``:`…`,th=e=>typeof e==`string`?!0:typeof e!=`object`||!e?!1:`if`in e?th(e.then)&&th(e.else):`concat`in e&&e.concat.every(th),nh=e=>{let t=e.value;if(typeof t!=`object`||!t)return``;let n=t.cooked,r=t.raw;return typeof n==`string`?n:typeof r==`string`?r:``},rh=e=>{let t=[];for(let n of e){let e=t[t.length-1];if(typeof n==`string`&&typeof e==`string`)t[t.length-1]=e+n;else if(typeof n==`object`&&n&&`concat`in n)for(let e of n.concat){let n=t[t.length-1];typeof e==`string`&&typeof n==`string`?t[t.length-1]=n+e:t.push(e)}else t.push(n)}return t.length===0?``:t.length===1?t[0]:{concat:t}},ih=()=>void 0,ah=60,oh=60,sh=1024,ch=25,lh=2,uh=1,dh=10,fh=10,ph=e=>e.type===`JSXIdentifier`?Y(e,`name`)??``:e.type===`JSXMemberExpression`?`${ph(J(e,`object`)??e)}.${Y(J(e,`property`)??e,`name`)??``}`:``,mh=e=>{let t=J(e,`openingElement`),n=t===void 0?void 0:J(t,`name`);return n===void 0?``:ph(n)},hh=e=>{let t=J(e,`openingElement`);return t===void 0?[]:Yp(t,`attributes`)},gh=(e,t,n,r)=>{let i=e.openFunction(t);if(i===void 0)return;let{ctx:a,body:o}=i,s=Zp(o),c=s.type===`JSXElement`?mh(s):``,l=a.module.imports.get(c);if(s.type!==`JSXElement`||l?.kind!==`markup`||l.specifier!==r||l.imported!==n){e.lowerer.error(a,s,`wrong-channel`,`The ${n===`Sms`?`sms`:`whatsapp`} channel returns one <${n}> element imported from ${r}.`,`Write \`import { ${n} } from "${r}"\` and return <${n}>…</${n}>.`);return}return{ctx:a,node:s,local:c}},_h=(e,t,n)=>{let r=new Map;for(let i of hh(t.node)){if(i.type===`JSXSpreadAttribute`){e.lowerer.error(t.ctx,i,`dynamic-expression`,`A spread attribute runs code, and templates render without running code.`,`Write each attribute as a string literal.`);continue}let a=J(i,`name`),o=a===void 0?``:ph(a);if(o===`key`)continue;if(!n.includes(o)){e.lowerer.error(t.ctx,i,`unknown-attribute`,`\`${o}\` is not an attribute of this component.`,`The attributes are ${n.join(`, `)}.`);continue}let s=J(i,`value`),c=s?.type===`JSXExpressionContainer`?J(s,`expression`):s;if(c?.type!==`StringLiteral`){e.lowerer.error(t.ctx,i,`dynamic-expression`,`\`${o}\` is fixed when the template is compiled, so it is a string literal.`,`Write ${o}="…".`);continue}r.set(o,Y(c,`value`)??``)}return r},vh=(e,t,n,r,i,a)=>a.includes(i)?!0:(e.lowerer.error(t.ctx,n,`invalid-attribute`,`\`${i}\` is not a ${r} this channel accepts.`,`Use one of ${a.join(`, `)}.`),!1),yh=e=>e.every(e=>rm(e)),bh=e=>e.some(e=>rm(e)?!1:`el`in e||`raw`in e?!0:`if`in e?bh(e.then)||bh(e.else??[]):`each`in e&&bh(e.children)),xh=(e,t)=>{let n=gh(e,t,`Sms`,`@samva/markup/sms`);if(n===void 0)return;let r=_h(e,n,sm),i=hh(n.node).find(e=>Y(J(e,`name`)??e,`name`)===`category`),a=r.get(`category`);if(a!==void 0&&i!==void 0&&!vh(e,n,i,`category`,a,im))return;let o=e.lowerer.jsxChildren(n.ctx,n.node);return bh(o)&&e.lowerer.error(n.ctx,n.node,`sms-markup`,`An SMS body is plain text, and this one contains an element.`,`Write the message as text and bindings; use a newline in the text for a line break.`),e.schema!==void 0&&e.checks.push(...Sm(e.schema,o,[])),{...a===void 0?{}:{category:a},body:o}},Sh=e=>typeof e==`string`?e.length:typeof e==`number`?String(e).length:typeof e==`object`&&e&&`concat`in e?e.concat.reduce((e,t)=>e+Sh(t),0):0,Ch={url:0,phone:0,quickReply:0,total:0},wh=e=>{let t=Ch;for(let n of e){let e;if(`if`in n){let t=wh(n.then),r=wh(n.else??[]);e={url:Math.max(t.url,r.url),phone:Math.max(t.phone,r.phone),quickReply:Math.max(t.quickReply,r.quickReply),total:Math.max(t.total,r.total)}}else e={url:+(n.type===`url`),phone:+(n.type===`phone`),quickReply:+(n.type===`quick-reply`),total:1};t={url:t.url+e.url,phone:t.phone+e.phone,quickReply:t.quickReply+e.quickReply,total:t.total+e.total}}return t},Th=e=>e.flatMap(e=>{if(`if`in e)return[{if:e.if,then:Th(e.then),...e.else===void 0?{}:{else:Th(e.else)},...e.src===void 0?{}:{src:e.src}}];switch(e.type){case`quick-reply`:return[e.text];case`url`:return[e.text,e.url];case`phone`:return[e.text,e.phone];case`copy-code`:return[e.code]}}),Eh=(e,t)=>{let n=gh(e,t,`WhatsApp`,`@samva/markup/whatsapp`);if(n===void 0)return;let{lowerer:r}=e,{ctx:i}=n,a=_h(e,n,cm);for(let e of[`category`,`language`])a.has(e)||r.error(i,n.node,`missing-attribute`,`<WhatsApp> needs \`${e}\`.`,e===`category`?`Write category="utility" (${am.join(`, `)}).`:`Write language="en_US".`);let o=a.get(`category`),s=hh(n.node).find(e=>Y(J(e,`name`)??e,`name`)===`category`);if(o!==void 0&&s!==void 0&&!vh(e,n,s,`category`,o,am))return;let c=new Map;for(let e of Yp(n.node,`children`)){if(e.type===`JSXText`){(Y(e,`value`)??``).trim()!==``&&r.error(i,e,`whatsapp-structure`,`Text sits inside Header, Body, Footer or Buttons, not directly in <WhatsApp>.`,`Move it into <WhatsApp.Body>.`);continue}let t=e.type===`JSXElement`?mh(e):``,a=t.startsWith(`${n.local}.`)?t.slice(n.local.length+1):``;if(![`Header`,`Body`,`Footer`,`Buttons`].includes(a)){r.error(i,e,`whatsapp-structure`,`<WhatsApp> holds <WhatsApp.Header>, <WhatsApp.Body>, <WhatsApp.Footer> and <WhatsApp.Buttons>.`,`Wrap the content in one of them.`);continue}if(c.has(a)){r.error(i,e,`whatsapp-structure`,`<WhatsApp.${a}> appears twice.`,`A WhatsApp template has at most one of each part.`);continue}c.set(a,e)}let l=[],u=(e,t,n,a)=>{n>a&&r.findings.add(i.module.parsed,t,`whatsapp-length`,`The ${e} is at least ${n} characters, and Meta allows ${a}.`,`Shorten the ${e}.`,`warning`)},d=(e,t,n)=>{let a=r.jsxChildren(i,t);if(!yh(a)){r.error(i,t,`whatsapp-conditional`,`A WhatsApp ${e} cannot branch or contain elements: Meta registers its text once.`,`Choose the wording as a parameter in the payload, or write separate templates.`);return}return u(e,t,a.reduce((e,t)=>e+(rm(t)?Sh(t):0),0),n),l.push(...a),a},f,p=c.get(`Header`);if(p!==void 0){let e=hh(p).find(e=>Y(J(e,`name`)??e,`name`)===`type`),t=e===void 0?void 0:J(e,`value`),n=t?.type===`JSXExpressionContainer`?J(t,`expression`):t,a=n?.type===`StringLiteral`?Y(n,`value`)??`text`:`text`;if(e!==void 0&&n?.type!==`StringLiteral`)r.error(i,e,`dynamic-expression`,"`type` is fixed when the template is compiled, so it is a string literal.",`Write type="image".`);else if(e!==void 0&&!om.includes(a))r.error(i,e,`invalid-attribute`,`\`${a}\` is not a header type.`,`Use one of ${om.join(`, `)}.`);else{let e=a,t=d(`header`,p,e===`text`?ah:1/0);t!==void 0&&(e===`text`?um(t).params.length>1&&r.error(i,p,`whatsapp-header-variables`,`A WhatsApp header text takes at most one variable.`,`Keep one binding in the header and move the rest to the body.`):t.length!==1&&r.error(i,p,`whatsapp-header-media`,`A ${e} header is one URL.`,`Write the media URL as the only child: a literal or one binding.`),f={type:e,content:t})}}let m=[],h=c.get(`Body`);if(h===void 0)r.error(i,n.node,`whatsapp-body-required`,`A WhatsApp template needs a body.`,`Add <WhatsApp.Body>…</WhatsApp.Body>.`);else{let e=d(`body`,h,sh);m=e??[],e!==void 0&&e.length===0&&r.error(i,h,`whatsapp-body-required`,`The WhatsApp body is empty.`,`Write the message text.`)}let g=c.get(`Footer`),_=g===void 0?void 0:d(`footer`,g,oh),v=c.get(`Buttons`),y=v===void 0?void 0:Oh(e,i,n.local,v);if(y!==void 0){let e=wh(y),t=(e,t,n)=>{t>n&&r.error(i,v,`whatsapp-button-limit`,`A WhatsApp template allows ${n} ${e}, and these conditions can produce ${t}.`,`Remove ${t-n}, or split the template.`)};t(`URL buttons`,e.url,lh),t(`phone buttons`,e.phone,uh),t(`quick-reply buttons`,e.quickReply,dh),t(`buttons in all`,e.total,fh),l.push(...Th(y))}if(e.schema!==void 0&&e.checks.push(...Sm(e.schema,l,[])),o===void 0||!a.has(`language`))return;let b=a.get(`name`);return{...b===void 0?{}:{name:b},category:o,language:a.get(`language`),...f===void 0?{}:{header:f},body:m,..._===void 0?{}:{footer:_},...y===void 0?{}:{buttons:y}}},Dh=[`UrlButton`,`QuickReplyButton`,`PhoneButton`,`CopyCodeButton`],Oh=(e,t,n,r)=>{let{lowerer:i}=e,a=(e,n)=>{let r=i.jsxChildren(t,e);if(!yh(r)||r.length===0){i.error(t,e,r.length===0?`whatsapp-button-text`:`whatsapp-conditional`,r.length===0?`A button needs its ${n}.`:`A button ${n} cannot branch or contain elements.`,`Write the ${n} as text between the tags.`);return}let a=rh(r);return n===`label`&&Sh(a)>ch&&i.findings.add(t.module.parsed,e,`whatsapp-length`,`The button label is at least ${Sh(a)} characters, and Meta allows ${ch}.`,`Shorten the label.`,`warning`),a},o=(e,n)=>{let r=i.attributeBindings(t,hh(e));if(r===void 0)return;let a=hh(e).map(e=>Y(J(e,`name`)??e,`name`));for(let r of a)r!==void 0&&r!==n&&r!==`key`&&i.error(t,e,`unknown-attribute`,`\`${r}\` is not an attribute of this button.`,n===void 0?`Remove it.`:`The attribute is ${n}.`);if(n===void 0)return;let o=r.get(n),s=o===void 0?void 0:tm(o);return s===void 0&&i.error(t,e,`missing-attribute`,`This button needs \`${n}\`.`,`Write ${n}="…" or ${n}={input.field}.`),s},s=e=>{let r=mh(e);switch(r.startsWith(`${n}.`)?r.slice(n.length+1):``){case`UrlButton`:{let t=o(e,`url`),n=a(e,`label`);return t===void 0||n===void 0?void 0:{type:`url`,text:n,url:t}}case`PhoneButton`:{let t=o(e,`phone`),n=a(e,`label`);return t===void 0||n===void 0?void 0:{type:`phone`,text:n,phone:t}}case`QuickReplyButton`:{o(e,void 0);let t=a(e,`label`);return t===void 0?void 0:{type:`quick-reply`,text:t}}case`CopyCodeButton`:{let t=a(e,`code`);return t===void 0?void 0:{type:`copy-code`,code:t}}default:i.error(t,e,`whatsapp-structure`,`<WhatsApp.Buttons> holds ${Dh.map(e=>`<WhatsApp.${e}>`).join(`, `)}.`,`Use one of the button components.`);return}},c=e=>{let n=Zp(e);switch(n.type){case`JSXElement`:{let e=s(n);return e===void 0?[]:[e]}case`JSXFragment`:return l(n);case`NullLiteral`:case`BooleanLiteral`:return[];case`LogicalExpression`:{let e=J(n,`left`),r=J(n,`right`);if(Y(n,`operator`)===`&&`&&e!==void 0&&r!==void 0){let a=i.predicate(t,e),o=c(r);return a===void 0?[]:[{if:a,then:o,src:i.src(t.module,n)}]}break}case`ConditionalExpression`:{let e=J(n,`test`),r=J(n,`consequent`),a=J(n,`alternate`);if(e===void 0||r===void 0||a===void 0)return[];let o=i.predicate(t,e),s=c(r),l=c(a);return o===void 0?[]:[{if:o,then:s,...l.length===0?{}:{else:l},src:i.src(t.module,n)}]}}return i.error(t,n,`dynamic-expression`,`Buttons are fixed by the template, and this expression builds them at render time.`,"List each button; wrap one in `condition && <WhatsApp.UrlButton … />` to make it optional."),[]},l=e=>{let n=[];for(let r of Yp(e,`children`))if(r.type===`JSXText`)(Y(r,`value`)??``).trim()!==``&&i.error(t,r,`whatsapp-structure`,`Text cannot sit between buttons.`,`Put the label inside the button.`);else if(r.type===`JSXExpressionContainer`){let e=J(r,`expression`);e!==void 0&&e.type!==`JSXEmptyExpression`&&n.push(...c(e))}else n.push(...c(r));return n};return l(r)},kh=e=>{let t=e.fields.get(`sms`),n=e.fields.get(`whatsapp`),r=t===void 0?void 0:xh(e,t),i=n===void 0?void 0:Eh(e,n);return{...r===void 0?{}:{sms:r},...i===void 0?{}:{whatsapp:i}}},Ah=8,jh=(e,t)=>{if(`leaf`in e){let n=e.leaf,r=e=>`leaf`in e?{leaf:n+e.leaf}:{pred:e.pred,then:r(e.then),else:r(e.else)};return r(t)}return{pred:e.pred,then:jh(e.then,t),else:jh(e.else,t)}},Mh=e=>{if(typeof e==`string`)return{leaf:e};if(typeof e==`object`&&e){if(`if`in e){let t=Mh(e.then),n=Mh(e.else);return t===void 0||n===void 0?void 0:{pred:e.if,then:t,else:n}}if(`concat`in e){let t={leaf:``};for(let n of e.concat){let e=Mh(n);if(e===void 0)return;t=jh(t,e)}return t}}},Nh=e=>`leaf`in e?[e.leaf]:[...Nh(e.then),...Nh(e.else)],Ph=(e,t,n={next:0})=>{if(`leaf`in e)return t(n.next++);let r=Ph(e.then,t,n),i=Ph(e.else,t,n);return JSON.stringify(r)===JSON.stringify(i)?r:{if:e.pred,then:r,else:i}},Fh=(e,t)=>{for(let n of e)rm(n)||(`el`in n?(t.push({kind:`el`,el:n}),Fh(n.children??[],t)):`if`in n?(Fh(n.then,t),Fh(n.else??[],t)):`each`in n?Fh(n.children,t):`raw`in n&&t.push({kind:`raw`,raw:n}))},Ih=(e,t)=>t.map(t=>typeof t==`string`?t:e.value(`attr`in t?t.attr:t.text)).join(``),Lh=(e,t,n)=>{let r=[];Fh([e],r);let i=new Dm,a=r.map(e=>{if(e.kind!==`el`)return;let t=e.el.attrs?.class;if(t===void 0)return;let n=Mh(t);if(n!==void 0)return n}),o=a.map(e=>e===void 0?1:Nh(e).length);for(let[t,i]of o.entries())if(i>Ah){let a=r[t],o=a?.kind===`el`?n.locate(a.el.src):void 0;return n.report({code:`too-many-class-variants`,severity:`error`,message:`This class list chooses between ${i} literal lists; the compiler resolves at most ${Ah}.`,fix:`Split the choice into fewer conditions, or move part of it to a partial.`,origins:o===void 0?[]:[o]}),{root:e,headCss:``,fontFaceCss:``}}let s=Math.max(1,...o),c=(e,t,r)=>e.flatMap(e=>{if(rm(e))return[];if(`el`in e){let o=r.next++,s=a[o],l=s===void 0?void 0:Nh(s),u={};for(let[t,n]of Object.entries(e.attrs??{}))t!==`class`&&(typeof n==`string`||typeof n==`number`?u[t]=n:typeof n==`object`&&n&&(u[t]=i.value(n)));l===void 0?e.attrs?.class!==void 0&&(u.class=i.value(e.attrs.class)):u.class=l[Math.min(t,l.length-1)];let d=e.style;if(Array.isArray(d)){let e={};for(let[t,n]of d)n!==null&&typeof n!=`boolean`&&(e[t]=typeof n==`number`?n:i.value(n));u.style=e}else if(typeof d==`string`&&d!==``){let e={};for(let t of d.split(`;`)){let n=t.indexOf(`:`);n>0&&(e[t.slice(0,n)]=t.slice(n+1))}u.style=e}let f=n.locate(e.src);return[cs.Element({tag:e.el,props:u,children:c(e.children??[],t,r),origins:f===void 0?[]:[f],authored:!0})]}return`if`in e?[cs.Fragment({children:[...c(e.then,t,r),...c(e.else??[],t,r)]})]:`each`in e?[cs.Fragment({children:c(e.children,t,r)})]:`raw`in e?(r.next++,[cs.Raw({html:Ih(i,e.raw),text:``,origins:[]})]):[]}),l=(e,t)=>{for(let n of e)n.type===`Fragment`?l(n.children,t):n.type===`Raw`?t.raws.push(n.html):n.type===`Element`&&(t.styles.push(n.props.style===void 0?void 0:n.props.style),t.bgcolors.push(typeof n.props.bgcolor==`string`?n.props.bgcolor:void 0),l(n.children,t))},u=[],d=``,f=``,p=new Set;for(let r=0;r<s;r++){let i=pu(c([e],r,{next:0})[0]??cs.Fragment({children:[]}),t);r===0&&(d=i.headCss,f=i.fontFaceCss);for(let e of i.diagnostics){let t=`${e.code}\0${e.message}`;p.has(t)||(p.add(t),n.report(e))}let a={styles:[],bgcolors:[],raws:[]};l([i.tree],a),u.push(a)}let m=(e,t)=>{if(e===void 0)return``;let r=Object.entries(e);if(r.length===0)return``;let a=n.locate(t.src),o=r.some(([,e])=>e.includes(``)),s=pl(Object.fromEntries(r.filter(([,e])=>!e.includes(``))),a===void 0?[]:[a]);for(let e of s.diagnostics)n.report(e);return o?r.map(([e,t])=>[e,i.toValue(t)??t]):s.css},h=0,g=0,_=0,v=e=>e.map(e=>{if(rm(e))return e;if(`el`in e){let t=h++,n=g++,r=a[t],o=u[0],s=o?.styles[n],c=r!==void 0&&Nh(r).length>1?Ph(r,t=>m(u[Math.min(t,u.length-1)]?.styles[n],e)):m(s,e),l=o?.bgcolors[n],d=typeof e.attrs?.bgcolor==`string`&&l!==void 0&&l!==e.attrs.bgcolor?{...e.attrs,bgcolor:i.toValue(l)??l}:e.attrs,f=v(e.children??[]),{style:p,children:_,attrs:y,...b}=e;return{...b,...d===void 0?{}:{attrs:d},...c===``?{}:{style:c},...f.length===0?{}:{children:f}}}if(`if`in e){let t=v(e.then),n=v(e.else??[]);return{...e,then:t,...e.else===void 0?{}:{else:n}}}if(`each`in e)return{...e,children:v(e.children)};if(`raw`in e){h++;let t=u[0]?.raws[_++];return t===void 0?e:{...e,raw:Am(i,t)}}return e});return{root:v([e])[0]??e,headCss:d,fontFaceCss:f}},Rh=`defineTemplate`,zh=[`email`,`sms`,`whatsapp`],Bh=(e,t)=>{let n=e.entry,r=n.defaultExport;r?.type===`Identifier`&&(r=n.declarations.get(Y(r,`name`)??``)?.value);let i=(e,i,a=`no-template`)=>{t.add(n.parsed,r??n.parsed.program,a,e,i)};if(r===void 0||r.type!==`CallExpression`)return i(`The entry must default-export defineTemplate({ ... }).`,"Write `export default defineTemplate({ id, schema, fixtures, email })`.");let a=J(r,`callee`),o=a===void 0?void 0:Y(a,`name`),s=o===void 0?void 0:n.imports.get(o);if(o===`defineEmail`)return i("`defineEmail` runs a render function, which the static profile does not read.","Use `defineTemplate` from @samva/markup with `email: { subject, preheader, body }`.",`legacy-definition`);if(s?.kind!==`markup`||s.imported!==Rh)return i(`The entry must default-export defineTemplate({ ... }) imported from @samva/markup.`,'Add `import { defineTemplate } from "@samva/markup";`.');let c=Yp(r,`arguments`)[0],l=c===void 0?void 0:Zp(c);if(l===void 0||l.type!==`ObjectExpression`)return i(`defineTemplate takes one object literal.`,`Write defineTemplate({ id, schema, fixtures, email }).`);let u=new Map;for(let e of Yp(l,`properties`)){let r=Vm(e),i=J(e,`value`);if(r===void 0||i===void 0){t.add(n.parsed,e,`dynamic-definition`,`A definition field is written out, not spread or computed.`,"Write each field as `name: value`.");continue}u.set(r,i)}return{module:n,call:r,fields:u}},Vh=(e,t,n)=>{let r=Zp(n);if(/Function/.test(r.type))return{module:t,fn:r};if(r.type===`Identifier`){let n=Y(r,`name`)??``,i=t.declarations.get(n);if(i!==void 0)return Vh(e,t,i.value);let a=t.imports.get(n);if(a?.kind===`project`){let t=e.modules.get(a.path);if(t===void 0)return;let n=a.imported==="default"?void 0:t.exports.get(a.imported);if(a.imported==="default"&&t.defaultExport!==void 0)return Vh(e,t,t.defaultExport);let r=n===void 0?void 0:t.declarations.get(n);return r===void 0?void 0:Vh(e,t,r.value)}}},Hh=e=>{let t=[],n=new Set,r=i=>{if(!n.has(i.path)){n.add(i.path);for(let n of i.ordered)if(n.kind===`css`)t.includes(n.path)||t.push(n.path);else{let t=e.modules.get(n.path);t!==void 0&&r(t)}}};return r(e.entry),t},Uh=(e,t,n)=>{let r=!1,i=e=>e.map(e=>{if(r||rm(e))return e;if(`el`in e)return t(e)?(r=!0,n(e)):{...e,...e.children===void 0?{}:{children:i(e.children)}};if(`if`in e){let t=i(e.then),n=i(e.else??[]);return{...e,then:t,...e.else===void 0?{}:{else:n}}}return`each`in e?{...e,children:i(e.children)}:e});return{nodes:i(e),done:r}},Wh={raw:[`<!--[if !mso]><!-->`]},Gh={raw:[`<!--<![endif]-->`]},Kh=(e,t,n={},r=[])=>({ir:e.blocking?void 0:t,fixtures:n,assets:r,diagnostics:e.items}),qh=(e,t,n,r)=>{let i=(e,t={},i=r.assets)=>Kh(n,e,t,i),a=r.urlFor,o={project:t,assetUrl:a},s=Bh(t,n);if(s===void 0)return i(void 0);let{module:c,fields:l}=s,u=e=>l.get(e)??s.call,d=l.has(`id`)?Um(o,c,l.get(`id`)):void 0;d===void 0||!d.ok||typeof d.value!=`string`?n.add(c.parsed,u(`id`),`invalid-template-id`,`The template id is a string literal.`,`Write id: "order-shipped".`):Dc.test(d.value)||n.add(c.parsed,u(`id`),`invalid-template-id`,`Template id ${JSON.stringify(d.value)} is not lowercase kebab-case.`,`Write lowercase letters and digits joined by single hyphens, for example "order-shipped".`);let f=d!==void 0&&d.ok&&typeof d.value==`string`?d.value:``,p,m=l.get(`schema`);if(m===void 0)n.add(c.parsed,s.call,`missing-schema`,`The template declares no schema.`,"Add `schema: jsonSchema<Input>({ ... })`.");else{let t=Um(o,c,m);t.ok&&typeof t.value==`object`&&t.value!==null?p=t.value:e.schema===void 0?n.add(t.ok?c.parsed:t.module.parsed,t.ok?m:t.node,`schema-not-static`,`The schema cannot be read without running it${t.ok?``:` (${t.reason})`}.`,'Write the schema as a literal: `jsonSchema<Input>({ type: "object", properties: { … } })`, or compile with the schema a library already converted.'):p={...e.schema}}let h=()=>!0;if(p!==void 0)try{let e=Tc(Cc(p));h=e.validate,p=e.schema}catch(e){if(!(e instanceof TypeError))throw e;n.add(c.parsed,u(`schema`),`invalid-schema`,e.message,`Use only the JSON Schema keywords the README lists.`),p=void 0}let g={},_=l.get(`fixtures`);if(_===void 0)n.add(c.parsed,s.call,`missing-fixtures`,`The template declares no fixtures.`,"Add `fixtures: { default: { … } }`.");else{let e=Um(o,c,_);if(!e.ok)n.add(e.module.parsed,e.node,`fixtures-not-static`,`Fixtures are data, and this one is computed (${e.reason}).`,`Write each fixture as a literal object; an imported asset is allowed.`);else if(typeof e.value!=`object`||e.value===null||Object.keys(e.value).length===0)n.add(c.parsed,_,`missing-fixtures`,`The template declares no fixtures.`,"Declare at least one: `fixtures: { default: { … } }`.");else{let t=Zp(_),r=new Map;if(t.type===`ObjectExpression`)for(let e of Yp(t,`properties`)){let t=Vm(e);t!==void 0&&r.set(t,J(e,`key`)??e)}for(let[t,i]of Object.entries(e.value)){if(!Ec.test(t)){n.add(c.parsed,r.get(t)??_,`invalid-fixture-name`,`Fixture key ${JSON.stringify(t)} is not one path segment.`,"Use letters, digits, `.`, `_` and `-`, starting with a letter or digit.");continue}if(g[t]=i,p!==void 0&&!h(i)){let e=h.errors?.at(-1)??h.errors?.[0];n.add(c.parsed,r.get(t)??_,`fixture-invalid`,`Fixture ${JSON.stringify(t)} does not match the schema${e===void 0?``:`: ${e.instanceLocation===`#`||e.instanceLocation===void 0?``:`${e.instanceLocation.replace(/^#/,``)} `}${e.error??`is invalid`}`}.`,`Change the fixture, or the schema, so a fixture is a payload a send could make.`)}}}}let v=l.has(`locale`)?Um(o,c,l.get(`locale`)):void 0,y=v?.ok===!0&&typeof v.value==`string`?v.value:void 0;l.has(`locale`)&&y===void 0&&n.add(c.parsed,u(`locale`),`invalid-locale`,`The locale is a string literal.`,`Write locale: "en-US".`);let b=new $m({project:t,findings:n,staticContext:o,assetUrl:a,brand:e.brand,brandPlugin:e.brandPlugin??jc,channel:ih}),x=e=>({module:e,env:new Map,stack:[],loops:[],depth:0}),S=e=>{let r=Vh(t,c,e);if(r===void 0){n.add(c.parsed,e,`not-a-function`,`A channel field is a function of the input, written in place or declared in the project.`,"Write `(input) => …`.");return}let i=x(r.module),a=new Map,o=Yp(r.fn,`params`)[0];o!==void 0&&b.bindPattern(i,o,{k:`path`,path:``},a,!1);let s={...i,env:a},l=b.functionExpression(s,r.fn);return l===void 0?void 0:{ctx:s,body:l}};for(let e of l.keys())[`id`,`schema`,`fixtures`,`locale`,...zh].includes(e)||n.add(c.parsed,u(e),`unknown-field`,`\`${e}\` is not a defineTemplate field.`,`The fields are id, schema, fixtures, locale, email, sms and whatsapp.`);let C,w=[],T=l.get(`email`),E;if(T!==void 0){let i=Zp(T),a=new Map;if(i.type===`ObjectExpression`)for(let e of Yp(i,`properties`)){let t=Vm(e),n=J(e,`value`);t!==void 0&&n!==void 0&&a.set(t,n)}else n.add(c.parsed,T,`invalid-channel`,"The email channel is an object: `{ subject, preheader, body }`.",`Write email: { subject: …, body: … }.`);for(let e of a.keys())[`subject`,`preheader`,`body`].includes(e)||n.add(c.parsed,a.get(e),`unknown-field`,`\`${e}\` is not an email field.`,`The fields are subject, preheader and body.`);let o=e=>{let t=a.get(e);if(t===void 0)return;let n=S(t);return n===void 0?void 0:b.value(n.ctx,n.body,!1)},s=a.has(`subject`)?o(`subject`):void 0;!a.has(`subject`)&&i.type===`ObjectExpression`&&n.add(c.parsed,T,`missing-subject`,`The email channel needs a subject.`,"Add `subject: (input) => …`.");let l=o(`preheader`),d,f=a.get(`body`);if(f===void 0&&i.type===`ObjectExpression`)n.add(c.parsed,T,`missing-body`,`The email channel needs a body.`,"Add `body: (input) => (<Email>…</Email>)`.");else if(f!==void 0){let e=S(f);if(e!==void 0){let t=b.content(e.ctx,e.body);t.length===1?d=t[0]:n.blocking||n.add(e.ctx.module.parsed,e.body,`multiple-roots`,t.length===0?`The email body renders nothing.`:`The email body renders more than one root.`,`Wrap the body in a single element such as <Email>.`)}}if(s!==void 0&&d!==void 0){let i=[];r.tailwindSheet!==void 0&&i.push(r.tailwindSheet);for(let e of Hh(t)){let t=r.stylesheets.get(e);t!==void 0&&i.push(t)}let a=[e.entry,...b.sources],o=Lh(d,qp(i),{locate:t=>{if(t!==void 0)return{fileName:a[t[2]??0]??e.entry,lineNumber:t[0],columnNumber:t[1]}},report:e=>{n.items.push(e)}}),f=o.root;if(o.headCss!==``||o.fontFaceCss!==``){let e=[...o.headCss===``?[]:[{el:`style`,children:[o.headCss]}],...o.fontFaceCss===``?[]:[Wh,{el:`style`,children:[o.fontFaceCss]},Gh]],t=Uh([f],e=>e.el===`head`,t=>({...t,children:[...t.children??[],...e]}));t.done?f=t.nodes[0]??f:n.report({code:`missing-head`,severity:`error`,message:`Styles that cannot be inlined — media queries, dark-scheme rules and pseudo-selectors — need a <head> to live in.`,fix:`Wrap the message in <Email>, or write those declarations as inline styles.`,origins:[]})}if(l!==void 0){let e=Uh([f],e=>e.el===`body`,e=>({...e,children:[{preheader:!0},...e.children??[]]}));e.done?f=e.nodes[0]??f:n.add(c.parsed,u(`email`),`preheader-without-shell`,`A preheader is the hidden inbox preview inside <body>, and this body has no <Email> shell.`,`Wrap the body in <Email>.`)}Cm([f],e=>w.push(e)),p!==void 0&&w.push(...Sm(p,[f],[s,...l===void 0?[]:[l]])),E={subject:s,...l===void 0?{}:{preheader:l},body:f}}}let D=kh({lowerer:b,findings:n,fields:l,module:c,openFunction:S,checks:w,schema:p}),O=[e.entry,...b.sources];for(let t of w){let r=t.src,i=O[r?.[2]??0]??e.entry;n.report({code:t.code,severity:`error`,message:t.message,...t.fix===void 0?{}:{fix:t.fix},origins:r===void 0?[{fileName:e.entry,lineNumber:1,columnNumber:1}]:[{fileName:i,lineNumber:r[0],columnNumber:r[1]}]})}return p!==void 0&&f!==``&&(E!==void 0||D.sms!==void 0||D.whatsapp!==void 0)?C={sml:1,template:f,...y===void 0?{}:{locale:y},sources:O,...E===void 0?{}:{email:E},...D.sms===void 0?{}:{sms:D.sms},...D.whatsapp===void 0?{}:{whatsapp:D.whatsapp},schema:p}:T===void 0&&!l.has(`sms`)&&!l.has(`whatsapp`)&&n.add(c.parsed,s.call,`no-channel`,`The template declares no channel.`,"Add `email`, `sms` or `whatsapp`."),i(C,g)},Jh=`@samva/markup`,Yh=`@samva/markup/`,Xh={"@samva/markup/email/components":`@samva/markup/email`},Zh=[`.tsx`,`.ts`],Qh=(e,t,n)=>{let r=Gp(Wp(e),t.replace(/[?#].*$/,``));if(r!==void 0){if(Object.hasOwn(n,r))return r;for(let e of Zh)if(Object.hasOwn(n,`${r}${e}`))return`${r}${e}`;for(let e of Zh)if(Object.hasOwn(n,`${r}/index${e}`))return`${r}/index${e}`}},$h=e=>/\.[cm]?[jt]sx?$/.test(e),eg=e=>e.type===`Identifier`?[Y(e,`name`)??``]:[],tg=(e,t,n,r)=>{let i=new Map,a=new Set,o=new Set,s=!1,c=t=>{let l=i.get(t);if(l!==void 0)return l;if(o.has(t))return;let u=e[t];if(u===void 0)return;let d=typeof u==`string`?u:new TextDecoder().decode(u),f;try{f=$p(t,d)}catch(e){if(!(e instanceof Qp))throw e;n.items.push({code:`syntax-error`,severity:`error`,message:e.message,origins:[{fileName:t,lineNumber:e.line,columnNumber:e.column}]}),s=!0;return}o.add(t);let p=new Map,m=[],h=new Map,g=new Map,_,v=e=>{if(e.type===`VariableDeclaration`)for(let t of Yp(e,`declarations`)){let n=J(t,`id`),r=J(t,`init`);if(n!==void 0&&r!==void 0)for(let t of eg(n))h.set(t,{value:Zp(r),node:e})}else if(e.type===`FunctionDeclaration`){let t=Y(J(e,`id`)??e,`name`);t!==void 0&&h.set(t,{value:e,node:e})}};for(let i of Yp(f.program,`body`))switch(i.type){case`ImportDeclaration`:{let o=Y(J(i,`source`)??i,`value`)??``,c=Y(i,`importKind`)===`type`,l=Yp(i,`specifiers`);if(c)break;let u=e=>Y(J(e,`local`)??e,`name`)??``,d=e=>{if(e.type===`ImportDefaultSpecifier`)return`default`;if(e.type===`ImportNamespaceSpecifier`)return`*`;let t=J(e,`imported`);return t===void 0?u(e):Y(t,`name`)??Y(t,`value`)??u(e)},h=Xh[o];if(h!==void 0){n.add(f,J(i,`source`)??i,`moved-import`,`\`${o}\` moved to \`${h}\`; the imported names are unchanged.`,`Import from "${h}".`),s=!0;break}if(o===Jh||o.startsWith(Yh)){for(let e of l)Y(e,`importKind`)!==`type`&&p.set(u(e),{kind:`markup`,specifier:o,imported:d(e),node:e});break}if(Pc(o,r.brandPlugin)!==void 0){for(let e of l)Y(e,`importKind`)!==`type`&&p.set(u(e),{kind:`brand`,specifier:o,imported:d(e),node:e});break}if(!/^\.{0,2}\//.test(o)){n.add(f,i,`non-project-import`,`\`${o}\` is not part of the project; templates import only @samva/markup and files inside the project.`,`Remove the import, or copy the code you need into a project file.`),s=!0;break}let g=Qh(t,o,e);if(g===void 0&&r.lenient===!0){let e=Gp(Wp(t),o.replace(/[?#].*$/,``)),n=e!==void 0&&gu(e),r=e!==void 0&&($h(e)||!/\.[a-z0-9]+$/i.test(e));if(e!==void 0&&(e.endsWith(`.css`)||n||r)){if(!e.endsWith(`.css`))for(let t of l)n?p.set(u(t),{kind:`asset`,path:e,node:t}):(a.add(u(t)),p.set(u(t),{kind:`project`,path:e,imported:d(t),node:t}));break}}if(g===void 0){n.add(f,i,`unresolved-import`,`\`${o}\` names no file in the project.`,`Check the path and the file extension.`),s=!0;break}if(g.endsWith(`.css`)){m.push({kind:`css`,path:g});break}if(gu(g)){for(let e of l)p.set(u(e),{kind:`asset`,path:g,node:e});break}if($h(g)){m.push({kind:`script`,path:g});for(let e of l)p.set(u(e),{kind:`project`,path:g,imported:d(e),node:e});break}n.add(f,i,`unresolved-import`,`\`${o}\` is a file type templates cannot import.`,`Import a script, a stylesheet or an asset such as .png or .woff2.`),s=!0;break}case`ExportNamedDeclaration`:{let e=J(i,`declaration`);if(e!==void 0){if(v(e),e.type===`VariableDeclaration`)for(let t of Yp(e,`declarations`))for(let e of eg(J(t,`id`)??t))g.set(e,e);else if(e.type===`FunctionDeclaration`){let t=Y(J(e,`id`)??e,`name`);t!==void 0&&g.set(t,t)}}else for(let e of Yp(i,`specifiers`)){let t=J(e,`exported`),n=J(e,`local`),r=t===void 0?void 0:Y(t,`name`)??Y(t,`value`),i=n===void 0?void 0:Y(n,`name`);r!==void 0&&i!==void 0&&g.set(r,i)}break}case`ExportDefaultDeclaration`:{let e=J(i,`declaration`);e!==void 0&&(_=Zp(e));break}case`VariableDeclaration`:case`FunctionDeclaration`:v(i)}let y={path:t,parsed:f,imports:p,ordered:m,declarations:h,exports:g,defaultExport:_};i.set(t,y),o.delete(t);for(let e of m)e.kind===`script`&&c(e.path);return y},l=c(t);if(!(l===void 0||s))return{modules:i,entry:l,unresolved:a}},ng=`template.tsx`,rg=new Set([`brand-unavailable`,`unmatched-class`]),ig=(e,t)=>typeof e==`string`?{[t]:e}:e,ag=(e,t=ng,n=jc)=>{let r=new Kp,i=tg(ig(e,t),t,r,{brandPlugin:n,lenient:!0});if(i===void 0)return r.items;qh({entry:t,brand:void 0,brandPlugin:n},i,r,{assets:[],stylesheets:new Map,tailwindSheet:void 0,urlFor:e=>`https://assets.invalid/${e}`});let a=[...i.unresolved];return r.items.filter(e=>!rg.has(e.code)&&!e.code.startsWith(`tailwind-`)&&!a.some(t=>e.message.includes(`<${t}`)||e.message.includes(`\`${t}\``)))},og=e=>`${e.code}\0${e.message}`,sg=(e,t)=>{let n=new Map;for(let t of e)t.severity===`error`&&n.set(og(t),(n.get(og(t))??0)+1);let r=[];for(let e of t){if(e.severity!==`error`)continue;let t=n.get(og(e))??0;t>0?n.set(og(e),t-1):r.push(e)}return r},cg=e=>is(e)&&`type`in e&&typeof e.type==`string`&&`start`in e&&typeof e.start==`number`&&`end`in e&&typeof e.end==`number`,lg=e=>Array.isArray(e)?e.filter(cg):[],ug=(e,t,n=null)=>{if(Array.isArray(e)){for(let r of e)ug(r,t,n);return}if(cg(e)){t(e,n);for(let[n,r]of Object.entries(e))n!==`loc`&&n!==`extra`&&n!==`comments`&&ug(r,t,e)}},dg=e=>{try{let t=zp(e,{sourceType:`module`,plugins:[`typescript`,`jsx`]});return cg(t)?t:null}catch{return null}},fg=e=>e.type===`Identifier`||e.type===`MemberExpression`&&e.computed===!1&&cg(e.object)&&fg(e.object),pg=e=>e.split(/\r\n|\n|\r|\u2028|\u2029/).map(e=>e.trim()).filter(e=>e!==``).join(` `),mg=(e,t,n,r)=>{let i=t.type===`JSXExpressionContainer`&&cg(t.expression)?t.expression:t,a=i.type===`StringLiteral`||i.type===`NumericLiteral`||i.type===`BooleanLiteral`||i.type===`JSXText`,o=n.slice(i.start,i.end),s=i.type===`JSXText`?{start:i.start+(o.length-o.trimStart().length),end:i.end-(o.length-o.trimEnd().length)}:{start:t.start,end:t.end};return{name:e,literalType:i.type===`NumericLiteral`?`number`:i.type===`BooleanLiteral`?`boolean`:`string`,kind:a?`literal`:fg(i)?`binding`:`computed`,value:a&&i.type===`JSXText`&&typeof i.value==`string`?pg(i.value):a&&(typeof i.value==`string`||typeof i.value==`number`||typeof i.value==`boolean`)?String(i.value):n.slice(i.start,i.end),start:s.start,end:s.end,syntax:r}},hg=(e,t,n)=>{if(t?.type!==`JSXElement`&&t?.type!==`JSXFragment`)return{previous:null,next:null};let r=lg(t.children).filter(e=>e.type!==`JSXText`||n.slice(e.start,e.end).trim()!==``),i=r.findIndex(t=>t.start===e.start),a=e=>e?.type===`JSXElement`?{start:e.start,end:e.end}:null;return{previous:a(r[i-1]),next:a(r[i+1])}},gg=(e,t,n)=>{if(t!==n.fileName)return null;let r=dg(e);if(r===null)return null;let i=bs(e),a=i[n.lineNumber-1];if(a===void 0||!Number.isInteger(n.columnNumber)||n.columnNumber<1)return null;let o=a+n.columnNumber-1;if(o>=(i[n.lineNumber]??e.length))return null;let s=null;return ug(r,(t,n)=>{if(t.type!==`JSXElement`||t.start!==o||!cg(t.openingElement))return;let r=t.openingElement,i=[];for(let t of lg(r.attributes))if(t.type===`JSXAttribute`&&cg(t.name)&&typeof t.name.name==`string`&&cg(t.value)){let n=t.value,r=n.type===`JSXExpressionContainer`&&cg(n.expression)?n.expression:null;if(t.name.name===`style`&&r?.type===`ObjectExpression`&&!lg(r.properties).some(e=>e.type===`SpreadElement`))for(let t of lg(r.properties)){if(t.type!==`ObjectProperty`||t.computed===!0||!cg(t.key)||!cg(t.value))continue;let n=t.key.type===`Identifier`?t.key.name:t.key.value;typeof n==`string`&&i.push(mg(`style.${n}`,t.value,e,`value`))}else i.push(mg(t.name.name,n,e,`attribute`))}let a=lg(t.children).filter(t=>t.type!==`JSXText`||e.slice(t.start,t.end).trim()!==``);if(a.length===1&&a[0]!==void 0&&a[0].type!==`JSXElement`&&a[0].type!==`JSXFragment`)i.unshift(mg(`children`,a[0],e,`child`));else if(a.length>1){let t=a.flatMap((t,n)=>t.type===`JSXText`?[mg(`text.${n}`,t,e,`child`)]:[]);i.unshift(...t)}s={start:t.start,end:t.end,contentStart:r.selfClosing===!0?null:r.end,contentEnd:cg(t.closingElement)?t.closingElement.start:null,tag:cg(r.name)?e.slice(r.name.start,r.name.end):`element`,properties:i,attributeInsertion:(()=>{let e=lg(r.attributes).at(-1);return e===void 0?cg(r.name)?r.name.end:r.end-1:e.end})(),hasSpread:lg(r.attributes).some(e=>e.type===`JSXSpreadAttribute`),structural:n?.type===`JSXElement`||n?.type===`JSXFragment`,...hg(t,n,e)}}),s},_g=/^[^\s{}<>&](?:[^{}<>&\r\n\u2028\u2029]*[^\s{}<>&])?$/,vg=(e,t,n)=>{if(t.kind!==`literal`||t.literalType===`number`&&(n.trim()===``||!Number.isFinite(Number(n)))||t.literalType===`boolean`&&n!==`true`&&n!==`false`)return null;let r=t.literalType===`string`?JSON.stringify(n):t.literalType===`number`?String(Number(n)):n,i=e.slice(t.start,t.end),a=t.syntax===`child`&&!i.startsWith(`{`)&&_g.test(n);return{start:t.start,end:t.end,before:i,after:a?n:t.syntax===`child`||t.syntax===`attribute`&&t.literalType!==`string`?`{${r}}`:r}},yg=(e,t,n)=>({start:t.start,end:t.end,before:e.slice(t.start,t.end),after:t.syntax===`value`?n:`{${n}}`}),bg=(e,t,n)=>{let r=n.file??n.entry,i=e=>({...n.files,[r]:e}),a=sg(ag(i(e),n.entry),ag(i(t),n.entry)),o=a[0];if(o===void 0)return null;let s=a.length>1?` (and ${a.length-1} more)`:``;return`This change leaves the static profile: ${o.message}${o.fix===void 0?``:` ${o.fix}`}${s}`},xg=(e,t,n={})=>{let r=[...t].sort((e,t)=>t.start-e.start),i=e.length,a=e;for(let t of r){if(t.start<0||t.end<t.start||t.end>i||e.slice(t.start,t.end)!==t.before)return{ok:!1,reason:`Source changed at this target. Select it again before applying the edit.`};a=a.slice(0,t.start)+t.after+a.slice(t.end),i=t.start}if(dg(a)===null)return{ok:!1,reason:`This change is not valid TSX. Review it in Source.`};if(n.profile!==void 0&&a!==e){let t=bg(e,a,n.profile);if(t!==null)return{ok:!1,reason:t}}return{ok:!0,source:a}},Sg=(e,t)=>{let n=Math.max(e.lastIndexOf(`
24
- `,t-1),e.lastIndexOf(`\r`,t-1)),r=e.slice(n+1,t);return/^[ \t]*$/.test(r)?r:null},Cg=(e,t)=>{if(Sg(e,t.start)===null)return t;let n=/^[ \t]*(\r\n|\n|\r)/.exec(e.slice(t.end));return n===null?t:{start:t.start-(Sg(e,t.start)??``).length,end:t.end+n[0].length}},wg=(e,t,n)=>{if(n.kind===`insert`)return t.contentEnd===null?null:[{start:t.contentEnd,end:t.contentEnd,before:``,after:n.tsx}];if(!t.structural)return null;let r=e.slice(t.start,t.end);if(n.kind===`duplicate`){let n=Sg(e,t.start);return[{start:t.end,end:t.end,before:``,after:n===null?r:`\n${n}${r}`}]}if(n.kind===`reorder`){let i=n.direction===`before`?t.previous:t.next;return i===null?null:[{start:i.start,end:i.end,before:e.slice(i.start,i.end),after:r},{start:t.start,end:t.end,before:r,after:e.slice(i.start,i.end)}]}let i=Cg(e,t),a={start:i.start,end:i.end,before:e.slice(i.start,i.end),after:``};if(n.kind===`delete`)return[a];let o=n.destination.contentEnd;return o===null||o>=t.start&&o<=t.end?null:[a,{start:o,end:o,before:``,after:r}]},Tg=(e,t)=>{let n=e.program;if(!cg(n))return null;for(let e of lg(n.body)){let n=e.type===`ExportNamedDeclaration`&&cg(e.declaration)?e.declaration:e;if(n.type===`VariableDeclaration`){for(let e of lg(n.declarations))if(cg(e.id)&&e.id.name===t&&cg(e.init)&&e.init.type===`ObjectExpression`)return e.init}}return null},Eg=e=>{let t=dg(e);if(t===null)return[];let n=[];return ug(t,r=>{if(r.type!==`CallExpression`||!cg(r.callee)||r.callee.type!==`Identifier`||r.callee.name!==`defineTemplate`)return;let i=lg(r.arguments)[0];if(i?.type!==`ObjectExpression`)return;let a=lg(i.properties).find(e=>e.type===`ObjectProperty`&&cg(e.key)&&e.key.name===`fixtures`&&e.computed!==!0);if(a!==void 0&&cg(a.value)&&a.value.type===`ObjectExpression`)for(let r of lg(a.value.properties)){if(r.type!==`ObjectProperty`||r.computed===!0||!cg(r.key)||!cg(r.value))continue;let i=r.key.type===`Identifier`?r.key.name:r.key.value,a=r.value.type===`Identifier`&&typeof r.value.name==`string`?Tg(t,r.value.name)??r.value:r.value;typeof i==`string`&&n.push({name:i,start:a.start,end:a.end,source:e.slice(a.start,a.end)})}}),n},Dg=e=>e.split(/\s+/).filter(e=>e!==``),Og=(e,t,n)=>{let r=t.properties.find(e=>e.name===`className`),i=e=>{if(n.kind===`set`)return Dg(n.value).join(` `);let t=Dg(n.tokens);return n.kind===`add`?[...e,...t.filter(t=>!e.includes(t))].join(` `):e.filter(e=>!t.includes(e)).join(` `)};if(r===void 0){if(t.hasSpread)return{ok:!1,reason:`A spread attribute can supply className here, so a class list cannot be added safely. Edit it in Source.`};if(n.kind===`remove`)return{ok:!0,edits:[]};let e=i([]);return e===``?{ok:!0,edits:[]}:{ok:!0,edits:[{start:t.attributeInsertion,end:t.attributeInsertion,before:``,after:` className=${JSON.stringify(e)}`}]}}if(r.kind!==`literal`||r.literalType!==`string`)return{ok:!1,reason:`className is ${r.kind===`binding`?`bound to`:`computed from`} \`${r.value}\`, so editing it would discard that choice. Change the literal classes inside it in Source.`};let a=i(Dg(r.value));return{ok:!0,edits:[{start:r.start,end:r.end,before:e.slice(r.start,r.end),after:JSON.stringify(a)}]}},kg=e=>is(e)&&typeof e.type==`string`&&typeof e.start==`number`&&typeof e.end==`number`,Ag=e=>Array.isArray(e)?e.filter(kg):[],jg=(e,t)=>{let n=e[t];return kg(n)?n:null},Mg=e=>{try{let t=zp(e,{sourceType:`module`,plugins:[`typescript`,`jsx`]});return kg(t)?t:null}catch{return null}},Ng=(e,t)=>{if(Array.isArray(e)){for(let n of e)Ng(n,t);return}if(kg(e)&&t(e)!==!1)for(let[n,r]of Object.entries(e))n!==`loc`&&n!==`extra`&&n!==`comments`&&Ng(r,t)},Pg=e=>e===null?``:e.type===`JSXIdentifier`?typeof e.name==`string`?e.name:``:e.type===`JSXMemberExpression`?`${Pg(jg(e,`object`))}.${Pg(jg(e,`property`))}`:``,Fg=e=>{if(e.type!==`JSXElement`)return null;let t=jg(e,`openingElement`);if(t===null)return null;let n=jg(e,`closingElement`);return{node:e,opening:t,closing:n,tag:Pg(jg(t,`name`)),children:Ag(e.children),attributes:Ag(t.attributes),selfClosing:t.selfClosing===!0,contentStart:t.end,contentEnd:n===null?t.end:n.start}},Ig=e=>{let t=jg(e,`body`);if(t===null)return null;if(t.type===`JSXElement`)return t;if(t.type!==`BlockStatement`)return null;let n=Ag(t.body).filter(e=>e.type!==`EmptyStatement`),r=n.length===1?n[0]:void 0,i=r?.type===`ReturnStatement`&&r!==void 0?jg(r,`argument`):null;return i!==null&&i.type===`JSXElement`?i:null},Lg=e=>{if(e.computed===!0)return null;let t=jg(e,`key`);return t===null?null:t.type===`Identifier`?typeof t.name==`string`?t.name:null:t.type===`StringLiteral`&&typeof t.value==`string`?t.value:null},Rg=(e,t)=>{let n=null;return Ng(e,e=>{if(n!==null)return!1;if(e.type!==`CallExpression`)return;let r=jg(e,`callee`);if(r?.type!==`Identifier`||r.name!==`defineTemplate`)return;let i=Ag(e.arguments)[0];if(i?.type!==`ObjectExpression`)return!1;for(let e of Ag(i.properties)){if(Lg(e)!==t)continue;let r=e.type===`ObjectMethod`?e:e.type===`ObjectProperty`?jg(e,`value`):null;if(r===null||r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`&&r.type!==`ObjectMethod`)return!1;let i=Ig(r),a=i===null?null:Fg(i);return a!==null&&(n={root:a,parameter:Ag(r.params)[0]??null}),!1}return!1}),n},zg=(e,t,n)=>{let r=n;return Ng(e,e=>{if(e.type===`ImportDeclaration`){if(jg(e,`source`)?.value!==t)return!1;for(let t of Ag(e.specifiers)){let e=jg(t,`imported`),i=jg(t,`local`);t.type===`ImportSpecifier`&&(e?.name===n||e?.value===n)&&(r=typeof i?.name==`string`?i.name:n)}return!1}}),r},Bg=e=>{let t=e.split(/\r\n|\n|\r/),n=0;t.forEach((e,t)=>{/[^ \t]/.test(e)&&(n=t)});let r=``;return t.forEach((e,i)=>{let a=e.replace(/\t/g,` `);i!==0&&(a=a.replace(/^ +/,``)),i!==t.length-1&&(a=a.replace(/ +$/,``)),a!==``&&(r+=i===n?a:`${a} `)}),r},Vg=e=>{let t=jg(e,`expression`);if(t===null)return null;if(t.type===`StringLiteral`&&typeof t.value==`string`)return t.value;if(t.type===`TemplateLiteral`&&Ag(t.expressions).length===0){let e=Ag(t.quasis)[0]?.value;return is(e)&&typeof e.cooked==`string`?e.cooked:null}return null},Hg=(e,t)=>{let n=e.slice(t.start,t.end).replace(/\s+/g,` `).trim();return n.length>60?`${n.slice(0,59)}…`:n},Ug=(e,t)=>{let n=[],r=t.contentStart,i=``,a=e=>{n.push({kind:`text`,text:i,start:r,end:e}),i=``};for(let o of t.children){if(o.type===`JSXText`){i+=Bg(typeof o.value==`string`?o.value:``);continue}if(o.type===`JSXExpressionContainer`){let e=Vg(o);if(e!==null){i+=e;continue}}a(o.start),n.push({kind:`locked`,summary:Hg(e,o),start:o.start,end:o.end}),r=o.end}return a(t.contentEnd),n},Wg=e=>!/[{}<>&\r\n\t]/.test(e),Gg=(e,t,n)=>{let r=[...e],i=r.map(e=>!Wg(e));if(t)for(let e=0;e<r.length&&/\s/.test(r[e]);e++)i[e]=!0;if(n)for(let e=r.length-1;e>=0&&/\s/.test(r[e]);e--)i[e]=!0;let a=``,o=``,s=!1,c=()=>{o!==``&&(a+=s?`{${JSON.stringify(o)}}`:o,o=``)};return r.forEach((e,t)=>{o!==``&&i[t]!==s&&c(),s=i[t],o+=e}),c(),a},Kg=(e,t,n,r,i)=>{let a=n[r];if(a?.kind!==`text`)return{ok:!1,reason:`That part of the body is locked.`};if(a.text===i)return{ok:!0,edits:[]};if(t.selfClosing){let n=t.opening,r=n.end-2;for(;r>n.start&&/\s/.test(e[r-1]);)r--;return{ok:!0,edits:[{start:r,end:n.end,before:e.slice(r,n.end),after:`>${Gg(i,!1,!1)}</${t.tag}>`}]}}let o=e.slice(a.start,a.end),s=/^\s*/.exec(o)?.[0]??``,c=/[\r\n]/.test(s)?s:``,l=o.slice(c.length),u=/\s*$/.exec(l)?.[0]??``,d=/[\r\n]/.test(u)?u:``,f=a.start+c.length,p=a.end-d.length;return{ok:!0,edits:[{start:f,end:p,before:e.slice(f,p),after:Gg(i,c!==``,d!==``)}]}},qg=(e,t)=>e.attributes.find(e=>e.type===`JSXAttribute`&&Pg(jg(e,`name`))===t)??null,Jg=(e,t,n)=>{let r=qg(t,n);if(r===null)return{kind:`absent`};let i=jg(r,`value`);if(i?.type===`StringLiteral`&&typeof i.value==`string`)return{kind:`literal`,value:i.value};if(i?.type===`JSXExpressionContainer`){let e=Vg(i);if(e!==null)return{kind:`literal`,value:e}}return{kind:`expression`,source:Hg(e,i??r)}},Yg=e=>/["&\\\r\n]/.test(e)?`{${JSON.stringify(e)}}`:`"${e}"`,Xg=(e,t,n,r)=>({start:t,end:n,before:e.slice(t,n),after:r}),Zg=(e,t,n,r)=>{let i=qg(t,n);if(i===null){if(r===void 0)return{ok:!0,edits:[]};let i=t.attributes.at(-1)?.end??jg(t.opening,`name`)?.end??t.opening.end;return{ok:!0,edits:[Xg(e,i,i,` ${n}=${Yg(r)}`)]}}if(Jg(e,t,n).kind===`expression`)return{ok:!1,reason:`\`${n}\` reads the input. Edit it in Source.`};if(r===void 0){let n=i.start;for(;n>t.opening.start&&/\s/.test(e[n-1]);)n--;return{ok:!0,edits:[Xg(e,n,i.end,``)]}}let a=jg(i,`value`);return{ok:!0,edits:a===null?[Xg(e,i.end,i.end,`=${Yg(r)}`)]:[Xg(e,a.start,a.end,Yg(r))]}},Qg=` `,$g=(e,t)=>{let n=e.lastIndexOf(`
25
- `,t-1)+1,r=e.slice(n,t);return/^[ \t]*$/.test(r)?r:null},e_=(e,t)=>{let n=$g(e,t.start),r=/^[ \t]*(\r?\n)/.exec(e.slice(t.end));return n===null||r===null?Xg(e,t.start,t.end,``):Xg(e,t.start-n.length,t.end+r[0].length,``)},t_=(e,t,n,r)=>{let i=$g(e,t.start);return n===`before`?Xg(e,t.start,t.start,i===null?r:`${r}\n${i}`):Xg(e,t.end,t.end,i===null?r:`\n${i}${r}`)},n_=(e,t,n)=>{let r=new Set,i=e=>{if(n?.type===`Identifier`&&typeof n.name==`string`){let t=RegExp(`\\b${n.name}((?:\\??\\.[A-Za-z_$][\\w$]*)+)`,`g`);for(let n of e.matchAll(t))r.add(n[1].replace(/\?/g,``).slice(1))}else if(n?.type===`ObjectPattern`)for(let t of Ag(n.properties)){let n=jg(t,`key`);n?.type===`Identifier`&&typeof n.name==`string`&&RegExp(`\\b${n.name}\\b`).test(e)&&r.add(n.name)}};return Ng(t.node,t=>{t.type===`JSXExpressionContainer`&&Vg(t)===null&&i(e.slice(t.start,t.end))}),[...r].sort()},r_=e=>{let t=Mg(e);if(t===null)return null;let n=Rg(t,`sms`);return n===null||n.root.tag!==zg(t,`@samva/markup/sms`,`Sms`)?null:{...n,tree:t}},i_=e=>{let t=r_(e);return t===null?null:{category:Jg(e,t.root,`category`),segments:Ug(e,t.root),variables:n_(e,t.root,t.parameter)}},a_=(e,t)=>{let n=r_(e);return n===null?{ok:!1,reason:`The SMS body is not editable here.`}:t.kind===`category`?t.value!==void 0&&!im.includes(t.value)?{ok:!1,reason:`\`${t.value}\` is not an SMS category.`}:Zg(e,n.root,`category`,t.value):Kg(e,n.root,Ug(e,n.root),t.segment,t.text)},o_={"quick-reply":`QuickReplyButton`,url:`UrlButton`,phone:`PhoneButton`,"copy-code":`CopyCodeButton`},s_={"quick-reply":`Reply`,url:`Visit site`,phone:`Call us`,"copy-code":`CODE`},c_=(e,t)=>{if(!e.startsWith(`${t}.`))return null;let n=e.slice(t.length+1);return Object.keys(o_).find(e=>o_[e]===n)??null},l_=e=>{let t=Mg(e);if(t===null)return null;let n=Rg(t,`whatsapp`),r=zg(t,`@samva/markup/whatsapp`,`WhatsApp`);if(n===null||n.root.tag!==r)return null;let i=e=>{for(let t of n.root.children){let n=Fg(t);if(n?.tag===`${r}.${e}`)return n}return null};return{...n,local:r,header:i(`Header`),body:i(`Body`),footer:i(`Footer`),buttons:i(`Buttons`)}},u_=(e,t)=>{if(t.buttons===null)return[];let n=[];for(let r of t.buttons.children){if(r.type===`JSXText`&&Bg(String(r.value??``))===``)continue;let i=Fg(r),a=i===null?null:c_(i.tag,t.local);if(i===null||a===null){n.push({row:{kind:`locked`,summary:Hg(e,r)},node:r});continue}let o=Ug(e,i),s=o[0];n.push({node:r,row:o.length===1&&s?.kind===`text`?{kind:`editable`,type:a,text:s.text,url:Jg(e,i,`url`),phone:Jg(e,i,`phone`)}:{kind:`locked`,summary:Hg(e,r)}})}return n},d_=e=>{let t=l_(e);if(t===null||t.body===null)return null;let{root:n}=t;return{name:Jg(e,n,`name`),language:Jg(e,n,`language`),category:Jg(e,n,`category`),header:t.header===null?null:Ug(e,t.header),headerType:t.header===null?{kind:`absent`}:Jg(e,t.header,`type`),body:Ug(e,t.body),footer:t.footer===null?null:Ug(e,t.footer),buttons:u_(e,t).map(({row:e})=>e),variables:n_(e,n,t.parameter)}},f_=(e,t,n,r)=>{let i=`${e}.${o_[t]}`;return`<${i}${t===`url`&&r.url!==void 0?` url=${Yg(r.url)}`:t===`phone`&&r.phone!==void 0?` phone=${Yg(r.phone)}`:``}>${Gg(n,!1,!1)}</${i}>`},p_=(e,t)=>f_(e,t,s_[t],{url:`https://example.com`,phone:`+15555550100`}),m_=(e,t,n,r,i)=>{let a=t[n];if(a===null){if(n===`body`||i===``||r!==0)return{ok:!0,edits:[]};let a=`${t.local}.${n===`header`?`Header`:`Footer`}`,o=`<${a}>${Gg(i,!1,!1)}</${a}>`;return{ok:!0,edits:[t_(e,n===`header`?t.body.node:t.buttons?.node??t.body.node,n===`header`?`before`:`after`,o)]}}let o=Ug(e,a);return n!==`body`&&i===``&&o.length===1?{ok:!0,edits:[e_(e,a.node)]}:Kg(e,a,o,r,i)},h_=(e,t)=>{let n=l_(e);if(n===null||n.body===null)return{ok:!1,reason:`The WhatsApp body is not editable here.`};let{root:r,local:i}=n;switch(t.kind){case`attribute`:{if(t.name===`category`&&!am.includes(t.value??``))return{ok:!1,reason:`Choose a WhatsApp category.`};let n=t.name===`name`&&t.value===``?void 0:t.value??``;return Zg(e,r,t.name,n)}case`headerType`:return n.header===null?{ok:!1,reason:`Add the header text before choosing its type.`}:om.includes(t.value)?Zg(e,n.header,`type`,t.value===`text`?void 0:t.value):{ok:!1,reason:`\`${t.value}\` is not a header type.`};case`text`:return m_(e,n,t.part,t.segment,t.text);case`buttonAdd`:{let r=p_(i,t.type),a=n.buttons;if(a===null){let t=n.footer??n.body,a=`${i}.Buttons`,o=$g(e,t.node.start),s=o===null?`<${a}>${r}</${a}>`:`<${a}>\n${o}${Qg}${r}\n${o}</${a}>`;return{ok:!0,edits:[t_(e,t.node,`after`,s)]}}if(a.selfClosing){let t=`${i}.Buttons`,n=$g(e,a.node.start),o=n===null?`<${t}>${r}</${t}>`:`<${t}>\n${n}${Qg}${r}\n${n}</${t}>`;return{ok:!0,edits:[Xg(e,a.node.start,a.node.end,o)]}}let o=a.children.findLast(e=>e.type!==`JSXText`||Bg(String(e.value??``))!==``);if(o!==void 0)return{ok:!0,edits:[t_(e,o,`after`,r)]};let s=$g(e,a.node.start);return{ok:!0,edits:[Xg(e,a.contentStart,a.contentEnd,s===null?r:`\n${s}${Qg}${r}\n${s}`)]}}}let a=u_(e,n),o=a[t.button];if(o===void 0||n.buttons===null)return{ok:!1,reason:`That button no longer exists.`};if(t.kind===`buttonRemove`)return{ok:!0,edits:[e_(e,a.length===1?n.buttons.node:o.node)]};let s=Fg(o.node);if(o.row.kind===`locked`||s===null)return{ok:!1,reason:`That button is locked. Edit it in Source.`};switch(t.kind){case`buttonText`:return Kg(e,s,Ug(e,s),0,t.text);case`buttonAttribute`:return Zg(e,s,t.name,t.value);default:{let{row:n}=o,r=e=>e.kind===`literal`?e.value:void 0,a=f_(i,t.type,n.text,{url:r(n.url)??`https://example.com`,phone:r(n.phone)??`+15555550100`});return{ok:!0,edits:[Xg(e,o.node.start,o.node.end,a)]}}}},g_=new Set([`[`,`]`,`{`,`}`,`\\`,`~`,`|`,`€`,`^`,`\f`]),__=/^[@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,\-./:;<=>?¡0-9ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà]*$/,v_=e=>{for(let t of e)if(!g_.has(t)&&!__.test(t))return!0;return!1},y_=e=>{if(v_(e)){let t=[...e].length,n=t<=70?1:Math.ceil(t/67);return{encoding:`ucs2`,characterCount:e.length,segmentCount:n}}let t=0;for(let n of e)t+=g_.has(n)?2:1;let n=t<=160?1:Math.ceil(t/153);return{encoding:`gsm7`,characterCount:e.length,segmentCount:n}},b_=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),x_=o(((e,t)=>{t.exports=b_()})),S_={};function C_(e,t){let n=W.useRef(S_);return n.current===S_&&(n.current=e(t)),n}var w_=[],T_=void 0;function E_(){return T_}function D_(e){w_.push(e)}function O_(e){let t=(t,n)=>{let r=C_(A_).current,i;try{T_=r;for(let e of w_)e.before(r);i=e(t,n);for(let e of w_)e.after(r);r.didInitialize=!0}finally{T_=void 0}return i};return t.displayName=e.displayName||e.name,t}function k_(e){return W.forwardRef(O_(e))}function A_(){return{didInitialize:!1}}function j_(){}var M_=Object.freeze([]),N_=Object.freeze({}),X=typeof document<`u`?W.useLayoutEffect:()=>{};function P_(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var F_=P_(`https://base-ui.com/production-error`,`Base UI`),I_=W.createContext(void 0);function L_(e){let t=W.useContext(I_);if(t===void 0&&!e)throw Error(F_(72));return t}function R_(e){W.useEffect(e,M_)}var z_=0,B_=class e{static create(){return new e}currentId=z_;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=z_,t()},e)}isStarted(){return this.currentId!==z_}clear=()=>{this.currentId!==z_&&(clearTimeout(this.currentId),this.currentId=z_)};disposeEffect=()=>this.clear};function V_(){let e=C_(B_.create).current;return R_(e.disposeEffect),e}function H_(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:U_,platform:W_,maxTouchPoints:G_}=H_(),K_=U_.toLowerCase(),q_=W_.toLowerCase(),J_=/^i(os$|p)/.test(q_)||q_===`macintel`&&G_>1,Y_=`android`,X_=q_===Y_||K_.includes(Y_),Z_=!J_&&q_.startsWith(`mac`);q_.startsWith(`win`),!X_&&/^(linux|chrome os)/.test(q_);var Q_=Z_||J_,$_=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!$_&&K_.includes(`firefox`),!$_&&K_.includes(`chrom`);var ev=Q_,tv=/jsdom|happydom/.test(K_);function nv(e){e.preventDefault(),e.stopPropagation()}function rv(e){return`nativeEvent`in e}function iv(e){return e.pointerType===``&&e.isTrusted?!0:X_&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function av(e){return tv?!1:!X_&&e.width===0&&e.height===0||X_&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function ov(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function sv(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function cv(){return typeof window<`u`}function lv(e){return fv(e)?(e.nodeName||``).toLowerCase():`#document`}function uv(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function dv(e){return((fv(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function fv(e){return cv()?e instanceof Node||e instanceof uv(e).Node:!1}function pv(e){return cv()?e instanceof Element||e instanceof uv(e).Element:!1}function mv(e){return cv()?e instanceof HTMLElement||e instanceof uv(e).HTMLElement:!1}function hv(e){return!cv()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof uv(e).ShadowRoot}function gv(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Dv(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function _v(e){return/^(table|td|th)$/.test(lv(e))}function vv(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var yv=/transform|translate|scale|rotate|perspective|filter/,bv=/paint|layout|strict|content/,xv=e=>!!e&&e!==`none`,Sv;function Cv(e){let t=pv(e)?Dv(e):e;return xv(t.transform)||xv(t.translate)||xv(t.scale)||xv(t.rotate)||xv(t.perspective)||!Tv()&&(xv(t.backdropFilter)||xv(t.filter))||yv.test(t.willChange||``)||bv.test(t.contain||``)}function wv(e){let t=kv(e);for(;mv(t)&&!Ev(t);){if(Cv(t))return t;if(vv(t))return null;t=kv(t)}return null}function Tv(){return Sv??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Sv}function Ev(e){return/^(html|body|#document)$/.test(lv(e))}function Dv(e){return uv(e).getComputedStyle(e)}function Ov(e){return pv(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kv(e){if(lv(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||hv(e)&&e.host||dv(e);return hv(t)?t.host:t}function Av(e){let t=kv(e);return Ev(t)?(e.ownerDocument||e).body:mv(t)&&gv(t)?t:Av(t)}function jv(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Av(e),i=r===e.ownerDocument?.body,a=uv(r);if(i){let e=Mv(a);return t.concat(a,a.visualViewport||[],gv(r)?r:[],e&&n?jv(e):[])}return t.concat(r,jv(r,[],n))}function Mv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Nv(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Pv(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&hv(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Fv(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var Iv=`data-base-ui-focusable`,Lv=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,Rv=`ArrowLeft`,zv=`ArrowRight`,Bv=`ArrowUp`,Vv=`ArrowDown`,Hv=`data-starting-style`,Uv=`data-ending-style`,Wv={[Hv]:``},Gv={[Uv]:``},Kv={transitionStatus(e){return e===`starting`?Wv:e===`ending`?Gv:null}},qv=`data-open`,Jv=`data-closed`,Yv=`data-anchor-hidden`,Xv=`data-popup-open`,Zv=`data-pressed`,Qv={[Xv]:``},$v={[Xv]:``,[Zv]:``},ey={[qv]:``},ty={[Jv]:``},ny={[Yv]:``},ry={open(e){return e?Qv:null}},iy={open(e){return e?$v:null}},ay={open(e){return e?ey:ty},anchorHidden(e){return e?ny:null}},oy={...ay,...Kv},sy=`data-trigger-disabled`;function cy(e,t){if(!pv(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(sy);for(let[,e]of t.entries())if(Pv(e,n))return!e.hasAttribute(sy);return!1}function ly(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function uy(e){return e.matches(`html,body`)}function dy(e){return mv(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function fy(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Lv}`)!=null}function py(e){return e?e.getAttribute(`role`)===`combobox`&&dy(e):!1}function my(e){if(!e||tv)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function hy(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function gy(e,t){return t!=null&&!ov(t)?0:typeof e==`function`?e():e}function _y(e,t,n){let r=gy(e,n);return typeof r==`number`?r:r?.[t]}function vy(e){return typeof e==`function`?e():e}function yy(e,t){return t||e===`click`||e===`mousedown`}function by(e){return e?.includes(`mouse`)&&e!==`mousedown`}var xy=`none`,Sy=`trigger-press`,Cy=`trigger-hover`,wy=`trigger-focus`,Ty=`outside-press`,Ey=`item-press`,Dy=`close-press`,Oy=`focus-out`,ky=`escape-key`,Ay=`close-watcher`,jy=`list-navigation`,My=`cancel-open`,Ny=`sibling-open`,Py=`disabled`,Fy=`imperative-action`,Iy=`swipe`,Ly=`window-resize`;function Ry(e,t,n,r){let i=!1,a=!1,o=r??N_;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var Z=x_(),zy=W.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new B_,currentIdRef:{current:null},currentContextRef:{current:null}});function By(e,t){e.current=t.current}function Vy(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:l,hasProvider:u,timeout:d}=W.useContext(zy),[f,p]=W.useState(!1),m=W.useRef(n);return X(()=>{m.current=n},[n]),X(()=>{function e(){l.current?.setIsInstantPhase(!1),a.current=null,l.current=null,o.current=c.current,d.clear()}if(a.current&&!n&&a.current===i){if(p(!1),s){let t=i;return d.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(m.current||a.current!==t)&&d.clear()}}e()}},[n,i,a,o,s,c,l,d,r]),X(()=>{if(!n)return;let e=l.current,t=a.current;d.clear(),l.current={onOpenChange:r.setOpen,setIsInstantPhase:p},a.current=i,o.current={open:0,close:_y(c.current,`close`)},t!==null&&t!==i?(p(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,Ry(xy))):(p(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,l,d]),X(()=>()=>{if(a.current===i){if(l.current=null,!m.current)return;a.current=null,By(o,c),d.clear()}},[l,a,o,i,c,d]),W.useMemo(()=>({activeIdRef:a,hasProvider:u,delayRef:o,isInstantPhase:f}),[a,u,o,f])}function Hy(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Uy(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Wy(e,t,n,r){let i=C_(Ky).current;return qy(i,e,t,n,r)&&Yy(i,[e,t,n,r]),i.callback}function Gy(e){let t=C_(Ky).current;return Jy(t,e)&&Yy(t,e),t.callback}function Ky(){return{callback:null,cleanup:null,refs:[]}}function qy(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Jy(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Yy(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function Xy(e){let t=C_(Zy,e).current;return t.next=e,X(t.effect),t}function Zy(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Qy={...W},$y=Qy.useInsertionEffect,eb=$y&&$y!==Qy.useLayoutEffect?$y:e=>e();function Q(e){let t=C_(tb).current;return t.next=e,eb(t.effect),t.trampoline}function tb(){let e={next:void 0,callback:nb,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function nb(){}var rb=null;globalThis.requestAnimationFrame;var ib=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},ab=class e{static create(){return new e}static request(e){return ib.request(e)}static cancel(e){return ib.cancel(e)}currentId=rb;request(e){this.cancel(),this.currentId=ib.request(()=>{this.currentId=rb,e()})}cancel=()=>{this.currentId!==rb&&(ib.cancel(this.currentId),this.currentId=rb)};disposeEffect=()=>this.cancel};function ob(){let e=C_(ab.create).current;return R_(e.disposeEffect),e}function sb(e){return e?.ownerDocument||document}var cb={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},lb={...cb,position:`fixed`,top:0,left:0},ub={...cb,position:`absolute`},db=W.forwardRef(function(e,t){let[n,r]=W.useState();X(()=>{ev&&$_&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,Z.jsx)(`span`,{...e,ref:t,style:lb,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),fb=Math.min,pb=Math.max,mb=Math.round,hb=Math.floor,gb=e=>({x:e,y:e}),_b={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function vb(e,t,n){return pb(e,fb(t,n))}function yb(e,t){return typeof e==`function`?e(t):e}function bb(e){return e.split(`-`)[0]}function xb(e){return e.split(`-`)[1]}function Sb(e){return e===`x`?`y`:`x`}function Cb(e){return e===`y`?`height`:`width`}function wb(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Tb(e){return Sb(wb(e))}function Eb(e,t,n){n===void 0&&(n=!1);let r=xb(e),i=Tb(e),a=Cb(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Fb(o)),[o,Fb(o)]}function Db(e){let t=Fb(e);return[Ob(e),t,Ob(t)]}function Ob(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var kb=[`left`,`right`],Ab=[`right`,`left`],jb=[`top`,`bottom`],Mb=[`bottom`,`top`];function Nb(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Ab:kb:t?kb:Ab;case`left`:case`right`:return t?jb:Mb;default:return[]}}function Pb(e,t,n,r){let i=xb(e),a=Nb(bb(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Ob)))),a}function Fb(e){let t=bb(e);return _b[t]+e.slice(t.length)}function Ib(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Lb(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ib(e)}function Rb(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function zb(e,t){return t<0||t>=e.length}function Bb(e,t){return Hb(e.current,{disabledIndices:t})}function Vb(e,t){return Hb(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Hb(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Ub(e,a,r));return a}function Ub(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!Gb(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function Wb(e){return e.visibility===`hidden`||e.visibility===`collapse`}function Gb(e,t=e?Dv(e):null){return!e||!e.isConnected||!t||Wb(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var Kb=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function qb(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return hv(n)?n.host:null}function Jb(e){for(let t of Array.from(e.children))if(lv(t)===`summary`)return t;return null}function Yb(e,t){let n=Jb(t);return!!n&&(e===n||Pv(n,e))}function Xb(e){let t=e?lv(e):``;return e!=null&&e.matches(Kb)&&(t!==`summary`||e.parentElement!=null&&lv(e.parentElement)===`details`&&Jb(e.parentElement)===e)&&(t!==`details`||Jb(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Zb(e){if(!Xb(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=qb(t)){let n=t!==e,r=lv(t)===`slot`;if(t.hasAttribute(`inert`)||n&&lv(t)===`details`&&!t.open&&!Yb(e,t)||t.hasAttribute(`hidden`)||!r&&!Qb(t,n))return!1}return!0}function Qb(e,t){let n=Dv(e);return t?n.display!==`none`:Gb(e,n)}function $b(e){let t=e.tabIndex;if(t<0){let t=lv(e);if(t===`details`||t===`audio`||t===`video`||mv(e)&&e.isContentEditable)return 0}return t}function ex(e){if(lv(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function tx(e,t){let n=ex(e);if(!n)return!0;let r=t.find(e=>{let t=ex(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=ex(e);return t?.name===n.name&&t.form===n.form})===n}function nx(e){if(mv(e)&&lv(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return mv(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function rx(e,t){nx(e).forEach(e=>{Xb(e)&&t.push(e),rx(e,t)})}function ix(e,t,n){nx(e).forEach(e=>{mv(e)&&e.matches(t)&&n.push(e),ix(e,t,n)})}function ax(e){return Zb(e)&&$b(e)>=0}function ox(e){let t=[];return rx(e,t),t.filter(Zb)}function sx(e){let t=ox(e);return t.filter(e=>$b(e)>=0&&tx(e,t))}function cx(e,t){let n=sx(e),r=n.length;if(r===0)return;let i=Nv(sb(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function lx(e){return cx(sb(e).body,1)||e}function ux(e){return cx(sb(e).body,-1)||e}function dx(e,t){if(!e)return null;let n=sx(sb(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function fx(e){return dx(e,1)}function px(e){return dx(e,-1)}function mx(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Pv(n,r)}function hx(e){sx(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function gx(e){let t=[];ix(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function _x(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],..._x(e,t.id,n)])}function vx(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function yx(e){return`data-base-ui-${e}`}var bx=0;function xx(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(bx);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),j_;let o=requestAnimationFrame(a);return bx=o,()=>{bx===o&&(cancelAnimationFrame(o),bx=0)}}var Sx={inert:new WeakMap,"aria-hidden":new WeakMap},Cx=`data-base-ui-inert`,wx={inert:new WeakSet,"aria-hidden":new WeakSet},Tx=new WeakMap,Ex=0;function Dx(e){return wx[e]}function Ox(e){return e?hv(e)?e.host:Ox(e.parentNode):null}var kx=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Ox(t);return e.contains(n)?n:null}).filter(e=>e!=null),Ax=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},jx=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{lv(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Mx(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=kx(t,e),l=i?jx(t,Ax(c),new Set(c)):[],u=[],d=[];if(a){let e=Sx[a],n=Dx(a);s=n,o=e;let r=kx(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);jx(t,Ax(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(Tx.get(e)||0)+1;Tx.set(e,t),d.push(e),t===1&&e.setAttribute(Cx,``)}),Ex+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(Tx.get(e)||0)-1;Tx.set(e,t),t||e.removeAttribute(Cx)}),--Ex,Ex||(Sx.inert=new WeakMap,Sx[`aria-hidden`]=new WeakMap,wx.inert=new WeakSet,wx[`aria-hidden`]=new WeakSet,Tx=new WeakMap)}}function Nx(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=sb(e[0]).body;return Mx(e,a,n,r,{mark:i})}var Px=0;function Fx(e,t=`mui`){let[n,r]=W.useState(e),i=e||n;return W.useEffect(()=>{n??(Px+=1,r(`${t}-${Px}`))},[n,t]),i}var Ix=Qy.useId;function Lx(e,t){if(Ix!==void 0){let n=Ix();return e??(t?`${t}-${n}`:n)}return Fx(e,t)}var Rx=19;function zx(e){return Rx>=e}function Bx(e){if(!W.isValidElement(e))return null;let t=e,n=t.props;return(zx(19)?n?.ref:t.ref)??null}function Vx(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function Hx(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Ux(e,t){return typeof e==`function`?e(t):e}function Wx(e,t){return typeof e==`function`?e(t):e}var Gx={};function Kx(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Jx(t);let a=Jx(e);return t&&(a=Yx(a,t)),n&&(a=Yx(a,n)),r&&(a=Yx(a,r)),i&&(a=Yx(a,i)),a}function qx(e){if(e.length===0)return Gx;if(e.length===1)return Jx(e[0]);let t=Jx(e[0]);for(let n=1;n<e.length;n+=1)t=Yx(t,e[n]);return t}function Jx(e){return $x(e)?{...eS(e,Gx)}:Xx(e)}function Yx(e,t){return $x(t)?eS(t,e):Zx(e,t)}function Xx(e){let t={...e};for(let e in t){let n=t[e];Qx(e,n)&&(t[e]=nS(n))}return t}function Zx(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Vx(e.style,r);break;case`className`:e[n]=iS(e.className,r);break;default:e[n]=Qx(n,r)?tS(e[n],r):r}}return e}function Qx(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function $x(e){return typeof e==`function`}function eS(e,t){return $x(e)?e(t):e??Gx}function tS(e,t){return t?e?(...n)=>{let r=n[0];if(aS(r)){let i=r;rS(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:nS(t):e}function nS(e){return e&&((...t)=>{let n=t[0];return aS(n)&&rS(n),e(...t)})}function rS(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function iS(e,t){return t?e?t+` `+e:t:e}function aS(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function oS(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=uS(r));let i=sS(t,n,r);if(n.enabled===!1)return null;let a=n.state??N_;return dS(e,r,i,a)}function sS(e,t,n){let{className:r,style:i}=e,{state:a=N_,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Ux(r,a):void 0,d=l?Wx(i,a):void 0,f=l?Hx(a,c):N_,p=l&&s?cS(s):void 0,m=l?Vx(f,p)??{}:N_;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?Gy([m.ref,Bx(n),...o]):Wy(m.ref,Bx(n),o):Wy(null,null)),l?(u!==void 0&&(m.className=iS(m.className,u)),d!==void 0&&(m.style=Vx(m.style,d)),m):N_}function cS(e){return Array.isArray(e)?qx(e):Kx(void 0,e)}var lS=Symbol.for(`react.lazy`);function uS(e){if(e?.$$typeof!==lS)return e;let t=W.Children.toArray(e)[0];return W.isValidElement(t)?t:e}function dS(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Kx(n,t.props);return e.ref=n.ref,W.cloneElement(t,e)}if(e&&typeof e==`string`)return fS(e,n);throw Error(F_(8))}function fS(e,t){return e===`button`?(0,W.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,W.createElement)(`img`,{alt:``,...t,key:t.key}):W.createElement(e,t)}var pS={style:{transition:`none`}},mS=`data-base-ui-click-trigger`,hS=`data-base-ui-swipe-ignore`,gS=`data-swipe-ignore`,_S=`[${hS}]`;`${gS}`;var vS={fallbackAxisSide:`none`},yS={fallbackAxisSide:`end`},bS={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},xS=c(m(),1),SS=W.createContext(null),CS=()=>W.useContext(SS),wS=yx(`portal`);function TS(e={}){let{ref:t,container:n,componentProps:r=N_,elementProps:i}=e,a=Lx(),o=CS()?.portalNode,[s,c]=W.useState(null),[l,u]=W.useState(null),d=Q(e=>{e!==null&&u(e)}),f=W.useRef(null);X(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(fv(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=oS(`div`,r,{ref:[t,d],props:[{id:a,[wS]:``},i]}),m=s&&p?xS.createPortal(p,s):null;return{node:l,nodeId:W.isValidElement(p)?p.props.id:void 0,subtree:m}}var ES=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=TS({container:o,ref:t,componentProps:e,elementProps:c}),f=W.useRef(null),p=W.useRef(null),m=W.useRef(null),h=W.useRef(null),[g,_]=W.useState(null),v=W.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;W.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&mx(e)&&(e.type===`focusin`?v.current&&=(gx(l),!1):(hx(l),v.current=!0))}return Uy(Hy(l,`focusin`,e,!0),Hy(l,`focusout`,e,!0))},[l,y]),X(()=>{l&&b===!0&&v.current&&(gx(l),v.current=!1)},[b,l]);let S=W.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,Z.jsxs)(W.Fragment,{children:[d,(0,Z.jsxs)(SS.Provider,{value:S,children:[x&&l&&(0,Z.jsx)(db,{"data-type":`outside`,ref:f,onFocus:e=>{mx(e,l)?m.current?.focus():ux(g?g.domReference:null)?.focus()}}),x&&l&&(0,Z.jsx)(`span`,{role:s,"aria-owns":u,style:bS}),l&&xS.createPortal(a,l),x&&l&&(0,Z.jsx)(db,{"data-type":`outside`,ref:p,onFocus:e=>{mx(e,l)?h.current?.focus():(lx(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,Ry(`focus-out`,e.nativeEvent)))}})]})]})});function DS(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var OS=class{nodesRef={current:[]};events=DS();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},kS=W.createContext(null),AS=W.createContext(null),jS=()=>W.useContext(kS)?.id||null,MS=e=>{let t=W.useContext(AS);return e??t};function NS(e){let t=Lx(),n=MS(e),r=jS();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function PS(e){let{children:t,id:n}=e,r=jS();return(0,Z.jsx)(kS.Provider,{value:W.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function FS(e){let{children:t,externalTree:n}=e,r=C_(()=>n??new OS).current;return(0,Z.jsx)(AS.Provider,{value:r,children:t})}function IS(e){return e==null?e:`current`in e?e.current:e}function LS(e,t){let n=uv(Fv(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var RS=20,zS=[];function BS(){zS=zS.filter(e=>e.deref()?.isConnected)}function VS(e){BS(),e&&lv(e)!==`body`&&(zS.push(new WeakRef(e)),zS.length>RS&&(zS=zS.slice(-20)))}function HS(){return BS(),zS[zS.length-1]?.deref()}function US(e){return e?ax(e)?e:sx(e)[0]||e:null}function WS(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=ox(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return ax(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function GS(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=Q(()=>b.current.floatingContext?.nodeId),S=i===!1,C=py(_)&&S,w=Xy(i),T=Xy(a),E=Xy(l),D=Xy(g),O=MS(p),k=CS(),A=W.useRef(!1),j=W.useRef(!1),M=W.useRef(!1),N=W.useRef(null),P=W.useRef(``),F=W.useRef(``),I=W.useRef(null),L=W.useRef(null),R=Wy(I,f,k?.beforeInsideRef),ee=Wy(L,k?.afterInsideRef),z=V_(),te=V_(),ne=ob(),re=k!=null,B=hy(v),ie=Q((e=B)=>e?sx(e):[]),ae=Q(()=>m?.().filter(e=>e!=null)??[]);W.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&Pv(B,Nv(sb(B)))&&ie().length===0&&!C&&nv(e)}return Hy(sb(B),`keydown`,e)},[r,B,s,C,ie]),W.useEffect(()=>{if(r||!g)return;let e=sb(B);function t(){M.current=!1}function n(e){let t=Fv(e),n=ae(),r=Pv(v,t)||Pv(_,t)||Pv(k?.portalNode,t)||n.some(e=>e===t||Pv(e,t));M.current=!r,F.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(j.current=!0,te.start(0,()=>{j.current=!1}))}function i(){F.current=`keyboard`}return Uy(Hy(e,`pointerdown`,n,!0),Hy(e,`pointerup`,t,!0),Hy(e,`pointercancel`,t,!0),Hy(e,`keydown`,i,!0),t)},[r,v,_,B,g,k,te,ae]),W.useEffect(()=>{if(r||!c)return;let e=sb(B);function t(){j.current=!0,te.start(0,()=>{j.current=!1})}function n(e){let t=Fv(e);ax(t)&&(N.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=Fv(t);s&&n==null&&i!=null&&Pv(v,i)&&VS(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=ae(),f=n?.hasAttribute(yx(`focus-guard`))&&[I.current,L.current,k?.beforeInsideRef.current,k?.afterInsideRef.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,IS(d),IS(u)].includes(n),p=!(Pv(_,n)||Pv(v,n)||Pv(n,v)||Pv(k?.portalNode,n)||l.some(e=>e===n||Pv(e,n))||c.hasMatchingElement(e=>Pv(e,n))||f||O&&(_x(O.nodesRef.current,a).find(e=>Pv(e.context?.elements.floating,n)||Pv(e.context?.elements.domReference,n))||vx(O.nodesRef.current,a).find(e=>[e.context?.elements.floating,hy(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&B&&WS(B),o&&r!==_&&!Gb(i)&&Nv(e)===e.body){if(mv(B)&&(B.focus(),o===`popup`)){ne.request(()=>{B.focus()});return}let e=ie(),t=N.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||B;mv(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!s)&&n&&p&&!j.current&&(C||n!==HS())&&(A.current=!0,h.setOpen(!1,Ry(Oy,t)))})}function a(){M.current||(b.current.insideReactTree=!0,z.start(0,()=>{b.current.insideReactTree=!1}))}let l=mv(_)?_:null;if(v||l)return Uy(l&&Hy(l,`focusout`,i),l&&Hy(l,`pointerdown`,t),v&&Hy(v,`focusin`,n),v&&Hy(v,`focusout`,i),v&&k&&Hy(v,`focusout`,a,!0))},[r,_,v,B,s,O,k,h,c,o,ie,C,x,b,z,te,ne,u,d,ae]),W.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(k?.portalNode?.querySelectorAll(`[${yx(`portal`)}]`)||[]),t=(O?vx(O.nodesRef.current,x()):[]).find(e=>py(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Nx([v,...e,I.current,L.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,...ae(),t,IS(d),IS(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=Nx([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,k,C,O,x,u,d,ae]),X(()=>{if(!g||r||!mv(B))return;P.current=``,F.current=``;let e=sb(B),t=Nv(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||Pv(B,t))return;let i=null,a=()=>(i??=ie(B),i[0]||B),o;o=r===!0||r===null?a():IS(r),o||=a();let s=Pv(B,Nv(e));xx(o,{preventScroll:o===B,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=Nv(e);return!(t!==o&&Pv(B,t))}})})},[r,g,B,ie,w,E,D]),X(()=>{if(r||!B)return;let e=sb(B),t=Nv(e),n=E.current==null;VS(t);function i(e){if(e.open||(P.current=LS(e.nativeEvent,F.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(A.current=!0),e.reason===`outside-press`){if(e.nested)A.current=!1;else if(iv(e.nativeEvent)||av(e.nativeEvent))A.current=!1;else{let e=!1;sb(B).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?A.current=!1:A.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&lv(t)!==`body`?t:null,s=n?o||a:a||o;return s||=HS()||null,typeof i==`boolean`?s:IS(i)||s||null}return()=>{y.off(`openchange`,i);let t=Nv(e),n=ae(),r=Pv(v,t)||n.some(e=>e===t||Pv(e,t))||O&&_x(O.nodesRef.current,x(),!1).some(e=>Pv(e.context?.elements.floating,t)),o=T.current,s=P.current,c=a(s);queueMicrotask(()=>{let n=US(c),i=typeof o!=`boolean`;if(o&&!A.current&&mv(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}A.current=!1})}},[r,v,B,T,E,y,O,_,x,ae]),X(()=>{if(!$_||g||!v)return;let e=Nv(sb(v));mv(e)&&dy(e)&&Pv(v,e)&&e.blur()},[g,v]),X(()=>{if(!r&&k)return k.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{k.setFocusManagerState(null)}},[r,k,s,g,h,c,_]),X(()=>{if(!r&&B)return WS(B),()=>{queueMicrotask(BS)}},[r,B]);let oe=!r&&(!s||!C)&&(re||s);return(0,Z.jsxs)(W.Fragment,{children:[oe&&(0,Z.jsx)(db,{"data-type":`inside`,ref:R,onFocus:e=>{if(s){let e=ie();xx(e[e.length-1])}else k?.portalNode&&(A.current=!1,mx(e,k.portalNode)?lx(_)?.focus():IS(d??k.beforeOutsideRef)?.focus())}}),n,oe&&(0,Z.jsx)(db,{"data-type":`inside`,ref:ee,onFocus:e=>{s?xx(ie()[0]):k?.portalNode&&(c&&(A.current=!0),mx(e,k.portalNode)?ux(_)?.focus():IS(u??k.afterOutsideRef)?.focus())}})]})}function KS(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Sy}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=W.useRef(void 0),f=ob(),p=V_(),m=W.useMemo(()=>{function e(e,t,n,r){let i=Ry(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=ov(e.pointerType,!0)&&av(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||ov(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=Fv(o);if(dy(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}ov(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return W.useMemo(()=>n?{reference:m}:N_,[n,m])}function qS(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function JS(e){return e!=null&&e.clientX!=null}function YS(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,l=W.useRef(!1),u=W.useRef(null),[d,f]=W.useState(),[p,m]=W.useState([]),h=Q(e=>{i.set(`positionReference`,e)}),g=Q((e,t,n)=>{l.current||(!c.current.openEvent||JS(c.current.openEvent))&&i.set(`positionReference`,qS(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:d}))}),_=Q(e=>{a?u.current||(g(e.clientX,e.clientY,e.currentTarget),m([])):g(e.clientX,e.clientY,e.currentTarget)}),v=ov(d)?o:a;W.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=uv(o);function r(t){let n=Fv(t);Pv(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||JS(c.current.openEvent)?u.current=Hy(t,`mousemove`,r):h(s),e},[v,n,o,c,s,i,g,h,p]),W.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),W.useEffect(()=>{n&&!o&&(l.current=!1)},[n,o]),W.useEffect(()=>{!n&&a&&(l.current=!0)},[n,a]);let y=W.useMemo(()=>{function e(e){f(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return W.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function XS(){return!1}function ZS(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function QS(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=XS,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f,events:p}=l.context,m=MS(c),h=Q(typeof i==`function`?i:()=>!1),g=typeof i==`function`?h:i,_=g!==!1,v=Q(()=>a),{escapeKey:y,outsidePress:b}=ZS(s),x=W.useRef(!1),S=W.useRef(!1),C=W.useRef(!1),w=W.useRef(!1),T=W.useRef(!1),E=W.useRef(``),D=W.useRef(null),O=V_(),k=V_(),A=Q(()=>{k.clear(),f.current.insideReactTree=!1}),j=Q(e=>{let t=f.current.floatingContext?.nodeId;return(m?_x(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=Q(e=>ly(e,l.select(`floatingElement`))||ly(e,l.select(`domReferenceElement`))),N=Q(e=>{o()&&l.setOpen(!1,Ry(Sy,e.nativeEvent))}),P=Q(e=>{if(!u||!n||!r||e.key!==`Escape`||T.current||!y&&j(`__escapeKeyBubbles`))return;let t=Ry(ky,rv(e)?e.nativeEvent:e);l.setOpen(!1,t),t.isCanceled||e.preventDefault(),!y&&!t.isPropagationAllowed&&e.stopPropagation()}),F=Q(()=>{f.current.insideReactTree=!0,k.start(0,A)}),I=Q(e=>{if(!u||!n||e.button!==0)return;let t=Fv(e.nativeEvent);Pv(l.select(`floatingElement`),t)&&(x.current||(x.current=!0,S.current=!1))}),L=Q(e=>{u&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&x.current&&(S.current=!0)});W.useEffect(()=>{function e(e){e.open||(w.current=!1)}return p.on(`openchange`,e),()=>{p.off(`openchange`,e)}},[p]),W.useEffect(()=>{if(!u||!n)return u||(w.current=!1),A;f.current.__escapeKeyBubbles=y,f.current.__outsidePressBubbles=b;let e=new B_,t=new B_,i=sb(d);function a(){e.clear(),T.current=!0}function o(){e.start($_?5:0,()=>{T.current=!1})}function s(){C.current=!0,t.start(0,()=>{C.current=!1})}function c(){x.current=!1,S.current=!1}function p(){let e=E.current,t=e===`pen`||!e?`mouse`:e,n=v(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function h(e){let t=p();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function k(e){let t=f.current.floatingContext?.nodeId,n=m&&_x(m.nodesRef.current,t).some(t=>ly(e,t.context?.elements.floating));return M(e)||n}function N(e){if(h(e)){e.type!==`click`&&!M(e)&&(t.clear(),C.current=!1),A();return}if(f.current.insideReactTree){A();return}let n=Fv(e),r=`[${yx(`inert`)}]`,i=pv(n)?n.getRootNode():null,a=Array.from((hv(i)?i:sb(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>Pv(e,n))))return;let s=pv(n)?n:null;for(;s&&!Ev(s);){let e=kv(s);if(Ev(e)||!pv(e))break;s=e}if(!(a.length&&pv(n)&&!uy(n)&&!Pv(n,l.select(`floatingElement`))&&a.every(e=>!Pv(s,e)))){if(mv(n)&&!(`touches`in e)){let t=Ev(n),r=Dv(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!k(e)){if(p()===`intentional`){if(e.detail!==0&&!iv(e)&&!w.current)return;if(C.current){t.clear(),C.current=!1;return}}(typeof g!=`function`||g(e))&&(j(`__outsidePressBubbles`)||(l.setOpen(!1,Ry(Ty,e)),A()))}}}function F(e){p()===`sloppy`&&e.pointerType!==`touch`&&l.select(`open`)&&n&&!M(e)&&N(e)}function I(e){if(p()!==`sloppy`||!l.select(`open`)||!n||M(e))return;let t=e.touches[0];t&&(D.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=Fv(e);if(!n)return;let r=Hy(n,e.type,()=>{t(e),r()})}function R(e){E.current=`touch`,L(e,I)}function ee(e){O.clear(),e.type===`pointerdown`&&(e.button===0&&(w.current=!0),E.current=e.pointerType),(e.type!==`mousedown`||!D.current||D.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function z(e){if(e.type===`pointercancel`&&(w.current=!1),!x.current)return;let n=S.current;if(c(),p()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!k(e)){if(n){s();return}(typeof g!=`function`||g(e))&&(t.clear(),C.current=!0,A())}}}function te(e){if(p()!==`sloppy`||!D.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-D.current.startX),r=Math.abs(t.clientY-D.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(D.current.dismissOnTouchEnd=!0),i>10&&(N(e),O.clear(),D.current=null)}function ne(e){L(e,te)}function re(e){p()===`sloppy`&&D.current&&!M(e)&&(D.current.dismissOnTouchEnd&&N(e),O.clear(),D.current=null)}function B(e){L(e,re)}let ie=Uy(r&&Uy(Hy(i,`keydown`,P),Hy(i,`compositionstart`,a),Hy(i,`compositionend`,o)),_&&Uy(Hy(i,`click`,ee,!0),Hy(i,`pointerdown`,ee,!0),Hy(i,`pointerup`,z,!0),Hy(i,`pointercancel`,z,!0),Hy(i,`mousedown`,ee,!0),Hy(i,`mouseup`,z,!0),Hy(i,`touchstart`,R,{capture:!0,passive:!0}),Hy(i,`touchmove`,ne,{capture:!0,passive:!0}),Hy(i,`touchend`,B,{capture:!0,passive:!0})));return()=>{ie(),e.clear(),t.clear(),c(),C.current=!1,A()}},[f,d,r,_,g,u,n,y,b,P,A,v,j,M,m,l,O]);let R=W.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),ee=W.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return W.useMemo(()=>n?{reference:R,floating:ee,trigger:R}:{},[n,R,ee])}function $S(e,t,n){let{reference:r,floating:i}=e,a=wb(t),o=Tb(t),s=Cb(o),c=bb(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=xb(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function eC(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=yb(t,e),p=Lb(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Rb(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Rb(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var tC=50,nC=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:eC},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=$S(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<tC&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=$S(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},rC=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=yb(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=bb(r),_=wb(o),v=bb(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Fb(o)]:Db(o)),x=p!==`none`;!d&&x&&b.push(...Pb(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Eb(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===wb(t)||T.every(e=>wb(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=wb(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},iC=new Set([`left`,`top`]);async function aC(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=bb(n),s=xb(n),c=wb(n)===`y`,l=iC.has(o)?-1:1,u=a&&c?-1:1,d=yb(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var oC=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await aC(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},sC=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=yb(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=wb(i),p=Sb(f),m=u[p],h=u[f],g=(e,t)=>vb(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},cC=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=yb(e,t),u={x:n,y:r},d=wb(i),f=Sb(d),p=u[f],m=u[d],h=yb(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=iC.has(bb(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},lC=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=yb(e,t),c=await i.detectOverflow(t,s),l=bb(n),u=xb(n),d=wb(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=fb(p-c[m],g),y=fb(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*pb(c.left,c.right):S=p-2*pb(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function uC(e){let t=Dv(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=mv(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=mb(n)!==a||mb(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function dC(e){return pv(e)?e:e.contextElement}function fC(e){let t=dC(e);if(!mv(t))return gb(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=uC(t),o=(a?mb(n.width):n.width)/r,s=(a?mb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var pC=gb(0);function mC(e){let t=uv(e);return!Tv()||!t.visualViewport?pC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hC(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===uv(e)}function gC(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=dC(e),o=gb(1);t&&(r?pv(r)&&(o=fC(r)):o=fC(e));let s=hC(a,n,r)?mC(a):gb(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=uv(a),t=pv(r)?uv(r):r,n=e,i=Mv(n);for(;i&&t!==n;){let e=fC(i),t=i.getBoundingClientRect(),r=Dv(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=uv(i),i=Mv(n)}}return Rb({width:u,height:d,x:c,y:l})}function _C(e,t){let n=Ov(e).scrollLeft;return t?t.left+n:gC(dv(e)).left+n}function vC(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-_C(e,n),y:n.top+t.scrollTop}}function yC(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=dv(r),s=t?vv(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=gb(1),u=gb(0),d=mv(r);if((d||!a)&&((lv(r)!==`body`||gv(o))&&(c=Ov(r)),d)){let e=gC(r);l=fC(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?vC(o,c):gb(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function bC(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function xC(e){let t=Ov(e),n=e.ownerDocument.body,r=pb(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=pb(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+_C(e),o=-t.scrollTop;return Dv(n).direction===`rtl`&&(a+=pb(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var SC=25;function CC(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=uv(e),a=dv(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Tv()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(_C(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=SC&&(s-=o)}return{width:s,height:c,x:l,y:u}}function wC(e,t){let n=gC(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=fC(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function TC(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=CC(e,n,t);else if(t===`document`)r=xC(dv(e));else if(pv(t))r=wC(t,n);else{let n=mC(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Rb(r)}function EC(e,t){let n=t.get(e);if(n)return n;let r=jv(e,[],!1).filter(e=>pv(e)&&lv(e)!==`body`),i=null,a=Dv(e).position===`fixed`,o=a?kv(e):e;for(;pv(o)&&!Ev(o);){let e=Dv(o),t=Cv(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=kv(o)}return t.set(e,r),r}function DC(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?vv(t)?[]:EC(t,this._c):[].concat(n),r],o=TC(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=TC(t,a[e],i);s=pb(n.top,s),c=fb(n.right,c),l=fb(n.bottom,l),u=pb(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function OC(e){let{width:t,height:n}=uC(e);return{width:t,height:n}}function kC(e,t,n){let r=mv(t),i=dv(t),a=n===`fixed`,o=gC(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=gb(0);if((r||!a)&&((lv(t)!==`body`||gv(i))&&(s=Ov(t)),r)){let e=gC(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=_C(i));let l=i&&!r&&!a?vC(i,s):gb(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function AC(e){return Dv(e).position===`static`}function jC(e,t){if(!mv(e)||Dv(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return dv(e)===n&&(n=n.ownerDocument.body),n}function MC(e,t){let n=uv(e);if(vv(e))return n;if(!mv(e)){let t=kv(e);for(;t&&!Ev(t);){if(pv(t)&&!AC(t))return t;t=kv(t)}return n}let r=jC(e,t);for(;r&&_v(r)&&AC(r);)r=jC(r,t);return r&&Ev(r)&&AC(r)&&!Cv(r)?n:r||wv(e)||n}var NC=async function(e){let t=this.getOffsetParent||MC,n=this.getDimensions,r=await n(e.floating);return{reference:kC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function PC(e){return Dv(e).direction===`rtl`}var FC={convertOffsetParentRelativeRectToViewportRelativeRect:yC,getDocumentElement:dv,getClippingRect:DC,getOffsetParent:MC,getElementRects:NC,getClientRects:bC,getDimensions:OC,getScale:fC,isElement:pv,isRTL:PC};function IC(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function LC(e,t,n){let r=null,i,a=dv(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=hb(d),h=hb(a.clientWidth-(u+f)),g=hb(a.clientHeight-(d+p)),_=hb(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:pb(0,fb(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!IC(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=uv(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function RC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=dC(e),u=i||a?[...l?jv(l):[],...t?jv(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?LC(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?gC(e):null;c&&g();function g(){let t=gC(e);h&&!IC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var zC=oC,BC=sC,VC=rC,HC=lC,UC=cC,WC=(e,t,n)=>{let r=new Map,i=n??{},a={...FC,...i.platform,_c:r};return nC(e,t,{...i,platform:a})},GC=typeof document<`u`?W.useLayoutEffect:function(){};function KC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!KC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!KC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function qC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function JC(e,t){let n=qC(e);return Math.round(t*n)/n}function YC(e){let t=W.useRef(e);return GC(()=>{t.current=e}),t}function XC(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=W.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=W.useState(r);KC(f,r)||p(r);let[m,h]=W.useState(null),[g,_]=W.useState(null),v=W.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=W.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=W.useRef(null),C=W.useRef(null),w=W.useRef(u),T=c!=null,E=YC(c),D=YC(i),O=YC(l),k=W.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),WC(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!KC(w.current,t)&&(w.current=t,xS.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);GC(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=W.useRef(!1);GC(()=>(A.current=!0,()=>{A.current=!1}),[]),GC(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=W.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=W.useMemo(()=>({reference:b,floating:x}),[b,x]),N=W.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=JC(M.floating,u.x),r=JC(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...qC(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return W.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var ZC=(e,t)=>{let n=zC(e);return{name:n.name,fn:n.fn,options:[e,t]}},QC=(e,t)=>{let n=BC(e);return{name:n.name,fn:n.fn,options:[e,t]}},$C=(e,t)=>({fn:UC(e).fn,options:[e,t]}),ew=(e,t)=>{let n=VC(e);return{name:n.name,fn:n.fn,options:[e,t]}},tw=(e,t)=>{let n=HC(e);return{name:n.name,fn:n.fn,options:[e,t]}},nw=o((e=>{var t=u();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),rw=o(((e,t)=>{t.exports=nw()})),iw=o((e=>{var t=u(),n=rw();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),aw=o(((e,t)=>{t.exports=iw()})),ow=rw(),sw=aw(),cw=zx(19)?dw:fw;function lw(e,t,n,r,i){return cw(e,t,n,r,i)}function uw(e,t,n,r,i){let a=W.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,ow.useSyncExternalStore)(e.subscribe,a,a)}D_({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,ow.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function dw(e,t,n,r,i){let a=E_();if(!a)return uw(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function fw(e,t,n,r,i){return(0,sw.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var pw=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return lw(this,e,t,n,r)}},mw=class extends pw{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){W.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;X(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){W.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return W.useDebugValue(e),lw(this,this.selectors[e],t,n,r)}useContextCallback(e,t){W.useDebugValue(e);let n=Q(t??j_);this.context[e]=n}useStateSetter(e){let t=W.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},hw={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},gw=class extends mw{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:DS(),nested:n,triggerElements:i},hw),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&sv(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function _w(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=t.context.triggerElements,d=o,f=W.useRef(null);r===void 0&&f.current===null&&(f.current=new gw({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),X(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};pv(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function vw(e,t=!1,n=!1,r=!1){let[i,a]=W.useState(e&&t?`idle`:void 0),[o,s]=W.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),X(()=>{if(!e&&o&&i!==`ending`&&n){let e=ab.request(()=>{a(`ending`)});return()=>{ab.cancel(e)}}},[e,o,i,n]),X(()=>{if(!e||t)return;let n=ab.request(()=>{a(void 0)});return()=>{ab.cancel(n)}},[t,e]),X(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=ab.request(()=>{a(`idle`)});return()=>{ab.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var yw=null;function bw(e){if(!yw){let e=[];yw=e,queueMicrotask(()=>{yw=null,xS.flushSync(()=>{for(let t of e)t()})})}yw.push(e)}function xw(e,t=!1,n=!1){let r=ob();return Q((i,a=null)=>{r.cancel();let o=IS(e);if(o==null)return;let s=o,c=()=>{if(!n){xS.flushSync(i);return}bw(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(s.getAnimations().some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=Hv;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function Sw(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=Q(a),s=xw(r,n,i);W.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}var Cw={tabIndex:-1,[Iv]:``};function ww(e){return t=>t!==`touch`||e.current}function Tw(e,t=!1){let n=Lx(),r=jS()!=null,i=C_(()=>e(n,r)).current;return _w({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Ew({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function Dw(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Ow(e,t){let n=W.useRef(null);return Q(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),Dw(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Dw(t))})}function kw(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function Aw(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function jw(e,t,n,r={}){let i=n.reason,a=i===Cy,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=Aw(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=kw(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?xS.flushSync(l):l()}function Mw(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Ow(e,n),o=Q(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=Q(e=>{a(e),e&&o(e)});return X(()=>(s(t.current),()=>s(null)),[s,t,n,e]),X(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Nw(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=W.useRef(null),i=e.useState(`open`);X(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=Ry(xy);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function Pw(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=vw(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=Q(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return Sw({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function Fw(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:N_,inactiveTriggerProps:N_,popupProps:N_})},[e])}function Iw(e,t){X(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),X(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Lw=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Rw(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new gw({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:N_,inactiveTriggerProps:N_,popupProps:N_}}var zw=e=>e.triggerIdProp??e.activeTriggerId,Bw=e=>e.openProp??e.open,Vw=e=>(e.popupElement?.id??e.floatingId)||void 0;function Hw(e,t){return t!==void 0&&Bw(e)&&zw(e)===t}function Uw(e,t){return Hw(e,t)?!0:t!==void 0&&Bw(e)&&zw(e)==null&&e.triggerCount===1}var Ww={open:Bw,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:zw,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Vw,isTriggerActive:(e,t)=>t!==void 0&&zw(e)===t,isOpenedByTrigger:(e,t)=>Hw(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&zw(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Uw(e,t)?Vw(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Gw(e){let t=W.useCallback(t=>e===void 0?j_:e.subscribeStore(t),[e]),n=W.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,ow.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Kw(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Lx(),a=jS()!=null,o=C_(()=>new gw({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Lw,floatingId:i,syncOnly:!1,nested:a})).current;return X(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=pv(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function qw(e){return Jw(e,e.rootContext)}function Jw(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=W.useState(null),[d,f]=W.useState(void 0),[p,m]=W.useState(void 0),h=W.useRef(null),g=MS(r),_=W.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=XC({...e,elements:{..._,...l&&{reference:l}}}),y=pv(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=W.useCallback(e=>{let t=pv(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=W.useCallback(e=>{(pv(e)||e===null)&&(h.current=e,f(e)),(pv(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!pv(e))&&v.refs.setReference(e)},[v.refs,f]),C=W.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=W.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=W.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=W.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return X(()=>{o&&(h.current=o)},[o]),X(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),W.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}var Yw=Z_&&$_;function Xw(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=W.useRef(!1),c=W.useRef(null),l=W.useRef(!0),u=V_();W.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=uv(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&mv(e)&&e===Nv(sb(e))&&(s.current=!0,c.current=e)}function a(){l.current=!0}function o(){l.current=!1}return Uy(Hy(t,`blur`,r),Yw&&Hy(t,`keydown`,a,!0),Yw&&Hy(t,`pointerdown`,o,!0))},[i,n]),W.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);pv(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let d=W.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Fv(t.nativeEvent);if(pv(a)){if(Yw&&!t.relatedTarget){if(!l.current&&!dy(a))return}else if(!my(a))return}let o=cy(t.relatedTarget,i.context.triggerElements),{nativeEvent:d,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,Ry(wy,d,f));return}u.start(p,()=>{s.current||i.setOpen(!0,Ry(wy,d,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=pv(n)&&n.hasAttribute(yx(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=Nv(sb(e));(n||t!==e)&&(Pv(o.current.floatingContext?.refs.floating.current,t)||Pv(e,t)||a||cy(n??t,i.context.triggerElements)||i.setOpen(!1,Ry(wy,r)))})}}},[o,r,i,u]);return W.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var Zw=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new B_,this.restTimeout=new B_,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},Qw=new WeakMap;function $w(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Qw.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),Qw.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function eT(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Qw.get(n);a&&a!==e&&$w(a),$w(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Qw.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function tT(e){let t=e.context.dataRef.current,n=C_(()=>t.hoverInteractionState??Zw.create()).current;return t.hoverInteractionState||=n,R_(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function nT(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:l}=a.context,u=MS(),d=jS(),f=tT(a),p=V_(),m=Q(()=>yy(l.current.openEvent?.type,f.interactedInside)),h=Q(()=>by(l.current.openEvent?.type)),g=Q(()=>{$w(f)});X(()=>{o||(f.pointerType=void 0,f.restTimeoutPending=!1,f.interactedInside=!1,g())},[o,f,g]),W.useEffect(()=>g,[g]),X(()=>{if(n&&o&&f.handleCloseOptions?.blockPointerEvents&&h()&&pv(c)&&s){let e=c,t=s,n=sb(s),r=u?.nodesRef.current.find(e=>e.id===d)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=f.pointerEventsScopeElement===t?null:f.pointerEventsScopeElement,a=r===t?null:r,o=f.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return eT(f,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,o,c,s,f,h,u,d,g]),W.useEffect(()=>{if(!n)return;function e(){return!!(u&&d&&_x(u.nodesRef.current,d).length>0)}function t(e){let t=_y(r,`close`,f.pointerType),n=()=>{a.setOpen(!1,Ry(Cy,e)),u?.events.emit(`floating.closed`,e)};t?f.openChangeTimeout.start(t,n):(f.openChangeTimeout.clear(),n())}function o(e){let t=Fv(e);if(!fy(t)){f.interactedInside=!1;return}f.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){f.openChangeTimeout.clear(),p.clear(),u?.events.off(`floating.closed`,v),g()}function _(n){if(e()&&u){u.events.on(`floating.closed`,v);return}if(cy(n.relatedTarget,a.context.triggerElements))return;let r=l.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(u&&r&&pv(o)&&_x(u.nodesRef.current,r,!1).some(e=>Pv(e.context?.elements.floating,o)))){if(f.handler){f.handler(n);return}g(),h()&&!m()&&t(n)}}function v(t){u&&d&&!e()&&p.start(0,()=>{u.events.off(`floating.closed`,v),a.setOpen(!1,Ry(Cy,t)),u.events.emit(`floating.closed`,t)})}let y=s;return Uy(y&&Hy(y,`mouseenter`,c),y&&Hy(y,`mouseleave`,_),y&&Hy(y,`pointerdown`,o,!0),()=>{u?.events.off(`floating.closed`,v)})},[n,s,a,l,r,i,h,m,g,f,u,d,p])}var rT={current:null};function iT(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=rT,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,h=`rootStore`in e?e.rootStore:e,{dataRef:g,events:_}=h.context,v=MS(l),y=tT(h),b=W.useRef(!1),x=Xy(i),S=Xy(r),C=Xy(o),w=Xy(n),T=Xy(p),E=Xy(f),D=Q(()=>yy(g.current.openEvent?.type,y.interactedInside)),O=Q(()=>T.current?.()!==!1),k=Q((e,t,n)=>{let r=h.context.triggerElements;if(r.hasElement(t))return!e||!Pv(e,t);if(!pv(n))return!1;let i=n;return r.hasMatchingElement(e=>Pv(e,i))&&(!e||!Pv(e,i))}),A=Q(()=>{y.handler&&=(sb(h.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),j=Q(()=>{$w(y)});return u&&(y.handleCloseOptions=i?.__options),W.useEffect(()=>A,[A]),W.useEffect(()=>{if(!n)return;function e(e){e.open?b.current=!1:(b.current=e.reason===Cy,A(),y.openChangeTimeout.clear(),y.restTimeout.clear(),y.blockMouseMove=!0,y.restTimeoutPending=!1)}return _.on(`openchange`,e),()=>{_.off(`openchange`,e)}},[n,_,y,A]),W.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=_y(S.current,`close`,y.pointerType);n?y.openChangeTimeout.start(n,()=>{h.setOpen(!1,Ry(Cy,e)),v?.events.emit(`floating.closed`,e)}):t&&(y.openChangeTimeout.clear(),h.setOpen(!1,Ry(Cy,e)),v?.events.emit(`floating.closed`,e))}let t=c.current??(u?h.select(`domReferenceElement`):null);if(!pv(t))return;function r(e){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!ov(y.pointerType))return;let t=vy(C.current),n=_y(S.current,`open`,y.pointerType),r=Fv(e),i=e.currentTarget??null,o=h.select(`domReferenceElement`),s=i;if(pv(r)&&!h.context.triggerElements.hasElement(r)){for(let e of h.context.triggerElements.elements())if(Pv(e,r)){s=e;break}}pv(i)&&pv(o)&&!h.context.triggerElements.hasElement(i)&&Pv(i,o)&&(s=o);let c=s!=null&&k(o,s,r),l=h.select(`open`),u=E.current?.()??h.select(`transitionStatus`)===`ending`,d=!l&&u&&b.current,f=!c&&pv(s)&&pv(o)&&Pv(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,g=!l||c;if(m){O()&&h.setOpen(!0,Ry(Cy,e,s));return}p||(n?y.openChangeTimeout.start(n,()=>{g&&O()&&h.setOpen(!0,Ry(Cy,e,s))}):g&&O()&&h.setOpen(!0,Ry(Cy,e,s)))}function i(t){if(D()){j();return}A();let n=sb(h.select(`domReferenceElement`));y.restTimeout.clear(),y.restTimeoutPending=!1;let r=g.current.floatingContext??d?.();if(!cy(t.relatedTarget,h.context.triggerElements)){if(x.current&&r){h.select(`open`)||y.openChangeTimeout.clear();let i=c.current;y.handler=x.current({...r,tree:v,x:t.clientX,y:t.clientY,onClose(){j(),A(),w.current&&!D()&&i===h.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,y.handler),y.handler(t);return}(y.pointerType!==`touch`||!Pv(h.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Pv(t,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let l=m?Hy(t,`mouseout`,o):void 0;return s?Uy(Hy(t,`mousemove`,r,{once:!0}),Hy(t,`mouseenter`,r),Hy(t,`mouseleave`,i),l):Uy(Hy(t,`mouseenter`,r),Hy(t,`mouseleave`,i),l)},[A,j,g,S,h,n,x,y,u,k,D,a,s,C,c,v,w,d,E,O,m]),W.useMemo(()=>{if(!n)return;function e(e){y.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=h.select(`domReferenceElement`),i=h.select(`open`),o=k(r,n,e.target);if(a&&!ov(y.pointerType))return;if(i&&o&&y.handleCloseOptions?.blockPointerEvents){let e=h.select(`floatingElement`);if(e){let t=y.handleCloseOptions?.getScope?.()??n.ownerDocument.body;eT(y,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=vy(C.current);if(i&&!o||s===0||!o&&y.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;y.restTimeout.clear();function c(){if(y.restTimeoutPending=!1,D())return;let e=h.select(`open`);!y.blockMouseMove&&(!e||o)&&O()&&h.setOpen(!0,Ry(Cy,t,n))}y.pointerType===`touch`?xS.flushSync(()=>{c()}):o&&i?c():(y.restTimeoutPending=!0,y.restTimeout.start(s,c))}}},[n,y,D,k,a,h,C,O])}var aT=`Escape`;function oT(e){return $_&&e.movementX===0&&e.movementY===0}function sT(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function cT(e,t){return sT(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function lT(e,t,n){return sT(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function uT(e,t,n){return sT(t,n?e===Rv:e===zv,e===Vv)}function dT(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===aT:sT(t,n?e===zv:e===Rv,e===Bv)}function fT(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,O=hy(T),k=py(E),A=Xy(O),j=jS(),M=MS(b),N=W.useRef(f),P=W.useRef(o??-1),F=W.useRef(null),I=W.useRef(!0),L=Q(e=>{i(P.current===-1?null:P.current,e)}),R=W.useRef(!!T),ee=W.useRef(w),z=W.useRef(!1),te=W.useRef(!1),ne=W.useRef(null),re=Xy(h),B=Xy(w),ie=Xy(o),ae=Xy(y),oe=ob(),se=ob(),ce=Q(()=>{function e(e){d?M?.events.emit(`virtualfocus`,e):ne.current=xx(e,{sync:z.current,preventScroll:!0})}let t=n.current[P.current],r=te.current;t&&e(t),(z.current?e=>e():e=>oe.request(e))(()=>{let i=n.current[P.current]||t;i&&(t||e(i),fe&&(r||!I.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{D.current.orientation=g},[D,g]),X(()=>{a&&(w&&T?(P.current=o??-1,N.current&&o!=null&&(te.current=!0,L())):R.current&&(P.current=-1,L()))},[a,w,T,o,L]),X(()=>{if(a){if(!w){z.current=!1;return}if(T){if(r==null){if(z.current=!1,ie.current!=null)return;if(R.current&&(P.current=-1,ce()),(!ee.current||!R.current)&&N.current&&(F.current!=null||N.current===!0&&F.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>se.request(e):queueMicrotask)(t),e+=1):(P.current=F.current==null||lT(F.current,g,u)||l?Bb(n):Vb(n),F.current=null,L())};t()}}else zb(n.current,r)||(P.current=r,ce(),te.current=!1)}}},[a,w,T,r,ie,l,n,g,u,L,ce,se]),X(()=>{if(!a||T||!M||d||!R.current)return;let e=M.nodesRef.current,t=e.find(e=>e.id===j)?.context?.elements.floating,n=Nv(sb(E??t??null)),r=e.some(e=>e.context&&Pv(e.context.elements.floating,n));t&&!r&&I.current&&t.focus({preventScroll:!0})},[a,T,E,M,j,d]),X(()=>{ee.current=w,R.current=!!T}),X(()=>{w||(F.current=null,N.current=f)},[w,f]);let le=r!=null,V=Q(e=>{if(!B.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(P.current!==t||r!==t)&&(P.current=t,L(e))}),H=Q(()=>_??M?.nodesRef.current.find(e=>e.id===j)?.context?.dataRef?.current.orientation),ue=Q(()=>Bb(n,re.current)),de=Q(e=>{if(I.current=!1,z.current=!0,e.which===229||!B.current&&e.currentTarget===A.current)return;if(l&&dT(e.key,g,u,S)){cT(e.key,H())||nv(e),C.setOpen(!1,Ry(jy,e.nativeEvent)),mv(E)&&(d?M?.events.emit(`virtualfocus`,E):E.focus());return}let t=P.current,r=Bb(n,h),i=Vb(n,h);if(k||(e.key===`Home`&&(nv(e),P.current=r,L(e)),e.key===`End`&&(nv(e),P.current=i,L(e))),x!=null){let t=x(e,P.current,n,g,c,u,h,r,i);if(t!=null&&(P.current=t,L(e)),g===`both`)return}if(cT(e.key,g)){if(nv(e),w&&!d&&Nv(e.currentTarget.ownerDocument)===e.currentTarget){P.current=lT(e.key,g,u)?r:i,L(e);return}lT(e.key,g,u)?c?t>=i?s&&t!==n.current.length?P.current=-1:(z.current=!1,P.current=r):P.current=Hb(n.current,{startingIndex:t,disabledIndices:h}):P.current=Math.min(i,Hb(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?P.current=n.current.length:(z.current=!1,P.current=i):P.current=Hb(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):P.current=Math.max(r,Hb(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),zb(n.current,P.current)&&(P.current=-1),L(e)}}),fe=W.useMemo(()=>({onFocus(e){z.current=!0,V(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){oT(e)||(z.current=!0,te.current=!1,p&&V(e))},onPointerLeave(e){if(!B.current||!I.current||e.pointerType===`touch`)return;z.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&ae.current&&(ne.current?.(),ne.current=null,P.current=-1,L(e),!d)){let e=A.current,t=Nv(sb(e));e&&Pv(e,t)&&e.focus({preventScroll:!0})}}}),[V,B,A,p,n,L,ae,d]),U=W.useMemo(()=>d&&w&&le&&{"aria-activedescendant":`${v}-${r}`},[d,w,le,v,r]),pe=W.useMemo(()=>({...k?{}:U,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=Fv(e.nativeEvent);if(t&&!Pv(A.current,t))return;nv(e),C.setOpen(!1,Ry(Oy,e.nativeEvent)),mv(E)&&E.focus();return}de(e)},onPointerMove(e){oT(e)||(I.current=!0)}}),[U,de,A,k,C,w,d,E]),me=W.useMemo(()=>{function e(e){C.setOpen(!0,Ry(jy,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&iv(e.nativeEvent)&&(N.current=!d)}function n(e){N.current=f,f===`auto`&&av(e.nativeEvent)&&(N.current=!0)}return{onKeyDown(t){let n=C.select(`open`);I.current=!1;let r=t.key.startsWith(`Arrow`),i=uT(t.key,H(),u),a=cT(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return de(t);if(n||m||!r){if(o){let e=cT(t.key,H());F.current=l&&e?null:t.key}if(l){i&&(nv(t),n?(P.current=ue(),L(t)):e(t));return}a&&(ie.current!=null&&(P.current=ie.current),nv(t),!n&&m?e(t):de(t),n&&L(t))}},onFocus(e){C.select(`open`)&&!d&&(P.current=-1,L(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[de,f,ue,l,L,C,m,g,H,u,ie,d]),he=W.useMemo(()=>({...U,...me}),[U,me]);return W.useMemo(()=>a?{reference:he,floating:pe,item:fe,trigger:me}:{},[a,he,pe,me,fe])}function pT(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=V_(),m=W.useRef(``),h=W.useRef(u??i??-1),g=W.useRef(null),_=Q(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!Gb(n)||n?.matches(`:disabled`)?!1:o==null||!Ub(M_,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(nv(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(nv(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=Q(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);Pv(n,t)||Pv(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=W.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return W.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var mT=.1,hT=mT*mT,gT=.5;function _T(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function vT(e,t,n,r,i,a,o,s,c,l){let u=!1;return _T(e,t,n,r,i,a)&&(u=!u),_T(e,t,i,a,o,s)&&(u=!u),_T(e,t,o,s,c,l)&&(u=!u),_T(e,t,c,l,n,r)&&(u=!u),u}function yT(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function bT(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function xT(e={}){let{blockPointerEvents:t=!1}=e,n=new B_,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*hT;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Fv(r),g=r.type===`mouseleave`,_=Pv(u,h),v=Pv(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&pv(r.relatedTarget)&&Pv(u,r.relatedTarget))return;function y(){return!!(s&&_x(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=bT(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=bT(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=bT(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=bT(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!yT(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?gT/2:gT*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+gT+1,o=C||T?S.bottom-gT:S.top,s=C?T?S.bottom-gT:S.top:S.bottom-gT;M=vT(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?gT/2:gT*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-gT,o=C||T?S.top+gT:S.bottom,s=C?T?S.top+gT:S.bottom:S.top+gT;M=vT(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?gT/2:gT*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+gT+1,o=w||E?S.right-gT:S.left,s=w?E?S.right-gT:S.left:S.right-gT;M=vT(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?gT/2:gT*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-gT,o=w||E?S.left+gT:S.right,s=w?E?S.left+gT:S.right:S.left+gT;M=vT(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}var ST={...Ww,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},CT=class extends mw{constructor(e,t,n){let r=new Lw;super(wT(e,r,t,n),TT(r),ST)}setOpen=(e,t)=>{jw(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Ry(Sy,e))}};function wT(e,t,n,r=!1){return{...Rw(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function TT(e){return{popupRef:W.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var ET=O_(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=Tw((e,t)=>new CT({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Nw(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=Pw(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=W.useRef(null);X(()=>{m&&t&&p.setOpen(!1,Ry(Py))},[m,t,p]),X(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),X(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),W.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,Ry(Fy))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,Z.jsxs)(I_.Provider,{value:p,children:[l&&(0,Z.jsx)(Ew,{handle:l,store:p}),T&&(0,Z.jsx)(DT,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function DT({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=QS(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=YS(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=W.useMemo(()=>Kx(a.reference,i.reference),[a.reference,i.reference]);return Fw(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??N_}),null}function OT(e){return Lx(e,`base-ui`)}var kT=W.createContext(void 0);function AT(){return W.useContext(kT)}var jT=`data-base-ui-tooltip-trigger`;function MT(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(pv(n))return n}}let t=e.target;return pv(t)?t:null}function NT(e){let t=e;for(;t;){let e=t.closest(`[${jT}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&pv(n.host)?n.host:null}return null}var PT=k_(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=L_(!0),m=Gw(a)??p;if(!m)throw Error(F_(82));let h=OT(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=W.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=Mw(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=AT(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=Vy(v,{open:_}),O=tT(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Xy(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=W.useRef(!1),F=V_(),I=W.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=NT(e);return n!==null&&n!==t&&Pv(t,n)}function ee(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let z=iT(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?xT():null,restMs:L,delay(){return u==null&&D?{close:_y(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),te=Xw(v,{enabled:!A}).reference,ne=e=>{let t=P.current,n=MT(e),r=ee(n),i=y.current,a=i&&n&&Pv(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`){m.setOpen(!1,Ry(Cy,e));return}if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&ov(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,Ry(Cy,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},re=m.useState(`triggerProps`,S);return oS(`button`,e,{state:{open:_},ref:[t,x,y],props:[z,te,S||M!==`none`?re:void 0,{onMouseOver(e){ne(e.nativeEvent)},onFocus(e){R(MT(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[sy]:A?``:void 0,[jT]:A?void 0:``},f],stateAttributesMapping:ry})}),FT=W.createContext(void 0);function IT(){let e=W.useContext(FT);if(e===void 0)throw Error(F_(70));return e}var LT=W.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=TS({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,Z.jsxs)(W.Fragment,{children:[l,c&&xS.createPortal(n,c)]})}),RT=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return L_().useState(`mounted`)||n?(0,Z.jsx)(FT.Provider,{value:n,children:(0,Z.jsx)(LT,{ref:t,...r})}):null}),zT=W.createContext(void 0);function BT(){let e=W.useContext(zT);if(e===void 0)throw Error(F_(71));return e}var VT=W.createContext(void 0);function HT(){return W.useContext(VT)?.direction??`ltr`}var UT=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d=`real`}=yb(e,t)||{};if(l==null)return{};let f=Lb(u),p={x:n,y:r},m=Tb(i),h=Cb(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=vb(k,j,A),N=!c.arrow&&xb(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),WT=(e,t)=>{let{name:n,fn:r}=UT(e);return{name:n,fn:r,options:[e,t]}},GT={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},KT={sideX:`left`,sideY:`top`},qT=`--available-width`,JT=`--available-height`,YT=`--anchor-width`,XT=`--anchor-height`,ZT=`--transform-origin`,QT=qT,$T=JT;function eE(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function tE(e,t,n){let{rects:r,placement:i}=e;return{side:eE(t,bb(i),n),align:xb(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function nE(e){return rE(e,qw)}function rE(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,[C,w]=W.useState(null);!g&&C!==null&&w(null);let T=_.side||`flip`,E=_.align||`flip`,D=_.fallbackAxisSide||`end`,O=v?.crossAxis??!1,k=v?.rootBoundary,A=typeof n==`function`?n:void 0,j=Q(A),M=A?j:n,N=Xy(n),P=Xy(g),F=HT()===`rtl`,I=C||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],L=o===`center`?I:`${I}-${o}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let ee=+(i===`bottom`),z=+(i===`top`),te=+(i===`right`),ne=+(i===`left`),re={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},B=W.useRef(null),ie=Xy(a),ae=Xy(s),oe=typeof a==`function`?0:a,se=typeof s==`function`?0:s,ce=[];p&&ce.push(p),ce.push(ZC(e=>{let t=tE(e,i,F),n=typeof ie.current==`function`?ie.current(t):ie.current,r=typeof ae.current==`function`?ae.current(t):ae.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[oe,se,F,i]));let le=E===`none`&&T!==`shift`,V=!le&&(u||O||T===`shift`),H=T===`none`?null:ew({...re,padding:{top:R.top+1+ee,right:R.right+1+ne,bottom:R.bottom+1+z,left:R.left+1+te},mainAxis:!O&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:D}),ue=le?null:QC({...re,rootBoundary:k,mainAxis:E!==`none`,crossAxis:V,limiter:u||O?void 0:$C(e=>{if(!B.current)return{};let{width:t,height:n}=B.current.getBoundingClientRect(),r=wb(bb(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[re,u,O,k,R,E]);T===`shift`||E===`shift`||o===`center`?ce.push(ue,H):ce.push(H,ue),ce.push(tw({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(QT,`${t}px`),i.setProperty($T,`${n}px`);let a=uv(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(YT,`${u}px`),i.setProperty(XT,`${d}px`)}}),WT(e=>({element:B.current||sb(e.elements.floating).createElement(`div`),padding:B.current?d:0,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=bb(r),u=xb(r),d=wb(l)===`y`,f=B.current,p=typeof a==`function`?a(tE(e,i,F)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return V&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(ZT,d?`${m} ${h}`:`${h} ${m}`),{}}},GT,b),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let de=W.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:fe,elements:U,x:pe,y:me,middlewareData:he,update:ge,placement:_e,context:ve,isPositioned:ye,floatingStyles:be}=t({rootContext:h,open:m?g:void 0,placement:L,middleware:ce,strategy:r,whileElementsMounted:m?void 0:(...e)=>RC(...e,de),nodeId:y,externalTree:S}),{sideX:xe,sideY:Se}=he.adaptiveOrigin||KT,Ce=ye?r:`fixed`,we=W.useMemo(()=>{let e;return e=ye?b?{position:Ce,[xe]:pe,[Se]:me}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[QT]=`100vw`,e[$T]=`100vh`,ye||(e.opacity=0),e},[b,Ce,xe,pe,Se,me,be,ye]),Te=W.useRef(null);X(()=>{if(!g)return;let e=N.current,t=typeof e==`function`?e():e,n=(iE(t)?t.current:t)||null;n!==Te.current&&(fe.setPositionReference(n),Te.current=n)},[g,fe,M,N]),W.useEffect(()=>{if(!g)return;let e=N.current;typeof e!=`function`&&iE(e)&&e.current!==Te.current&&(fe.setPositionReference(e.current),Te.current=e.current)},[g,fe,M,N]),W.useEffect(()=>{if(m&&g&&U.reference&&U.floating)return RC(U.reference,U.floating,ge,de)},[m,g,U,ge,de]);let Ee=bb(_e),De=eE(i,Ee,F),Oe=xb(_e)||`center`,ke=!!he.hide?.referenceHidden;X(()=>{x&&g&&ye&&Ee!==I&&w(Ee)},[x,g,ye,Ee,I]);let Ae=W.useMemo(()=>({position:`absolute`,top:he.arrow?.y,left:he.arrow?.x}),[he.arrow]),je=he.arrow?.centerOffset!==0;return W.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:B,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:fe,context:ve,isPositioned:ye,update:ge}),[we,Ae,B,je,De,Oe,Ee,ke,fe,ve,ye,ge])}function iE(e){return e!=null&&`current`in e}function aE(e){return e===`starting`?pS:N_}function oE(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),oS(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},aE(r),i],stateAttributesMapping:ay})}var sE=W.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=yS,style:g,..._}=e,v=L_(),y=IT(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=nE({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=oE(e,W.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,Z.jsx)(zT.Provider,{value:D,children:O})}),cE=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=L_(),{side:s,align:c}=BT(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);Sw({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),nT(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return oS(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[Cw,f,aE(d),a],stateAttributesMapping:oy})});function lE(e){return zx(19)?e:e?`true`:void 0}function uE(e){let[t,n]=W.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function dE(e){let t=W.useRef(!0);t.current&&(t.current=!1,e())}function fE(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function pE({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=W.useRef(e!==void 0),[a,o]=W.useState(t);return[i&&e!==void 0?e:a,W.useCallback(e=>{i||o(e)},[])]}var mE=W.createContext(void 0),hE=W.createContext(void 0),gE=W.createContext(void 0);function _E(){let e=W.useContext(mE);if(e===void 0)throw Error(F_(60));return e}function vE(){let e=W.useContext(hE);if(e===void 0)throw Error(F_(101));return e}function yE(){let e=W.useContext(gE);if(e===void 0)throw Error(F_(61));return e}var bE=`data-valid`,xE=`data-invalid`,SE={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},CE={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},wE={valid(e){return e===null?null:e?{[bE]:``}:{[xE]:``}}},TE={invalid:void 0,name:void 0,validityData:{state:SE,errors:[],error:``,value:``,initialValue:null},setValidityData:j_,disabled:void 0,setTouched:j_,setDirty:j_,setFilled:j_,setFocused:j_,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:CE,registerFieldControl:j_,validation:{getValidationProps:(e,t=N_)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:j_,getInputControl:()=>null,commit:async()=>{},change:j_}},EE=W.createContext(TE);function DE(e=!0){let t=W.useContext(EE);if(t.setValidityData===j_&&!e)throw Error(F_(28));return t}function OE(e,t,n,r,i=!0,a){let{registerFieldControl:o}=DE(),s=C_(()=>Symbol());X(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),X(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var kE=W.createContext({controlId:void 0,registerControlId:j_,resetControlId:j_,labelId:void 0,setLabelId:j_,messageIds:[],setMessageIds:j_,getDescriptionProps:e=>e});function AE(){return W.useContext(kE)}function jE(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=AE(),o=OT(),s=C_(()=>Symbol()),c=W.useRef(!1),l=W.useRef(!1),u=Q(()=>{c.current&&i!==j_&&(c.current=!1,i(s.current,void 0))});return X(()=>{if(!n||i===j_){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}if(e===void 0){u();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,u]),X(()=>u,[u]),(n?r:void 0)??t??o}function ME(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var NE=(e,t)=>Object.is(e,t);function PE(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function FE(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!ME(e,t,(e,t)=>PE(e,t,n)):e!==t}function IE(e,t,n){return e?e.some(e=>e!==void 0&&PE(t,e,n)):!1}function LE(e,t,n){return e?e.findIndex(e=>e!==void 0&&PE(e,t,n)):-1}function RE(e,t){if(t!==NE)return n=>IE(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function zE(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(RE(t,n)):LE(e,t,n);return i===-1?null:i}function BE(e,t,n,r,i,a){return IE(r,t,i)?a!=null&&e>a&&IE(r,n[a],i)?a:e:e===a?zE(n,r,i,!0):a}function VE(e,t,n){return e.filter(e=>!PE(t,e,n))}function HE(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function UE(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function WE(e){return UE(e?.[0])}function GE(e){return WE(e)?e.flatMap(e=>e.items):e}function KE(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(WE(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function qE(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return HE(e)}function JE(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?HE(e.value):HE(e)}function YE(e,t,n){function r(){return qE(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=GE(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function XE(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Z.jsx)(W.Fragment,{children:YE(r,t,n)},i)),e),[])}var ZE={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:JE(t,r)!==``},hasNullItemLabel:(e,t)=>t?KE(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>PE(t,e,n)):PE(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},QE=W.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:j_,validationMode:`onSubmit`,submitCountRef:{current:0}});function $E(){return W.useContext(QE)}function eD(e,t){let n=W.useRef(e),r=Q(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function tD(e){let t=W.useRef(``),n=W.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:W.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function nD(e,t){let{onClick:n,onPointerDown:r}=tD(Q((n,r)=>{(typeof e==`function`?e():e)||t(r||(J_?`touch`:``))}));return W.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function rD(e){let[t,n]=W.useState(null),r=nD(e,n);return eD(e,t=>{t&&!e&&n(null)}),W.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function iD(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function aD(e,t){return Math.max(0,e-t)}function oD(e,t){if(t<=0)return 0;let n=iD(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function sD(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=NE,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=$E(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=DE(),F=jE({id:t}),I=M||d,L=j??c,[R,ee]=pE({controlled:n,default:y?r??M_:r,name:`Select`,state:`value`}),[z,te]=pE({controlled:a,default:o,name:`Select`,state:`open`}),ne=W.useRef([]),re=W.useRef([]),B=W.useRef(null),ie=W.useRef(null),ae=W.useRef(0),oe=W.useRef(null),se=W.useRef([]),ce=W.useRef(!1),le=W.useRef(null),V=W.useRef(null),H=W.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ue=W.useRef(!1),de=W.useRef(R),{mounted:fe,setMounted:U,transitionStatus:pe}=vw(z),{openMethod:me,triggerProps:he}=rD(z),ge=C_(()=>new mw({id:F,labelId:void 0,modal:m,multiple:y,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:z,mounted:fe,transitionStatus:pe,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:N_,triggerProps:N_,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:j_,setOpen:j_,handleScrollArrowVisibility:j_,onOpenChangeComplete:j_,listRef:ne,popupRef:B,scrollHandlerRef:ie,scrollArrowsMountedCountRef:ae,valueRef:oe,valuesRef:se,labelsRef:re,typingRef:ce,selectionRef:H,firstItemTextRef:le,selectedItemTextRef:V,alignItemWithTriggerActiveRef:ue,initialValueRef:de},ZE)).current,_e=ge.useState(`activeIndex`),ve=ge.useState(`selectedIndex`),ye=ge.useState(`triggerElement`),be=ge.useState(`positionerElement`),xe=uE(me),Se=me??xe,Ce=W.useMemo(()=>y?``:JE(R,x),[y,R,x]),we=W.useMemo(()=>y&&Array.isArray(R)?R.map(e=>JE(e,x)):JE(R,x),[y,R,x]);OE(Xy(ye),F,R,Q(()=>we),!I,c);let Te=y?Array.isArray(R)&&R.length>0:R!=null&&Ce!==``;X(()=>{A(Te)},[Te,A]),X(function(){let e=zE(se.current,R,S,y);e===null&&(V.current=null),!z&&ge.set(`selectedIndex`,e)},[y,z,R,S,ge]),eD(R,()=>{T(L),E(FE(R,k.initialValue,S)),N.change(R)});let Ee=Q((e,t)=>{s?.(e,t),!t.isCanceled&&(te(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))}),De=Q(()=>{U(!1),ge.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});Sw({enabled:!h,open:z,ref:B,onComplete(){z||De()}}),W.useImperativeHandle(h,()=>({unmount:De}),[De]);let Oe=Q((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),ke=Q(e=>{let t=aD(e.scrollHeight,e.clientHeight),n=oD(e.scrollTop,t),r=n>0,i=n<t;ge.set(`scrollUpArrowVisible`,r),ge.set(`scrollDownArrowVisible`,i)}),Ae=Kw({open:z,onOpenChange:Ee,elements:{reference:ye,floating:be}}),je=KS(Ae,{enabled:!I,event:`mousedown`}),Me=QS(Ae),Ne=fT(Ae,{enabled:!I,listRef:ne,activeIndex:_e,selectedIndex:ve,disabledIndices:M_,onNavigate(e){(e!==null||z)&&ge.set(`activeIndex`,e)},focusItemOnHover:C}),Pe=pT(Ae,{enabled:!I&&(z||!f&&!y),listRef:re,activeIndex:_e,selectedIndex:ve,disabledIndices:e=>fE(ne.current[e]),onMatch(e){z?ge.set(`activeIndex`,e):Oe(se.current[e],Ry(xy))},onTyping(e){ce.current=e}}),Fe=W.useMemo(()=>Kx(Pe.reference,Ne.reference,Me.reference,je.reference,he),[je.reference,Pe.reference,Ne.reference,Me.reference,he]),Ie=W.useMemo(()=>Kx(Cw,Pe.floating,Ne.floating,Me.floating),[Pe.floating,Ne.floating,Me.floating]),Le=Ne.item??N_;ge.useContextCallback(`setValue`,Oe),ge.useContextCallback(`setOpen`,Ee),ge.useContextCallback(`handleScrollArrowVisibility`,ke),ge.useContextCallback(`onOpenChangeComplete`,_),dE(()=>{ge.update({popupProps:Ie,triggerProps:Fe})}),ge.useSyncedValues({id:F,modal:m,multiple:y,value:R,open:z,mounted:fe,transitionStatus:pe,popupProps:Ie,triggerProps:Fe,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Se});let Re=W.useMemo(()=>({disabled:I,readOnly:f,required:p,multiple:y,highlightItemOnHover:C,itemProps:Le}),[I,f,p,y,C,Le]),ze=Wy(g,N.inputRef),Be=y?void 0:L,Ve=W.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=JE(e,x);return(0,Z.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,Z.jsxs)(mE.Provider,{value:ge,children:[(0,Z.jsx)(hE.Provider,{value:Re,children:(0,Z.jsx)(gE.Provider,{value:Ae,children:w})}),(0,Z.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){ge.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Ry(xy,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=se.current.findIndex(t=>JE(t,x).toLowerCase()===e||qE(t,b).toLowerCase()===e);r===-1&&(r=se.current.findIndex((t,n)=>{let r=re.current[n];return r!=null&&r.toLowerCase()===e}));let i=se.current[r];i!=null&&Oe(i,n)}ge.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&Be==null?`${F}-hidden-input`:void 0,form:l,name:Be,autoComplete:u,value:Ce,disabled:I,required:p&&!(y&&Te),readOnly:f,ref:ze,style:L?ub:lb,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ve]})}function cD(e,t){return e??t}var lD=5;function uD(e,t){let n=dD(t);return e.clientX>=n.left-lD&&e.clientX<=n.right+lD&&e.clientY>=n.top-lD&&e.clientY<=n.bottom+lD}function dD(e){let t=e.getBoundingClientRect(),n=uv(e);if(tv)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var fD=W.createContext(void 0);function pD(e=!1){let t=W.useContext(fD);if(t===void 0&&!e)throw Error(F_(16));return t}function mD(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:W.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function hD(e,t,{detail:n=0}={}){e.dispatchEvent(new(uv(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function gD(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=W.useRef(null),s=pD(!0),c=a??s!==void 0,{props:l}=mD({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=W.useCallback(()=>{let e=o.current;_D(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:W.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Kx({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(rS(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=_D(r),s=!i&&vD(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),hD(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),hD(r,e)))},onKeyUp(e){if(!t){if(rS(e),a?.(e),e.target===e.currentTarget&&i&&c&&_D(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),hD(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Q(e=>{o.current=e,u()})}}function _D(e){return mv(e)&&e.tagName===`BUTTON`}function vD(e){return mv(e)&&e.tagName===`A`&&!!e.href}var yD=`data-popup-side`,bD=400,xD={...iy,...wE,popupSide:e=>e?{[yD]:e}:null,value:()=>null},SD=W.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,validation:f,state:p,disabled:m}=DE(),{labelId:h}=AE(),g=_E(),{readOnly:_,required:v,disabled:y}=vE(),b=m||y||a,x=g.useState(`open`),S=g.useState(`mounted`),C=g.useState(`value`),w=g.useState(`triggerProps`),T=g.useState(`positionerElement`),E=g.useState(`listElement`),D=g.useState(`popupSide`),O=g.useState(`id`),k=g.useState(`labelId`),A=g.useState(`hasSelectedValue`),j=S&&T?D:null,M=i??O,N=cD(h,k);jE({id:i});let P=Xy(T),F=W.useRef(null),{getButtonProps:I,buttonRef:L}=gD({disabled:b,native:o}),R=g.useStateSetter(`triggerElement`),ee=V_(),z=V_(),te=V_();W.useEffect(()=>{if(x)return te.start(bD,()=>{g.context.selectionRef.current.allowUnselectedMouseUp=!0,g.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{te.clear()};g.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},z.clear()},[x,g,z,te]);let ne=Kx(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??hy(T)?.id:void 0,"aria-labelledby":N,"aria-readonly":_||void 0,"aria-required":v||void 0,tabIndex:b?-1:0,onFocus(e){u(!0),x&&g.context.alignItemWithTriggerActiveRef.current&&g.context.setOpen(!1,Ry(xy,e.nativeEvent)),ee.start(0,()=>{g.set(`forceMount`,!0)})},onBlur(e){Pv(T,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&f.commit(C))},onMouseDown(e){if(x)return;let t=sb(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;Pv(F.current,t)||Pv(P.current,t)||uD(e,F.current)||g.context.setOpen(!1,Ry(My,e))}z.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),re=f.getValidationProps(b,ne);re.role=`combobox`;let B={...p,open:x,disabled:b,value:C,readOnly:_,popupSide:j,placeholder:!A};return oS(`button`,e,{ref:[t,F,L,R],state:B,stateAttributesMapping:xD,props:re})}),CD={value:()=>null},wD=W.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=_E(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?XE(l,u,d):YE(l,u,d)),oS(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:CD})}),TD=W.forwardRef(function(e,t){let n=_E(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Z.jsx)(ES,{ref:t,...e}):null}),ED=W.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function DD(){return W.useContext(ED)}function OD(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Q(i),[,o]=W.useState(!1),s=C_(AD).current,c=C_(kD).current,l=W.useRef(0),u=W.useRef(!0),d=W.useRef(null),f=W.useRef(null),p=Q(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Q((e,t)=>{c.set(e,t),p()}),h=Q(e=>{c.delete(e),p()}),g=Q(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!ND(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&PD(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=MD(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Q(()=>{let[e,t]=jD(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Q(e=>(s.add(e),()=>{s.delete(e)})),b=W.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,Z.jsx)(ED.Provider,{value:b,children:t})}function kD(){return new Map}function AD(){return new Set}function jD(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>PD(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function MD(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function ND(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function PD(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var FD=W.createContext(void 0);function ID(){let e=W.useContext(FD);if(!e)throw Error(F_(59));return e}var LD=W.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Z.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function RD(e,t){e&&Object.assign(e.style,t)}var zD={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},BD={},VD={},HD=``;function UD(e,t){return gv(e)?e:t}function WD(e,t,n){return/hidden|clip/.test(e.getComputedStyle(UD(t,n)).overflowY)}function GD(e){if(typeof document>`u`)return!1;let t=sb(e);return uv(t).innerWidth-t.documentElement.clientWidth>0}function KD(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=sb(e),n=t.documentElement,r=t.body,i=UD(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function qD(e){let t=sb(e),n=t.documentElement,r=t.body,i=UD(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function JD(e){let t=sb(e),n=t.documentElement,r=t.body,i=uv(n),a=0,o=0,s=!1,c=ab.create();if($_&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,BD={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},HD=n.style.scrollBehavior,VD={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=UD(n,r);if(s=KD(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,BD),Object.assign(r.style,VD),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=HD)}function d(){u(),c.request(l)}l();let f=Hy(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var YD=new class{lockCount=0;restore=null;timeoutLock=B_.create();timeoutUnlock=B_.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=sb(e),n=t.documentElement,r=t.body,i=uv(n);if(WD(i,n,r)){let t=new i.MutationObserver(()=>{WD(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=J_||!GD(e);this.restore=a?qD(e):JD(e)}};function XD(e=!0,t=null){X(()=>{if(e)return YD.acquire(t)},[e,t])}var ZD=20;function QD(e,t,n,r){let[i,a]=W.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=sb(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-ZD)},[e,t,n]),XD(e&&(!t||i),r)}var $D={position:`fixed`},eO=W.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=vS,style:_,...v}=e,y=_E(),b=yE(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),O=y.useState(`isItemEqualToValue`),k=y.useState(`transitionStatus`),A=W.useRef(null),j=W.useRef(null),[M,N]=W.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),W.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),QD((P||C)&&x,T===`touch`,E,D);let F=nE({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??P,collisionAvoidance:g,keepMounted:!0}),I=P?`none`:F.side,L=P?$D:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};X(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=oE(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),z=W.useRef(0),te=Q(e=>{if(y.context.valuesRef.current.length===0)return;let t=z.current;z.current=e.size;let n=Ry(xy);if(t!==0&&!y.state.multiple&&w!==null&&LE(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&LE(y.context.valuesRef.current,e,O)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>LE(y.context.valuesRef.current,e,O)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&P){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};RD(E,e),RD(y.context.popupRef.current,e)}}),ne=W.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,Z.jsx)(OD,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:te,children:(0,Z.jsxs)(FD.Provider,{value:ne,children:[S&&C&&(0,Z.jsx)(LD,{inert:lE(!x),cutout:D}),ee]})})}),tO=`base-ui-disable-scrollbar`,nO={className:tO,getElement(e){return(0,Z.jsx)(`style`,{nonce:e,href:tO,precedence:`base-ui:low`,children:`.${tO}{scrollbar-width:none}.${tO}::-webkit-scrollbar{display:none}`})}},rO=W.createContext(void 0);function iO(e){let t=W.useContext(rO);if(t===void 0&&!e)throw Error(F_(69));return t}var aO=`ArrowUp`,oO=`ArrowDown`,sO=`ArrowLeft`,cO=`ArrowRight`,lO=new Set([aO,oO,sO,cO,`Home`,`End`]),uO=[`Shift`,`Control`,`Alt`,`Meta`];function dO(e){return mv(e)&&e.tagName===`INPUT`}function fO(e){return!!(dO(e)&&e.selectionStart!=null||mv(e)&&e.tagName===`TEXTAREA`)}function pO(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=mO(e,t,`left`),a=hO(e),o=hO(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=mO(e,t,`top`),r=hO(e),i=hO(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function mO(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function hO(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var gO=W.createContext(void 0),_O={disableStyleElements:!1};function vO(){return W.useContext(gO)??_O}var yO=`--transform-origin`,bO={...ay,...Kv},xO=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=_E(),{multiple:c,readOnly:l,highlightItemOnHover:u}=vE(),d=yE(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=ID(),_=iO(!0)!=null,v=HT(),{nonce:y,disableStyleElements:b}=vO(),x=s.useState(`id`),S=s.useState(`open`),C=s.useState(`openMethod`),w=s.useState(`mounted`),T=s.useState(`popupProps`),E=s.useState(`transitionStatus`),D=s.useState(`triggerElement`),O=s.useState(`positionerElement`),k=s.useState(`listElement`),A=W.useRef(!1),j=W.useRef(!1),M=W.useRef({}),N=ob(),P=Q(e=>{if(!O||!s.context.popupRef.current||!j.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(A.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=wO(O),i=TO(O.getBoundingClientRect().height,`y`,r),a=sb(O),o=uv(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=SO(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=CO(e),g=null,_=e=>{O.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=iD(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(A.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=iD(g,0,CO(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(A.current=!0),s.context.handleScrollArrowVisibility(e)});W.useImperativeHandle(s.context.scrollHandlerRef,()=>P,[P]),Sw({open:S,ref:s.context.popupRef,onComplete(){S&&s.context.onOpenChangeComplete(!0)}});let F={open:S,transitionStatus:E,side:f,align:p};X(()=>{O&&s.context.popupRef.current&&!Object.keys(M.current).length&&(M.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),X(()=>{S||m||(j.current=!1,A.current=!1,RD(O,M.current))},[S,m,O]),X(()=>{let e=s.context.popupRef.current;if(!S||!D||!O||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(j.current=!0,e.style.removeProperty(yO),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=OO(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=uv(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=sb(D),c=wO(D),l=EO(D.getBoundingClientRect(),c),d=EO(O.getBoundingClientRect(),c),f=l.height,p=k||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=SO(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,j=0;if(t&&n){let e=EO(n.getBoundingClientRect(),c);T=EO(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;j=T.top-d.top+T.height/2-r}let N=w+j+y+h,P=Math.min(S,N),F=S-_-y,I=N-P,L=C-5;O.style.left=`${iD(E,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${_}px`,O.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=CO(p),ee=I>=R-1;ee&&(P=Math.min(S,d.height)-(I-R));let z=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),te=(r.visualViewport?.scale??1)!==1&&$_;if(z||te){RD(O,M.current),g(!1);return}let ne=Math.max(b,P);if(ee){let e=Math.max(0,S-N);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=CO(p)}else O.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=iD(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(yO,`50% ${i}%`)}(ne===S||P>=x)&&(A.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,S,O,D,m,g,N,k,u,v,h]),W.useEffect(()=>{if(!m||!O||!S)return;let e=uv(O);function t(e){s.context.setOpen(!1,Ry(Ly,e))}return Hy(e,`resize`,t)},[s,m,O,S]);let I={...k?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${x}-list`},onKeyDown(e){_&&lO.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:zD},className:!k&&m?nO.className:void 0},L=oS(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:bO,props:[T,I,aE(E),o]});return(0,Z.jsxs)(W.Fragment,{children:[!b&&nO.getElement(y),(0,Z.jsx)(GS,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:L})]})});function SO(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function CO(e){return aD(e.scrollHeight,e.clientHeight)}function wO(e){return FC.getScale(e)}function TO(e,t,n){return e/n[t]}function EO(e,t){return Rb({x:TO(e.x,`x`,t),y:TO(e.y,`y`,t),width:TO(e.width,`x`,t),height:TO(e.height,`y`,t)})}var DO=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function OO(e){let{style:t}=e,n={};for(let[e,r]of DO)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of DO){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}function kO(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=DD(),u=W.useRef(-1),[d,f]=W.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=W.useRef(null),h=W.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var AO=W.createContext(void 0);function jO(){let e=W.useContext(AO);if(!e)throw Error(F_(57));return e}var MO=W.memo(W.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=W.useRef(null),d=kO({guess:!0,label:o,textRef:u}),f=_E(),{itemProps:p,multiple:m,disabled:h,readOnly:g}=vE(),_=h||s,v=f.useState(`isActive`,d.index),y=f.useState(`open`),b=f.useState(`isSelected`,a),x=f.useState(`isSelectedByFocus`,d.index),S=f.useState(`isItemEqualToValue`),C=d.index,w=W.useRef(null);X(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),X(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=BE(C,a,f.context.valuesRef.current,e,S,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&PE(a,e,S),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,S,f,a]);let T=W.useRef(`mouse`),E=W.useRef(!1),{getButtonProps:D,buttonRef:O}=gD({disabled:_,focusableWhenDisabled:!0,native:c,composite:!0}),k={disabled:_,selected:b,highlighted:v};function A(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=b?VE(n,a,S):[...n,a];f.context.setValue(r,Ry(Ey,e))}else f.context.setValue(a,Ry(Ey,e)),f.context.setOpen(!1,Ry(Ey,e))}function j(){f.context.selectionRef.current.dragY=0}let M={role:`option`,"aria-selected":b,tabIndex:y&&v?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&iv(e.nativeEvent)&&(n!==void 0||v),i=t&&!r&&!E.current;E.current=!1,!(_||i)&&A(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,j()},onMouseUp(){if(j(),_||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&b,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!b;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},N=oS(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=W.useMemo(()=>({selected:b,index:C,textRef:u,selectedByFocus:x}),[b,C,u,x]);return(0,Z.jsx)(AO.Provider,{value:P,children:N})})),NO=W.memo(W.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=jO(),a=_E(),{render:o,className:s,style:c,...l}=e;return oS(`div`,e,{ref:[W.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),PO=e=>Symbol.iterator in e,FO=e=>`entries`in e,IO=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},LO=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function RO(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:PO(e)&&PO(t)?FO(e)&&FO(t)?IO(e,t):LO(e,t):IO({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function zO(e){let t=W.useRef(void 0);return n=>{let r=e(n);return RO(t.current,r)?t.current:t.current=r}}function BO(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=BO(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function VO(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=BO(e))&&(r&&(r+=` `),r+=t);return r}var HO=W.createContext(void 0);function UO(){return W.useContext(HO)}function WO(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=pD(),{ref:i,index:a}=kO(e),o=n===a,s=W.useRef(null),c=Wy(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function GO(e){let{render:t,className:n,style:r,state:i=N_,props:a=M_,refs:o=M_,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=WO({metadata:s});return oS(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var KO=W.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=OT(u||void 0),h=UO(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=pE({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=gD({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=Ry(xy,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=oS(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=W.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,Z.jsx)(GO,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T});function qO(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=M_}=e,[p,m]=W.useState(0),h=r!=null,g=W.useRef(null),_=Wy(g,c),v=W.useRef([]),y=W.useRef(!1),b=W.useRef(null),x=o??p,S=Q((e,t=!1)=>{if(b.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];pO(g.current,t,a,n)}}),C=Q(e=>{if(e.size===0)return;if(y.current){let e=v.current,t=e.indexOf(b.current);if(t===-1){let t=e[x];!t||Ub(e,x,d)?S(JO(e,d)):b.current=t}else t!==x&&S(t);return}y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)S(i);else if(Ub(t,x,d)){let e=Hb(t,{disabledIndices:d});zb(t,e)||S(e)}pO(g.current,r,a,n)});X(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(Ub(e,x,d)){let t=Hb(e,{disabledIndices:d});zb(e,t)||S(t)}},[d,o,x,v,S]);let w=Q((e,t,n)=>i?i(e,t,n,v):n),T=Q(e=>{let o=e.key===`Home`||e.key===`End`;if(!lO.has(e.key)||!l&&o||YO(e,f)||!g.current)return;let s=a===`rtl`,c=s?sO:cO,p=s?cO:sO,m=n===`vertical`?oO:c,_=n===`vertical`?aO:p,y=Fv(e.nativeEvent);if(y!=null&&fO(y)&&!fE(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=x,C=Bb(v,d),T=Vb(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:x,loopFocus:t,maxIndex:T,minIndex:C,onLoop:w,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=C:e.key===`End`&&(b=T)),b===x&&(E||D)&&(t&&b===T&&E?(b=C,i&&(b=i(e,x,b,v))):t&&b===C&&D?(b=T,i&&(b=i(e,x,b,v))):b=Hb(v.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==x&&!zb(v.current,b)&&(u&&e.stopPropagation(),(h||o||E||D)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Fv(e.nativeEvent);t&&n!=null&&fO(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:v,onMapChange:C,relayKeyboardEvent:T}}function JO(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!Ub(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function YO(e,t){for(let n of uO)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function XO(e){let{render:t,className:n,style:r,refs:i=M_,props:a=M_,state:o=N_,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=qO({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:HT(),disabledIndices:v,modifierKeys:y}),k=oS(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=W.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,Z.jsx)(fD.Provider,{value:A,children:(0,Z.jsx)(OD,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var ZO=W.createContext(void 0);function QO(){return W.useContext(ZO)}var $O=W.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=iO(!0),m=QO(),h=n??M_,g=c!==void 0||n!==void 0,_=(p?.disabled??!1)||(m?.disabled??!1)||r,[v,y]=pE({controlled:c,default:h,name:`ToggleGroup`,state:`value`}),b=Q((e,t,n)=>{let r;s?(r=v.slice(),t?r.push(e):r.splice(v.indexOf(e),1)):r=t?[e]:[],a?.(r,n),!n.isCanceled&&y(r)}),x={disabled:_,multiple:s,orientation:o},S=W.useMemo(()=>({disabled:_,setGroupValue:b,value:v,isValueInitialized:g}),[_,b,v,g]),C={role:`group`},w=oS(`div`,e,{enabled:!!p,state:x,ref:t,props:[C,f]});return(0,Z.jsx)(HO.Provider,{value:S,children:p?w:(0,Z.jsx)(XO,{render:u,className:l,style:d,state:x,refs:[t],props:[C,f],loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})});function ek(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=pE({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=vw(a,!0,!0),u=OT(),[d,f]=W.useState(),p=d===null?void 0:d??u,m=Q(e=>{let t=!a,n=Ry(Sy,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return W.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var tk=W.createContext(void 0);function nk(){let e=W.useContext(tk);if(e===void 0)throw Error(F_(15));return e}var rk=`data-open`,ik=`data-closed`,ak=Hv,ok=`data-panel-open`,sk={[rk]:``},ck={[ik]:``},lk={open(e){return e?{[ok]:``}:null}},uk={open(e){return e?sk:ck},...Kv},dk=W.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=Q(o),d=ek({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=W.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=W.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=oS(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:uk});return(0,Z.jsx)(tk.Provider,{value:p,children:m})}),fk={...lk,...Kv},pk=W.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=nk(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=gD({disabled:c,focusableWhenDisabled:!0,native:u});return oS(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:fk})}),mk={height:void 0,width:void 0};function hk(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=W.useRef(null),f=W.useRef(null),[p,m]=W.useState(mk),h=W.useRef(mk),g=W.useRef(!1),_=W.useRef(s),v=W.useRef(!1),[y,b]=W.useState(!1),x=W.useRef(null),S=Wy(t,d),C=Xy(s),w=xw(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),O=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,k=n&&T&&f.current!==`css-animation`,A=Q((e,t=!0)=>{t&&(h.current=e),m(e)}),j=Q(()=>{x.current?.(),x.current=null}),M=Q(e=>{j(),x.current=()=>{x.current=null,e()}}),N=Q(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});X(()=>{y&&u!==`starting`&&b(!1)},[y,u]),W.useEffect(()=>()=>{N(),j()},[N,j]),X(()=>{let e=d.current;if(!e)return;!s&&x.current&&j();let t=_k(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=gk(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){A(gk(e)),b(!0);return}if(t===`css-transition`){let t=bk(e);if(A(gk(e)),!n)return t;let r=yk(e,`transition-duration`,`0s`);return M(r),b(!0),t}A(gk(e));let r=yk(e,`animation-name`,`none`);if(!n){r();return}let i=yk(e,`animation-duration`,`0s`);r(),M(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(_.current=!1,v.current=!1,t===`none`){A(mk,!1),c(!1);return}A(gk(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=gk(e);if(!(n.height>0||n.width>0)){c(!1);return}A(n),t===`css-animation`&&yk(e,`animation-name`,`none`)()},[a,s,j,A,c,M,D,u]),Sw({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&A(mk,!1)}}),W.useEffect(()=>{if(s||!a||E!==`ending`||!d.current)return;let e=new AbortController,t=-1;function n(){C.current||(c(!1),A(mk,!1))}return t=ab.request(()=>{w(n,e.signal)}),()=>{ab.cancel(t),e.abort()}},[C,a,s,E,w,A,c]),X(()=>{let e=d.current;e&&n&&T&&e.setAttribute(`hidden`,`until-found`)},[T,n]),W.useEffect(function(){let e=d.current;if(!e)return;function t(e){let t=Ry(xy,e);o(!0,t),!t.isCanceled&&(g.current=!0,l(!0))}return Hy(e,`beforematch`,t)},[o,l]);let P=i||n||a||s;return{height:O.height,props:{...k?{[ak]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:P,transitionStatus:E,width:O.width}}function gk(e){return{height:e.scrollHeight,width:e.scrollWidth}}function _k(e,t){let n=uv(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&vk(n.animationDuration),i=vk(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function vk(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function yk(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function bk(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=ab.request(n);return()=>{ab.cancel(r),n()}}var xk=`--collapsible-panel-height`,Sk=`--collapsible-panel-width`,Ck=W.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=nk(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;X(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=hk({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=Wx(s,k),j=oS(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[xk]:S===void 0?`auto`:`${S}px`,[Sk]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:uk});return E?j:null}),wk=W.createContext(void 0);function Tk(e=!0){let t=W.useContext(wk);if(t===void 0&&!e)throw Error(F_(25));return t}var Ek=W.createContext(void 0);function Dk(e){let t=W.useContext(Ek);if(t===void 0&&!e)throw Error(F_(33));return t}var Ok=W.createContext(void 0);function kk(e){let t=W.useContext(Ok);if(t===void 0&&!e)throw Error(F_(36));return t}function Ak(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=Tk(!0),f=d!==void 0;return W.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:Ey})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!Z_&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&hD(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var jk={type:`regular-item`};function Mk(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=W.useRef(null),{getButtonProps:d,buttonRef:f}=gD({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Ak({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=W.useCallback(e=>Kx(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=Wy(u,f);return W.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Nk=W.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=kO({guess:!0,label:a}),f=Dk(!0),p=OT(i),{store:m}=kk(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Mk({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:jk});return oS(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),Pk=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=kk(),{side:c,align:l}=Dk(),u=iO(!0)!=null,d=s.useState(`open`),f=s.useState(`transitionStatus`),p=s.useState(`popupProps`),m=s.useState(`mounted`),h=s.useState(`instantType`),g=s.useState(`activeTriggerElement`),_=s.useState(`parent`),v=s.useState(`lastOpenChangeReason`),y=s.useState(`rootId`),b=s.useState(`floatingRootContext`),x=s.useState(`floatingTreeRoot`),S=s.useState(`closeDelay`),C=s.useState(`hoverEnabled`),w=s.useState(`disabled`),T=s.useState(`openMethod`),E=_.type===`context-menu`;Sw({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),W.useEffect(()=>{function e(e){s.setOpen(!1,Ry(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),nT(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),O=oS(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:oy,props:[p,{onKeyDown(e){u&&lO.has(e.key)&&e.stopPropagation()}},aE(f),o,{"data-rootownerid":y}]}),k=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(k=!0),(0,Z.jsx)(GS,{context:b,openInteractionType:T,modal:E,disabled:!m,returnFocus:a===void 0?k:a,initialFocus:_.type!==`menu`,restoreFocus:!0,externalTree:_.type===`menubar`?void 0:x,previousFocusableElement:g,nextFocusableElement:_.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:O})}),Fk=W.createContext(void 0);function Ik(){let e=W.useContext(Fk);if(e===void 0)throw Error(F_(32));return e}var Lk=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=kk();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Z.jsx)(Fk.Provider,{value:n,children:(0,Z.jsx)(ES,{ref:t,...r,portalOwnerRole:o})})}),Rk=W.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=vS,style:g,..._}=e,{store:v}=kk(),y=Ik(),b=Tk(!0),x=v.useState(`parent`),S=v.useState(`floatingRootContext`),C=v.useState(`floatingTreeRoot`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`activeTriggerElement`),k=v.useState(`transitionStatus`),A=v.useState(`positionerElement`),j=v.useState(`instantType`),M=v.useState(`adaptiveOrigin`),N=v.useState(`lastOpenChangeReason`),P=v.useState(`floatingNodeId`),F=v.useState(`floatingParentNodeId`),I=S.useState(`domReferenceElement`),L=W.useRef(null),R=xw(A),ee=n,z=c,te=l,ne=s,re=h;x.type===`context-menu`&&(ee=n??x.context?.anchor,ne??=`start`,!o&&ne!==`center`&&(te=e.alignOffset??2,z=e.sideOffset??-5));let B=o,ie=ne;x.type===`menu`?(B??=`inline-end`,ie??=`start`,re=e.collisionAvoidance??yS):x.type===`menubar`&&(B??=x.context.orientation===`vertical`?`inline-end`:`bottom`,ie??=`start`);let ae=x.type===`context-menu`,oe=nE({anchor:ee,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:B,sideOffset:z,align:ie,alignOffset:te,arrowPadding:ae?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:P,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:re,shift:ae?{crossAxis:!(`side`in re&&re.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:M});W.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===P&&v.set(`hoverEnabled`,!1),e.nodeId!==P&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Ry(Ny)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,P]),W.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Ry(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let se=V_();W.useEffect(()=>{T||se.clear()},[T,se]),W.useEffect(()=>{function e(e){if(T&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&O&&O!==e.target){let e=v.select(`closeDelay`);e>0?se.isStarted()||se.start(e,()=>{v.setOpen(!1,Ry(Ny))}):v.setOpen(!1,Ry(Ny))}else se.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,O,v,se]),W.useEffect(()=>{let e={open:T,nodeId:P,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,P,F]),X(()=>{let e=I,t=L.current;if(e&&(L.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return R(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,R,v]);let ce={open:T,side:oe.side,align:oe.align,anchorHidden:oe.anchorHidden,nested:x.type===`menu`,instant:j},le=x.type===`menubar`&&x.context.modal;QD(T&&(le||E&&N!==`trigger-hover`),D===`touch`,A,O);let V=oE(e,ce,{styles:oe.positionerStyles,transitionStatus:k,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),H=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&N!==`trigger-hover`||x.type===`menubar`&&x.context.modal),ue=null;return x.type===`menubar`?ue=x.context.contentElement:x.type===void 0&&(ue=O),(0,Z.jsxs)(Ek.Provider,{value:oe,children:[H&&(0,Z.jsx)(LD,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:lE(!T),cutout:ue}),(0,Z.jsx)(PS,{id:P,children:(0,Z.jsx)(OD,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:V})})]})}),zk=W.createContext(null);function Bk(e){let t=W.useContext(zk);if(t===null&&!e)throw Error(F_(5));return t}var Vk={...Ww,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Hk=class extends mw{constructor(e,t,n=!1){let r=new Lw,i=Wk(r,t,n,e);super(i,Uk(r),Vk),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function Uk(e){return{positionerRef:W.createRef(),popupRef:W.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:W.createRef(),beforeContentFocusGuardRef:W.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Wk(e,t,n=!1,r){return{...Rw(e,t,n),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new OS,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:N_,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Gk=W.createContext(void 0);function Kk(){return W.useContext(Gk)}var qk=O_(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:l=`vertical`,actionsRef:u,closeParentOnEsc:d=!1,handle:f,triggerId:p,defaultTriggerId:m=null,highlightItemOnHover:h=!0}=e,g=Tk(!0),_=kk(!0),v=Bk(!0),y=Kk(),b=W.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=Lx(),S=Lx(),C=jS(),w=b.type===`menu`?b.store:void 0,T=(n??a)&&w?.state.transitionStatus===`starting`,E=C_(()=>T?w?.state.instantType:void 0).current,D=Jk({open:a,openProp:n,activeTriggerId:m,triggerIdProp:p,parent:b,disabled:o,highlightItemOnHover:h,modal:b.type===void 0?s:void 0,rootId:x,instantType:E},S,C!=null);D.useControlledProp(`openProp`,n),D.useControlledProp(`triggerIdProp`,p),D.useContextCallback(`onOpenChangeComplete`,i);let O=D.useState(`floatingTreeRoot`),k=NS(O),A=D.useState(`open`),j=D.useState(`activeTriggerElement`),M=D.useState(`positionerElement`),N=D.useState(`hoverEnabled`),P=D.useState(`disabled`),F=D.useState(`lastOpenChangeReason`),I=D.useState(`parent`),L=D.useState(`activeIndex`),R=D.useState(`payload`),ee=D.useState(`floatingParentNodeId`),z=W.useRef(null),te=W.useRef(I.type!==`context-menu`),ne=V_(),re=W.useRef(!0),B=V_(),ie=ee!=null,{openMethod:ae,triggerProps:oe}=rD(A);D.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:I.type===void 0?s:void 0,openMethod:ae,rootId:x}),Nw(D);let{forceUnmount:se,transitionStatus:ce}=Pw(A,D,()=>{D.set(`allowMouseEnter`,!1)},T),le=xw(D.context.popupRef);W.useEffect(()=>{if(E===void 0)return;let e=()=>{D.state.instantType===E&&D.set(`instantType`,void 0)};if(!A){e();return}if(ce!==void 0)return;if(D.context.popupRef.current==null){e();return}let t=new AbortController;return le(e,t.signal),()=>{t.abort()}},[E,A,ce,le,D]),X(()=>{g&&!_?D.update({parent:{type:`context-menu`,context:g},floatingNodeId:k,floatingParentNodeId:C}):_&&D.update({floatingNodeId:k,floatingParentNodeId:C})},[g,_,k,C,D]),W.useEffect(()=>{if(A||(z.current=null),I.type===`context-menu`){if(!A){ne.clear(),te.current=!1;return}ne.start(500,()=>{te.current=!0})}},[ne,A,I.type]),X(()=>{!A&&!N&&D.set(`hoverEnabled`,!0)},[A,N,D]);let V=Q((e,t)=>{let n=t.reason;if(!e&&!D.select(`open`)||A===e&&t.trigger===j&&F===n)return;let i=Aw(t);if(!e&&t.trigger==null&&(t.trigger=j??void 0),r?.(e,t),t.isCanceled)return;D.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!re.current)return;e&&n===`trigger-focus`?(re.current=!1,B.start(300,()=>{re.current=!0})):(re.current=!0,B.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);z.current=t.event;let c=kw(D.state,e,t.trigger,i());c.openChangeReason=n,c.instantType=I.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:o||s?o?`click`:`dismiss`:void 0,D.update(c)}),H=_w({popupStore:D,floatingRootContext:D.state.floatingRootContext,floatingId:S,nested:C!=null,onOpenChange:V}),ue=H.context.events;X(()=>{let e=({open:e,eventDetails:t})=>V(e,t);return ue.on(`setOpen`,e),()=>{ue?.off(`setOpen`,e)}},[ue,V]);let de=W.useCallback(()=>{D.setOpen(!1,Ry(Fy))},[D]);W.useImperativeHandle(u,()=>({unmount:se,close:de}),[se,de]);let fe;I.type===`context-menu`&&(fe=I.context),W.useImperativeHandle(fe?.positionerRef,()=>M,[M]),W.useImperativeHandle(fe?.actionsRef,()=>({setOpen:V}),[V]);let U=QS(H,{enabled:!P,bubbles:{escapeKey:d&&I.type===`menu`},outsidePress(){return I.type!==`context-menu`||z.current?.type===`contextmenu`||te.current},externalTree:ie?O:void 0}),pe=HT(),me=W.useCallback(e=>{D.select(`activeIndex`)!==e&&D.set(`activeIndex`,e)},[D]),he=fT(H,{enabled:!P,listRef:D.context.itemDomElements,activeIndex:L,nested:I.type!==void 0,loopFocus:c,orientation:l,parentOrientation:I.type===`menubar`?I.context.orientation:void 0,rtl:pe===`rtl`,disabledIndices:M_,onNavigate:me,openOnArrowKeyDown:I.type!==`context-menu`,externalTree:ie?O:void 0,focusItemOnHover:h}),ge=W.useCallback(e=>{D.context.typingRef.current=e},[D]),_e=pT(H,{enabled:!P,listRef:D.context.itemLabels,elementsRef:D.context.itemDomElements,activeIndex:L,resetMs:500,onMatch:e=>{A&&e!==L&&D.set(`activeIndex`,e)},onTyping:ge}),ve=W.useMemo(()=>{let e=Kx(_e.reference,he.reference,U.reference,{onMouseMove(){D.set(`allowMouseEnter`,!0)}},oe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=A,e},[D,_e.reference,he.reference,U.reference,oe,A]),ye=W.useMemo(()=>{let e=Kx(he.trigger,U.trigger,oe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[he.trigger,U.trigger,oe]);C_(()=>(D.update({inactiveTriggerProps:ye}),null)),Fw(D,{floatingRootContext:H,activeTriggerProps:ve,inactiveTriggerProps:ye,popupProps:W.useMemo(()=>Kx(Cw,{id:S,role:`menu`,"aria-orientation":l===`horizontal`?`horizontal`:void 0,"aria-labelledby":j?.id,onMouseMove(){D.set(`allowMouseEnter`,!0),I.type===`menu`&&D.set(`hoverEnabled`,!1)},onClick(){D.select(`hoverEnabled`)&&D.set(`hoverEnabled`,!1)},onKeyDown(e){let t=D.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},_e.floating,he.floating,U.floating),[j,S,l,I.type,D,_e.floating,he.floating,U.floating]),itemProps:he.item??N_});let be=W.useMemo(()=>({store:D,parent:b}),[D,b]),xe=(0,Z.jsxs)(Ok.Provider,{value:be,children:[f&&(0,Z.jsx)(Ew,{handle:f,store:D}),typeof t==`function`?t({payload:R}):t]});return I.type===void 0||I.type===`context-menu`?(0,Z.jsx)(FS,{externalTree:O,children:xe}):xe});function Jk(e,t,n){return C_(()=>new Hk(e,t,n)).current}function Yk(e){if(mv(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Ev(e))return Yk(kv(e))}function Xk(e,t){let n=W.useRef(null);function r(t){xS.flushSync(()=>{e.setOpen(!1,Ry(Oy,t.nativeEvent,t.currentTarget))}),px(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&mx(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{xS.flushSync(()=>{e.setOpen(!1,Ry(Oy,n.nativeEvent,n.currentTarget))});let i=fx(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Pv(r,i);){let e=i;if(i=lx(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Zk(e){let[t,n]=W.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=W.useRef(null),i=W.useRef(null),a=W.useRef(null),o=W.useRef(null),s=W.useRef(!0),c=W.useRef(null),l=Lx(),u=W.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,Z.jsx)(wk.Provider,{value:u,children:(0,Z.jsx)(Ok.Provider,{value:void 0,children:(0,Z.jsx)(qk,{...e})})})}var Qk=500,$k=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=Tk(!1),{store:m}=kk(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=W.useRef(null),v=W.useRef(null),y=V_(),b=V_(),x=W.useRef(!1),S=W.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,Ry(Sy,n)),b.start(Qk,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,nv(e),C(e.clientX,e.clientY,e.nativeEvent);let t=sb(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=Fv(e);Pv(u.current,t)||p&&t&&Yk(t)===p||s.current?.setOpen(!1,Ry(My,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(Qk,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return W.useEffect(()=>()=>{S.current?.abort()},[]),W.useEffect(()=>{function e(e){if(g)return;let t=Fv(e);(Pv(_.current,t)||Pv(c.current,t)||Pv(l.current,t))&&e.preventDefault()}return Hy(sb(_.current),`contextmenu`,e)},[l,g,c]),oS(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:iy})}),eA=Rk,tA=W.createContext(void 0);function nA(){let e=W.useContext(tA);if(e===void 0)throw Error(F_(53));return e}function rA(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var iA=`data-has-overflow-x`,aA=`data-has-overflow-y`,oA=`data-overflow-x-start`,sA=`data-overflow-x-end`,cA=`data-overflow-y-start`,lA=`data-overflow-y-end`,uA=e=>t=>t?{[e]:``}:null,dA={hasOverflowX:uA(iA),hasOverflowY:uA(aA),overflowXStart:uA(oA),overflowXEnd:uA(sA),overflowYStart:uA(cA),overflowYEnd:uA(lA),cornerHidden:()=>null},fA=`--scroll-area-corner-height`,pA=`--scroll-area-corner-width`,mA=`data-orientation`,hA={x:0,y:0},gA={width:0,height:0},_A={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},vA={x:!0,y:!0,corner:!0},yA=W.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=bA(i),d=OT(),f=V_(),p=V_(),{nonce:m,disableStyleElements:h}=vO(),[g,_]=W.useState(!1),[v,y]=W.useState(!1),[b,x]=W.useState(!1),[S,C]=W.useState(!1),[w,T]=W.useState(!1),[E,D]=W.useState(gA),[O,k]=W.useState(gA),[A,j]=W.useState(_A),[M,N]=W.useState(vA),P=W.useRef(null),F=W.useRef(null),I=W.useRef(null),L=W.useRef(null),R=W.useRef(null),ee=W.useRef(null),z=W.useRef(null),te=W.useRef(null),ne=W.useRef(0),re=W.useRef(0),B=W.useRef(0),ie=W.useRef(0),ae=W.useRef(`vertical`),oe=W.useRef(hA),se=W.useRef(null);function ce(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let le=Q(e=>{let t=e.x-oe.current.x,n=e.y-oe.current.y;oe.current=e,n!==0&&ce(!0),t!==0&&ce(!1)}),V=Q(()=>{let e=F.current;e&&se.current===null&&(se.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),H=Q(e=>{if(e.button!==0||te.current!==null&&(ae.current===`vertical`?R.current:ee.current)?.hasPointerCapture(te.current))return;te.current=e.pointerId,ne.current=e.clientY,re.current=e.clientX,ae.current=e.currentTarget.getAttribute(mA);let t=F.current;t&&(B.current=t.scrollTop,ie.current=t.scrollLeft,V()),(ae.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),ue=Q(e=>{if(e.pointerId!==te.current)return;te.current=null,(ae.current===`vertical`?x:y)(!1),se.current!==null&&(F.current&&(F.current.style.scrollSnapType=se.current),se.current=null);let t=ae.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),de=Q(e=>{if(e.pointerId!==te.current)return;if(e.buttons%2==0){ue(e);return}let t=F.current;if(!t)return;let n=ae.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=rA(i,`padding`,a),s=rA(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-ne.current:e.clientX-re.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?B.current:ie.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ce(n)});function fe(e){C(e.pointerType===`touch`)}function U(e){if(fe(e),e.pointerType!==`touch`){let t=Pv(P.current,e.target);_(t)}}let pe=W.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),me={role:`presentation`,onPointerEnter:U,onPointerMove:U,onPointerDown:fe,onPointerLeave(){_(!1)},style:{position:`relative`,[fA]:`${E.height}px`,[pA]:`${E.width}px`}},he=oS(`div`,e,{state:pe,ref:[t,P],props:[me,o],stateAttributesMapping:dA}),ge=W.useMemo(()=>({handlePointerDown:H,handlePointerMove:de,handlePointerUp:ue,handleScroll:le,disableViewportSnap:V,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:z,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:ee,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:pe,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[H,de,ue,le,V,E,O,w,S,v,b,g,d,M,A,pe,s,c,l,u]);return(0,Z.jsxs)(tA.Provider,{value:ge,children:[!h&&nO.getElement(m),he]})});function bA(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}var xA=W.createContext(void 0),SA=`--scroll-area-overflow-x-start`,CA=`--scroll-area-overflow-x-end`,wA=`--scroll-area-overflow-y-start`,TA=`--scroll-area-overflow-y-end`,EA=`--scroll-area-thumb-height`,DA=`--scroll-area-thumb-width`,OA=[SA,CA,wA,TA],kA=!1;function AA(){kA||$_||(typeof CSS<`u`&&`registerProperty`in CSS&&OA.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),kA=!0)}var jA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=nA(),T=HT(),E=W.useRef(!0),D=W.useRef([NaN,NaN,NaN,NaN]),O=V_(),k=V_(),A=Q(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=MA(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=oD(T===`rtl`?-w:w,P),L=P-I);let R=A?0:oD(x,F),ee=A?0:F-R,z=j?0:b,te=A?0:y,ne=0,re=0;!j&&!A&&(ne=t?.offsetWidth||0,re=n?.offsetHeight||0);let B=f.width===0&&f.height===0,ie=B?ne:0,ae=B?re:0,oe=rA(n,`padding`,`x`),se=rA(t,`padding`,`y`),ce=rA(i,`margin`,`x`),le=rA(r,`margin`,`y`),V=z-oe-ce,H=te-se-le,ue=n?Math.min(n.offsetWidth-ie,V):V,de=t?Math.min(t.offsetHeight-ae,H):H,fe=Math.max(16,ue*M),U=Math.max(16,de*N);if(m(e=>NA(e,{width:fe,height:U})),t&&r){let e=PA(r,EA,x,F,h,U,t.offsetHeight-U-se-le);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-fe-oe-ce,t=PA(i,DA,T===`rtl`?-w:w,P,_,fe,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let pe=[I,L,R,ee];OA.forEach((t,n)=>{e.style.setProperty(t,`${pe[n]}px`)}),a&&p(e=>NA(e,{width:ne,height:re})),g(e=>NA(e,k));let me={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>NA(e,me))});X(()=>{AA()},[]),X(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),X(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),X(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=e.getAnimations({subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished)).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={role:`presentation`,...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:nO.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=oS(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:dA}),P=W.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,Z.jsx)(xA.Provider,{value:P,children:N})});function MA(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function NA(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function PA(e,t,n,r,i,a,o){let s=iD(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var FA=W.createContext(void 0);function IA(){let e=W.useContext(FA);if(e===void 0)throw Error(F_(54));return e}var LA=W.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=nA(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=HT(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;W.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return Hy(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=Fv(e.nativeEvent),n=T?h.current:g.current;if(n&&Pv(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=rA(n,`margin`,a),s=rA(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onMouseDown(e){e.preventDefault()},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(${fA})`,insetInlineEnd:0,[EA]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${pA})`,bottom:0,[DA]:`${S.width}px`}}},M=oS(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:dA});return A?(0,Z.jsx)(FA.Provider,{value:i,children:M}):null}),RA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=nA(),m=IA(),h=m===`vertical`;return oS(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),zA=W.createContext(void 0);function BA(e){let t=W.useContext(zA);if(!e&&t===void 0)throw Error(F_(27));return t}var VA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=BA(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return oS(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:oy,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),HA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=BA(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=gD({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Ry(Dy,e.nativeEvent))}return oS(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),UA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=BA(),c=OT(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),oS(`p`,e,{ref:t,props:[{id:c},o]})}),WA=W.createContext(void 0);function GA(){let e=W.useContext(WA);if(e===void 0)throw Error(F_(26));return e}var KA=`--nested-dialogs`,qA=`data-nested-dialog-open`,JA={...ay,...Kv,nestedDialogOpen(e){return e?{[qA]:``}:null}},YA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=BA(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);GA(),Sw({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?ww(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=oS(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Cw,hidden:!m,onKeyDown(e){lO.has(e.key)&&e.stopPropagation()},style:{[KA]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:JA});return(0,Z.jsx)(GS,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),XA=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=BA(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Z.jsx)(WA.Provider,{value:n,children:(0,Z.jsxs)(ES,{ref:t,...r,children:[a&&o===!0&&(0,Z.jsx)(LD,{ref:i.context.internalBackdropRef,inert:lE(!s)}),e.children]})}):null});function ZA({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=W.useState(0),[u,d]=W.useState(0),f=c===0,p=QS(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Fv(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Pv(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return XD(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),X(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),Fw(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var QA={...Ww,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},$A=class extends mw{constructor(e,t,n){let r=new Lw,i=ej(e,r,t,n);super(i,tj(r),QA)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(kw(this.state,e,t.trigger)))}};function ej(e,t,n,r=!1){return{...Rw(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function tj(e){return{popupRef:W.createRef(),backdropRef:W.createRef(),internalBackdropRef:W.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function nj(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=BA(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Tw((e,t)=>new $A({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);Iw(b,x),Nw(b);let{forceUnmount:w}=Pw(x,b);W.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,Ry(Fy))}),[w,b]);let T=x||S;return(0,Z.jsxs)(zA.Provider,{value:b,children:[u&&(0,Z.jsx)(Ew,{handle:u,store:b}),T&&(0,Z.jsx)(ZA,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var rj=O_(function(e){return nj(`dialog`,e)}),ij=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=GA(),c=BA(),l=c.useState(`open`),u=c.useState(`nested`),d=c.useState(`transitionStatus`),f=c.useState(`nestedOpenDialogCount`),p=c.useState(`mounted`),m=c.useStateSetter(`viewportElement`);return oS(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:JA,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),aj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=BA(),c=OT(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),oS(`h2`,e,{ref:t,props:[{id:c},o]})}),oj=k_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=BA(!0),f=Gw(l)??d;if(!f)throw Error(F_(79));let p=OT(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=W.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=Mw(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=gD({disabled:a,native:o}),S=KS(m),C=nD(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return oS(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[mS]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:ry})}),sj=`--nested-drawers`,cj=`--drawer-height`,lj=`--drawer-frontmost-height`,uj=`--drawer-swipe-movement-x`,dj=`--drawer-swipe-movement-y`,fj=`--drawer-snap-point-offset`,pj=`--drawer-swipe-strength`,mj=`--drawer-swipe-progress`,hj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=BA(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return oS(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:oy,props:[{role:`presentation`,hidden:!u,style:{pointerEvents:c?void 0:`none`,userSelect:`none`,WebkitUserSelect:`none`,[mj]:`0`,[pj]:`1`}},o],enabled:a||!l})}),gj=HA,_j=`data-drawer-content`,vj=UA,yj=W.createContext(void 0);function bj(){return W.useContext(yj)}var xj=`data-expanded`,Sj=`data-nested-drawer-open`,Cj=`data-nested-drawer-swiping`,wj=`data-swipe-dismiss`,Tj=`data-swipe-direction`,Ej=`data-swiping`,Dj=W.createContext(void 0);function Oj(e){let t=W.useContext(Dj);if(e!==!0&&t===void 0)throw Error(F_(90));return t}function kj(e,t){let n=e+t;return n>=0?t:-Math.sqrt(-n)-e}function Aj(e,t,n){if(!Number.isFinite(t)||t<=0)return null;if(typeof e==`number`)return Number.isFinite(e)?e<=1?iD(e,0,1)*t:e:null;let r=e.trim();if(r.endsWith(`px`)){let e=Number.parseFloat(r);return Number.isFinite(e)?e:null}if(r.endsWith(`rem`)){let e=Number.parseFloat(r);return Number.isFinite(e)?e*n:null}return null}function jj(e,t){let n=-1,r=1/0;for(let i=0;i<e.length;i+=1){let a=Math.abs(e[i]-t);a<r&&(r=a,n=i)}return n}function Mj(){let e=BA(),{snapPoints:t,activeSnapPoint:n,setActiveSnapPoint:r,popupHeight:i}=Oj(),a=e.useState(`viewportElement`),[o,s]=W.useState(0),[c,l]=W.useState(16),u=Q(()=>{let e=sb(a).documentElement;s(a?a.offsetHeight:e.clientHeight);let t=parseFloat(getComputedStyle(e).fontSize);Number.isFinite(t)&&l(t)});X(()=>{if(u(),!a||typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(u);return e.observe(a),()=>{e.disconnect()}},[u,a]);let d=W.useMemo(()=>{if(!t||t.length===0||o<=0||i<=0)return[];let e=Math.min(i,o),n=t.map(t=>{let n=Aj(t,o,c);if(n===null)return null;let r=iD(n,0,e);return{value:t,height:r,offset:Math.max(0,i-r)}}).filter(e=>!!e);if(n.length<=1)return n;let r=[],a=[];for(let e=n.length-1;e>=0;--e){let t=n[e];a.some(e=>Math.abs(e-t.height)<=1)||(a.push(t.height),r.push(t))}return r.reverse(),r},[i,c,t,o]);return{snapPoints:t,activeSnapPoint:n,setActiveSnapPoint:r,popupHeight:i,viewportHeight:o,resolvedSnapPoints:d,activeSnapPointOffset:W.useMemo(()=>{if(n===null)return;let e=d.find(e=>Object.is(e.value,n));if(e)return e;let t=Math.min(i,o),r=Aj(n,o,c);if(r===null)return;let a=iD(r,0,t);return d[jj(d.map(e=>e.height),a)]},[n,i,d,c,o])?.offset??null}}var Nj=W.createContext(null);function Pj(){return W.useContext(Nj)}var Fj=!1;function Ij(){Fj||=(typeof CSS<`u`&&`registerProperty`in CSS&&([uj,dj,fj].forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),[{name:mj,initialValue:`0`},{name:pj,initialValue:`1`}].forEach(({name:e,initialValue:t})=>{try{CSS.registerProperty({name:e,syntax:`<number>`,inherits:!1,initialValue:t})}catch{}})),!0)}var Lj={...oy,expanded(e){return e?{[xj]:``}:null},nestedDrawerOpen(e){return e?{[Sj]:``}:null},nestedDrawerSwiping(e){return e?{[Cj]:``}:null},swipeDirection(e){return{[Tj]:e}},swiping(e){return e?{[Ej]:``}:null}},Rj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=BA(),l=c.context.popupRef,{swipeDirection:u,frontmostHeight:d,hasNestedDrawer:f,nestedSwiping:p,nestedSwipeProgressStore:m,onPopupHeightChange:h,notifyParentFrontmostHeight:g,notifyParentHasNestedDrawer:_}=Oj(),v=c.useState(`descriptionElementId`),y=c.useState(`disablePointerDismissal`),b=c.useState(`floatingRootContext`),x=c.useState(`popupProps`),S=c.useState(`modal`),C=c.useState(`mounted`),w=c.useState(`nested`),T=c.useState(`nestedOpenDrawerCount`),E=c.useState(`transitionStatus`),D=c.useState(`open`),O=c.useState(`openMethod`),k=c.useState(`titleElementId`),A=c.useState(`role`),j=b.useState(`floatingId`),M=s.id??j,N=Pj();GA();let{snapPoints:P,activeSnapPoint:F,activeSnapPointOffset:I}=Mj(),L=T>0,R=N?.swiping??!1,ee=N?.swipeStrength??null,[z,te]=W.useState(0),ne=W.useRef(0),re=Q(()=>{let e=l.current;if(!e)return;let t=e.offsetHeight;if(ne.current>0&&d>ne.current&&t>ne.current)return;if(ne.current>0&&f){let e=ne.current;te(e),h(e);return}let n=t;n!==ne.current&&(ne.current=n,te(n),h(n))});X(()=>{if(!C){ne.current=0,te(0),h(0);return}let e=l.current;if(!e||(Ij(),re(),typeof ResizeObserver!=`function`))return;let t=new ResizeObserver(re);return t.observe(e),()=>{t.disconnect()}},[re,C,L,h,l]),X(()=>{let e=()=>{let e=l.current;if(!e)return;let t=m.getSnapshot();t>0?e.style.setProperty(mj,`${t}`):e.style.setProperty(mj,`0`)};e();let t=m.subscribe(e),n=l.current;return()=>{t(),n&&n.style.setProperty(mj,`0`)}},[m,l]),X(()=>{if(D)return g?.(d),()=>{g?.(0)}},[d,D,g]),X(()=>{if(_)return _(D||E===`ending`),()=>{_(!1)}},[_,D,E]),Sw({open:D,ref:l,onComplete(){D&&c.context.onOpenChangeComplete?.(!0)}});let B=o===void 0?l:o,ie=c.useStateSetter(`popupElement`),ae={open:D,nested:w,transitionStatus:E,expanded:F===1,nestedDrawerOpen:L,nestedDrawerSwiping:p,swipeDirection:u,swiping:R},oe;z&&(f||E===`ending`)&&(oe=`${z}px`);let se=P&&P.length>0&&(u===`down`||u===`up`),ce=null;se&&I!==null&&(ce=u===`up`?-I:I);let le=N?N.getDragStyles():N_;if(se&&u===`down`){let e=I??0,t=Number.parseFloat(String(le[dj]));le=R&&Number.isFinite(t)?{...le,transform:void 0,[dj]:`${kj(e,t)}px`}:{...le,transform:void 0}}let V=oS(`div`,e,{state:ae,props:[x,{id:M,"aria-labelledby":k,"aria-describedby":v,role:A,...Cw,hidden:!C,onKeyDown(e){lO.has(e.key)&&e.stopPropagation()},style:{...le,[mj]:`0`,[sj]:T,[cj]:oe,[fj]:typeof ce==`number`?`${ce}px`:`0px`,[lj]:d?`${d}px`:void 0,[pj]:typeof ee==`number`&&Number.isFinite(ee)&&ee>0?`${ee}`:`1`}},s],ref:[t,l,ie],stateAttributesMapping:Lj});return(0,Z.jsx)(GS,{context:b,openInteractionType:O,disabled:!C,closeOnFocusOut:!y,initialFocus:B,returnFocus:a,modal:S!==!1,restoreFocus:`popup`,children:V})}),zj=XA,Bj,Vj;function Hj(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null,swipeDirection:f=`down`,snapToSequentialPoints:p=!1,snapPoints:m,snapPoint:h,defaultSnapPoint:g,onSnapPointChange:_}=e,v=Oj(!0),y=v?.onNestedSwipeProgressChange,b=v?.onNestedFrontmostHeightChange,x=v?.onNestedSwipingChange,S=v?.onNestedDrawerPresenceChange,[C,w]=W.useState(0),[T,E]=W.useState(0),[D,O]=W.useState(!1),[k,A]=W.useState(!1),[j]=W.useState(Uj),M=g===void 0?m?.[0]??null:g,N=h!==void 0,[P,F]=pE({controlled:h,default:M,name:`Drawer`,state:`snapPoint`}),I=W.useRef(!1),L=W.useRef(!1),R=Q((e,t)=>{let n=t??Ry(`none`);_?.(e,n),!n.isCanceled&&F(e)}),ee=W.useMemo(()=>N||!m||m.length===0?P:P===null||!m.some(e=>Object.is(e,P))?M:P,[P,N,M,m]),z=Q(e=>{w(e),!I.current&&e>0&&E(e)}),te=Q(e=>{if(e>0){I.current=!0,E(e);return}I.current=!1,C>0&&E(C)}),ne=Q(e=>{O(e)}),re=Q(e=>{j.set(e),y?.(e)}),B=Q(e=>{A(e),x?.(e)}),ie=Q((e,t)=>{i?.(e,t),!t.isCanceled&&!e&&m&&m.length>0&&R(M,Ry(t.reason,t.event,t.trigger))}),ae=W.useMemo(()=>({swipeDirection:f,swipeAreaActiveRef:L,snapToSequentialPoints:p,snapPoints:m,activeSnapPoint:ee,setActiveSnapPoint:R,frontmostHeight:T,popupHeight:C,hasNestedDrawer:D,nestedSwiping:k,nestedSwipeProgressStore:j,onNestedDrawerPresenceChange:ne,onPopupHeightChange:z,onNestedFrontmostHeightChange:te,onNestedSwipingChange:B,onNestedSwipeProgressChange:re,notifyParentFrontmostHeight:b,notifyParentSwipingChange:x,notifyParentSwipeProgressChange:y,notifyParentHasNestedDrawer:S}),[ee,T,D,k,j,S,y,x,b,ne,te,re,B,z,C,R,m,p,L,f]),oe=nj(`drawer`,{open:n,defaultOpen:r,onOpenChange:ie,onOpenChangeComplete:a,disablePointerDismissal:o,modal:s,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d,children:typeof t==`function`?e=>(0,Z.jsxs)(W.Fragment,{children:[Bj||=(0,Z.jsx)(Wj,{}),t(e)]}):(0,Z.jsxs)(W.Fragment,{children:[Vj||=(0,Z.jsx)(Wj,{}),t]})});return(0,Z.jsx)(Dj.Provider,{value:ae,children:oe})}function Uj(){let e=0,t=new Set;return{getSnapshot:()=>e,set(n){let r=Number.isFinite(n)?n:0;r!==e&&(e=r,t.forEach(e=>{e()}))},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function Wj(){let e=bj(),t=BA(!1),n=e?.setDrawerOpen,r=e?.removeDrawer,i=t.useState(`open`),a=t.useState(`nestedOpenDialogCount`),o=t.useState(`popupElement`),s=a===0;return X(()=>{if(r)return()=>{r(t)}},[r,t]),X(()=>{n?.(t,i)},[i,n,t]),W.useEffect(()=>{if(!i||!s||!X_)return;let e=uv(o).CloseWatcher;if(!e)return;function n(e){t.select(`open`)&&t.setOpen(!1,Ry(Ay,e))}let r=new e,a=Hy(r,`close`,n);return()=>{a(),r.destroy()}},[t,s,i,o]),null}function Gj(e,t=!1){let{overflowY:n}=Dv(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function Kj(e,t=!1){let{overflowX:n}=Dv(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientWidth>0:e.scrollWidth>e.clientWidth}function qj(e,t,n=!1){return t===`vertical`?Gj(e,n):Kj(e,n)}function Jj(e,t,n){let r=e;for(;mv(r)&&r!==t&&!Ev(r);){for(let e of n)if(qj(r,e))return!0;r=kv(r)}return!1}function Yj(e,t,n=`vertical`,r=!1){let i=mv(e)?e:null;for(;mv(i)&&i!==t&&!Ev(i);){if(qj(i,n,r))return i;i=kv(i)}return qj(t,n,r)?t:null}function Xj(e,t,n){return typeof e?.elementFromPoint==`function`?e.elementFromPoint(t,n):null}function Zj(e,t){let n=(t??uv(e).getComputedStyle(e)).transform,r=0,i=0,a=1;if(n&&n!==`none`){let e=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(r=t[4],i=t[5],a=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(r=t[12],i=t[13],a=t[0])}}return{x:r,y:i,scale:a}}var Qj=40,$j=10,eM=1,tM=50,nM=16,rM=80,iM=`button,a,input,select,textarea,label,[role="button"]`;function aM(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function oM(e){return Number.isFinite(e)&&e>0?e:null}function sM(e,t){return`translate3d(${e.x}px,${e.y}px,0) scale(${t})`}function cM(e){return e%2==1}function lM(e,t,n){let r=e[n];if(typeof r==`function`)try{r.call(e,t)}catch(e){if(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`)return;throw e}}function uM(e){let{enabled:t,directions:n,elementRef:r,movementCssVars:i,canStart:a,ignoreSelectorWhenTouch:o=!0,ignoreScrollableAncestors:s=!1,swipeThreshold:c,onDismiss:l,onProgress:u,onCancel:d,onSwipeStart:f,onRelease:p,onSwipingChange:m,trackDrag:h=!0}=e,g=iM,_=n.length===1?n[0]:void 0,v=Math.max(0,typeof c==`number`?c:Qj),y=n.includes(`left`),b=n.includes(`right`),x=n.includes(`up`),S=n.includes(`down`),C=y||b,w=x||S,T=W.useMemo(()=>{let e=[];return w&&e.push(`vertical`),C&&e.push(`horizontal`),e},[C,w]),[E,D]=W.useState(void 0),[O,k]=W.useState(!1),[A,j]=W.useState(!1),M=W.useRef({x:0,y:0}),N=W.useRef({x:0,y:0}),P=W.useRef(null),F=W.useRef({x:0,y:0,scale:1}),I=W.useRef(void 0),L=W.useRef(0),R=W.useRef(!1),ee=W.useRef({x:0,y:0}),z=W.useRef(null),te=W.useRef(!1),ne=W.useRef(!1),re=W.useRef(null),B=W.useRef(!1),ie=W.useRef(!1),ae=W.useRef({width:0,height:0}),oe=W.useRef(0),se=W.useRef(v),ce=W.useRef(null),le=W.useRef(null),V=W.useRef(null),H=W.useRef({x:0,y:0}),ue=W.useRef(null),de=W.useRef(!1),fe=W.useRef(null),U=Q(e=>{de.current!==e&&(de.current=e,k(e),m?.(e))});function pe(e){if(!e)return;let t=r.current,n=ce.current;if(!t||!n)return;let i=n({element:t,direction:e});se.current=Math.max(0,i)}let me=Q((e,t)=>{let n=Number.isFinite(e)?iD(e,0,1):0,r=n!==oe.current,i=!1;if(t){let e=ue.current;i=!e||e.deltaX!==t.deltaX||e.deltaY!==t.deltaY||e.direction!==t.direction}(r||i)&&(oe.current=n,t?ue.current=t:r&&(ue.current=null),u?.(n,t))}),he=Q(e=>{let t=r.current;if(!h||!t){e||(fe.current=null);return}let n=t.style,a=fe.current;e?(a||(fe.current=[n.transition,n.transform]),n.transition=`none`):a&&([n.transition,n.transform]=a,fe.current=null);let o=N.current,s=F.current,c=o.x-s.x,l=o.y-s.y;e&&(n.transform=sM(o,s.scale)),n.setProperty(i.x,`${c}px`),n.setProperty(i.y,`${l}px`)});function ge(e,t){if(t===null)return;let n=V.current;if(n&&t>n.time){let r=Math.max(t-n.time,nM);H.current={x:(e.x-n.x)/r,y:(e.y-n.y)/r}}V.current={x:e.x,y:e.y,time:t}}let _e=W.useCallback(()=>{D(void 0),U(!1),j(!1),me(0),se.current=v,ce.current=null,M.current={x:0,y:0},N.current={x:0,y:0},F.current={x:0,y:0,scale:1},I.current=void 0,L.current=0,R.current=!1,ee.current={x:0,y:0},z.current=null,te.current=!1,P.current=null,ne.current=!1,re.current=null,B.current=!1,ie.current=!1,ae.current={width:0,height:0},le.current=null,V.current=null,H.current={x:0,y:0},ue.current=null,he(!1)},[U,v,he,me]);function ve(e){if(`touches`in e){let t=e.touches[0];return t?{x:t.clientX,y:t.clientY}:null}return{x:e.clientX,y:e.clientY}}function ye(e){return`touches`in e||e.pointerType===`touch`}function be(e,t){let n=r.current?.getRootNode();return Xj(n,e.x,e.y)??Fv(t)}function xe(e,t){let n=n=>{let r=Yj(e,t,n),i=sb(r);return r===i.body||r===i.documentElement?null:r};return C&&!w?n(`horizontal`):w&&!C?n(`vertical`):n(`vertical`)??n(`horizontal`)}function Se(e,t,n){B.current=!1;let i=ye(e),a=be(t,e.nativeEvent),l=sb(r.current).body,u=i&&l?xe(a,l):null,d=n?.ignoreScrollableTarget??!1;if(u&&!d||(B.current=!!(u&&d),a&&a.closest(g)&&(!i||o)))return!1;let p=r.current;if(s&&p&&a&&T.length>0&&!(n?.ignoreScrollableAncestors??!1)&&Jj(a,p,T))return!1;if(R.current=!1,I.current=void 0,L.current=0,M.current=t,le.current=oM(e.timeStamp),ee.current=t,P.current=t,se.current=v,ce.current=typeof c==`function`?c:null,p){ae.current={width:p.offsetWidth,height:p.offsetHeight},pe(_);let t=Zj(p);F.current=t,N.current={x:t.x,y:t.y},ge({x:t.x,y:t.y},le.current),`touches`in e||lM(p,e.pointerId,`setPointerCapture`)}return f?.(e.nativeEvent),U(!0),z.current=null,te.current=!0,me(0),he(!0),!0}function Ce(){we(),B.current=!1,P.current=null}function we(){ne.current=!1,re.current=null}function Te(e){if(Ce(),!de.current)return;U(!1),z.current=null;let t=F.current;N.current={x:t.x,y:t.y},D(void 0),ie.current=!1,he(!1);let n=r.current;n&&lM(n,e.pointerId,`releasePointerCapture`),me(0,{deltaX:0,deltaY:0,direction:void 0}),d?.(e.nativeEvent)}function Ee(e,t){let n=e=>Math.sign(e)*Math.abs(e)**.5,r=(e,t,r)=>!t&&e<0||!r&&e>0?n(e):e;return{x:C?r(e,y,b):n(e),y:w?r(t,x,S):n(t)}}function De(e,t,n){let r=(e,t,n,r,i)=>e>0&&t<=0&&r||e<0&&t>=Math.max(0,n)&&i,i=Math.abs(t),a=Math.abs(n);return w&&n!==0&&(!C||a>=i)?r(n,e.scrollTop,e.scrollHeight-e.clientHeight,S,x):C&&t!==0&&(!w||i>a)?r(t,e.scrollLeft,e.scrollWidth-e.clientWidth,b,y):null}let Oe=Q(e=>{if(!t||e.defaultPrevented||e.nativeEvent.defaultPrevented||!(`touches`in e)&&e.button!==0)return;let n=ve(e);n&&(ne.current=!0,re.current=n,B.current=!1,ie.current=!(`touches`in e),(!a||a(n,{nativeEvent:e.nativeEvent,direction:_}))&&Se(e,n)&&we())});function ke(e,n,r){if(!t||!de.current)return;let i=Fv(e.nativeEvent);if(ye(e)&&!B.current){let t=e.currentTarget;if(xe(i,t))return}if(`touches`in e||e.preventDefault(),te.current&&(te.current=!1,h)){M.current=n;let t=oM(e.timeStamp);t!==null&&(le.current=t)}let a=n.x,o=n.y,s=r.x,c=r.y;(c<0&&o>ee.current.y||c>0&&o<ee.current.y)&&(ee.current={x:ee.current.x,y:o}),(s<0&&a>ee.current.x||s>0&&a<ee.current.x)&&(ee.current={x:a,y:ee.current.y});let l=a-M.current.x,u=o-M.current.y,d=o-ee.current.y,f=a-ee.current.x,p=z.current;p===null&&C&&w&&Math.sqrt(l*l+u*u)>=eM&&(p=Math.abs(l)>Math.abs(u)?`horizontal`:`vertical`,z.current=p);let m;if(!I.current)p===`vertical`?u>0?m=`down`:u<0&&(m=`up`):p===`horizontal`?l>0?m=`right`:l<0&&(m=`left`):m=Math.abs(l)>=Math.abs(u)?l>0?`right`:`left`:u>0?`down`:`up`,m&&(m===`left`&&y||m===`right`&&b||m===`up`&&x||m===`down`&&S)&&(I.current=m,L.current=aM(m,l,u),D(m),pe(m));else{let e=I.current,t=aM(e,f,d);t>se.current?(R.current=!1,D(e)):!(y&&b)&&!(x&&S)&&L.current-t>=$j&&(R.current=!0)}let g=Ee(l,u),v=F.current.x,T=F.current.y;p===`horizontal`?C&&(v+=g.x):(p===`vertical`||C&&(v+=g.x),w&&(T+=g.y));let E=N.current,O=v!==E.x||T!==E.y;N.current={x:v,y:T},O&&he(!0),ge({x:v,y:T},oM(e.timeStamp));let k=v-F.current.x,A=T-F.current.y,j={deltaX:k,deltaY:A,direction:I.current},P=0,ne=_??I.current;if(ne){let e=ne===`left`||ne===`right`?ae.current.width:ae.current.height,t=F.current.scale||1,n=aM(ne,k,A);e>0&&t>0&&n>0&&(P=n/(e*t))}me(P,j)}let Ae=Q(e=>{if(!t)return;let i=N.current,a=F.current,o=i.x-a.x,s=i.y-a.y,c={deltaX:o,deltaY:s,direction:I.current};if(!de.current){Ce(),me(0,c);return}U(!1),z.current=null,Ce(),ie.current=!1;let u=r.current;u&&(`touches`in e||lM(u,e.pointerId,`releasePointerCapture`));let d=o,f=s,m=le.current,h=oM(e.timeStamp),g=m!==null&&h!==null&&h>m?h-m:0,v=g>0?Math.max(g,tM):0,y=v>0?d/v:0,b=v>0?f/v:0,x=H.current.x,S=H.current.y,C=V.current;if(C&&h!==null&&h>=C.time){let e=h-C.time;if(e<=rM){let t=Math.max(e,nM),n=i.x-C.x,r=i.y-C.y,a=n/t,o=r/t;a!==0&&(x=a),o!==0&&(S=o)}else x=0,S=0}let w=p?.({event:e.nativeEvent,direction:I.current,deltaX:d,deltaY:f,velocityX:y,velocityY:b,releaseVelocityX:x,releaseVelocityY:S}),T=typeof w==`boolean`;if(R.current&&!T){N.current={x:a.x,y:a.y},D(void 0),he(!1),me(0,c);return}let E=!1,O;if(T)E=w,O=I.current??_;else for(let e of n)if(aM(e,d,f)>se.current){E=!0,O=e;break}E&&O?(D(O),j(!0),he(!1),l?.(e.nativeEvent,{direction:O})):(N.current={x:a.x,y:a.y},D(void 0),he(!1),me(0,c))}),je=Q(e=>{let t=ve(e);if(!t)return;let n=!1;if(!(`touches`in e)){let t=cM(e.buttons);if(t&&(ie.current=!0),e.buttons!==0&&!t){Te(e);return}if(e.buttons===0&&ie.current){if(!de.current){Ae(e);return}n=!0}}if(!O&&ne.current){if(!ye(e)&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)){Ce();return}if(!a||a(t,{nativeEvent:e.nativeEvent,direction:_})){let n=re.current,i=!1;if(ye(e)){let a=r.current;if(n&&a){let r=be(t,e.nativeEvent),o=sb(a).body,s=o?xe(r,o):null;if(s&&(Pv(a,s)||Pv(s,a))){let e=De(s,t.x-n.x,t.y-n.y);if(e===!1)return;e===!0&&(i=!0)}}}Se(e,t,{ignoreScrollableTarget:i,ignoreScrollableAncestors:i})&&(n&&i?(we(),M.current=n,ee.current=n,P.current=n,te.current=!1):(we(),B.current=!1))}}let i=P.current,o=i===null?{x:0,y:0}:{x:t.x-i.x,y:t.y-i.y};P.current=t,ke(e,t,o),n&&!(`touches`in e)&&Ae(e)}),Me=Q((e,t)=>{je({touches:e.touches,currentTarget:t,nativeEvent:e,defaultPrevented:e.defaultPrevented,timeStamp:e.timeStamp})}),Ne=W.useCallback(()=>{let e=de.current,t=N.current,n=F.current,r=t.x-n.x,a=t.y-n.y;return!e&&r===0&&a===0&&!A?{[i.x]:`0px`,[i.y]:`0px`}:{transition:e?`none`:void 0,transform:e?sM(t,n.scale):void 0,[i.x]:`${r}px`,[i.y]:`${a}px`}},[A,i]);return{swiping:O,swipeDirection:E,dragDismissed:A,getPointerProps:W.useCallback(()=>t?{onPointerDown:Oe,onPointerMove:je,onPointerUp:Ae,onPointerCancel:Ae}:{},[t,Ae,je,Oe]),getTouchProps:W.useCallback(()=>t?{onTouchStart:Oe,onTouchMove:je,onTouchEnd:Ae,onTouchCancel:Ae}:{},[t,Ae,je,Oe]),moveNative:Me,getDragStyles:Ne,reset:_e}}var dM=aj,fM=`data-nested-dialog-open`,pM=W.createContext(void 0);function mM(){return W.useContext(pM)}var hM=10,gM=.5,_M=.5,vM=300,yM=4,bM=.2,xM=4,SM=80,CM=360,wM=.1,TM=6,EM=2,DM=`[${_j}]`,OM=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=BA(),c=s.context.popupRef,l=s.context.backdropRef,{swipeDirection:u,notifyParentSwipingChange:d,notifyParentSwipeProgressChange:f,frontmostHeight:p,snapToSequentialPoints:m,swipeAreaActiveRef:h}=Oj(),g=bj(),{snapPoints:_,resolvedSnapPoints:v,activeSnapPoint:y,activeSnapPointOffset:b,setActiveSnapPoint:x,popupHeight:S}=Mj(),C=s.useState(`open`),w=s.useState(`mounted`),T=s.useState(`nested`),E=s.useState(`nestedOpenDrawerCount`),D=s.useState(`viewportElement`),O=s.useState(`popupElement`),k=g?.visualStateStore,A=E>0,j=u===`left`||u===`right`?`horizontal`:`vertical`,M=j===`vertical`,N=M?`horizontal`:`vertical`,[P,F]=W.useState(null),I=W.useRef(void 0),L=W.useRef(null),R=ob(),ee=W.useRef(!1),z=W.useRef(!1),te=W.useRef(``),ne=W.useRef(!1),re=W.useRef(!1),B=W.useRef(null),ie=mM(),ae=W.useMemo(()=>{if(!_||_.length<2||v.length<2||u!==`down`&&u!==`up`)return null;let e=v.map(e=>e.offset).sort((e,t)=>e-t),t=e[0];return{minOffset:t,range:e[1]-t}},[v,_,u]),oe=W.useMemo(()=>!ae||b===null?null:iD((b-ae.minOffset)/ae.range,0,1),[b,ae]),se=W.useMemo(()=>_&&_.length>0&&(u===`down`||u===`up`)?u===`down`?[`down`,`up`]:[`up`,`down`]:[u],[_,u]),ce=Q(e=>{c.current?.toggleAttribute(wj,e),l.current?.toggleAttribute(wj,e)}),le=Q(()=>{ce(!1),c.current?.removeAttribute(Uv),F(null)}),V=Q(()=>{z.current&&(z.current=!1,d?.(!1))}),H=Q((e,t,n)=>{let r=C&&!T&&t,i=r?e:0,a=C&&t?e:0;n&&f&&(f(a),a<=0&&V()),k?.set({swipeProgress:i,frontmostHeight:i>0?p:0});let o=l.current;if(!o)return;let s=r&&i>0;o.style.setProperty(mj,s?`${i}`:`0`),s&&p>0?o.style.setProperty(cj,`${p}px`):o.style.removeProperty(cj)});function ue(e,t,n,r,i,a,o,s){let c=MM(e,t);if(c<=0)return null;let l=((t===`down`||t===`up`)&&_&&_.length>0?b??0:0)+aM(t,n,r),u=Math.max(0,c-l);if(u<=0)return null;let d=aM(t,o,s),f=Math.abs(d)>0?d:aM(t,i,a);return f<=bM?null:wM+(iD(u/iD(f,bM,xM),SM,CM)-SM)/280*.9}function de(e){if(z.current||!e)return;let t=aM(e.direction??u,e.deltaX,e.deltaY);Math.abs(t)<hM||(z.current=!0,d?.(!0))}let fe=uM({enabled:w&&!A,directions:se,elementRef:s.context.popupRef,ignoreSelectorWhenTouch:!1,ignoreScrollableAncestors:!0,movementCssVars:{x:uj,y:dj},onSwipeStart(e){if(`touches`in e||e.pointerType===`touch`)return;let t=c.current,n=sb(t).getSelection?.();if(!n||n.isCollapsed)return;let r=pv(n.anchorNode)?n.anchorNode:n.anchorNode?.parentElement,i=pv(n.focusNode)?n.focusNode:n.focusNode?.parentElement;(Pv(t,r)||Pv(t,i))&&n.removeAllRanges()},onSwipingChange(e){ee.current=e,kM(s.context.backdropRef.current,e),!e&&!f&&V()},swipeThreshold({element:e,direction:t}){return NM(e,t)},canStart(e,t){let n=s.context.popupRef.current;if(!n)return!1;let r=n.ownerDocument,i=Xj(n.getRootNode(),e.x,e.y);if(!i||!Pv(n,i))return!1;let a=t.nativeEvent;return!((`touches`in a||a.pointerType===`touch`)&&LM(r,n))},onProgress(e,t){let n=ee.current;n&&de(t);let r=!!(_&&_.length>0);if(n&&u===`down`&&r&&t){let e=s.context.popupRef.current;e&&(e.style.removeProperty(`transform`),e.style.setProperty(dj,`${kj(b??0,t.deltaY)}px`))}let i=e;if(ae&&S>0){let e=b??ae.minOffset;n&&t&&Number.isFinite(t.deltaY)?i=(e=>iD((e-ae.minOffset)/ae.range,0,1))(iD(e+t.deltaY,0,S)):oe!==null&&(i=oe)}n||(f?.(0),V()),H(i,!0,n)},onRelease({event:e,deltaX:t,deltaY:n,direction:r,velocityX:i,velocityY:a,releaseVelocityX:o,releaseVelocityY:c}){let l=s.context.popupRef.current;if(!l){le();return}let d=l;function f(e){V(),ce(!0),d.style.removeProperty(`transition`),d.setAttribute(Uv,``),xS.flushSync(()=>{F(ue(d,e,t,n,i,a,o,c))})}if(!_||_.length===0){if(!r){le();return}let e=aM(r,t,n);if(e<=0)return le(),!1;if(aM(r,i,a)>=gM)return f(r),!0;let o=e>NM(d,r);return o?f(r):le(),o}if(u!==`down`&&u!==`up`){le();return}if(!S)return le(),!1;if(v.length===0){le();return}let p=u===`down`?n:-n,h=Math.sign(p),g=u===`down`?c:-c,C=u===`down`?a:-a,w=g;if(h!==0&&Math.abs(p)>=hM){let e=Math.sign(w);e!==0&&e!==h&&(w=C)}let T=b??0,E=iD(T+p,0,S),D=Math.abs(w)>=_M?iD(w,-4,yM)*vM:0,O=m?E:iD(E+D,0,S),k=Ry(Iy,e),A=()=>(H(0,!0,!0),le(),!1),j=e=>(x(e.value,k),A()),M=e=>r?(x(null,k),k.isCanceled?A():(I.current=y,f(u),!0)):j(e);if(m){let e=[...v].sort((e,t)=>e.offset-t.offset),t=e.map(e=>e.offset),n=jj(t,T),r=e[jj(t,O)],i=Math.sign(w),a=h!==0&&i!==0&&i===h&&Math.abs(w)>=_M,o=O;if(a){let t=iD(n+h,0,e.length-1);if(t!==n){let n=e[t];(h>0?O<n.offset:O>n.offset)&&(r=n,o=n.offset)}else if(h>0)return M(r)}return Math.abs(o-S)<Math.abs(o-r.offset)?M(r):j(r)}let N=v[jj(v.map(e=>e.offset),O)];return w>=gM&&p>0||Math.abs(O-S)<Math.abs(O-N.offset)?M(N):j(N)},onDismiss(e){k?.set({swipeProgress:0,frontmostHeight:0});let t=s.context.backdropRef.current;t&&(t.style.setProperty(mj,`0`),t.style.removeProperty(cj));let n=Ry(Iy,e);if(s.setOpen(!1,n),n.isCanceled){let t=I.current;t!==void 0&&x(t,Ry(Iy,e)),I.current=void 0,L.current?.(),le();return}if(s.select(`open`)){let t=e;R.request(()=>{if(s.select(`open`)){let e=I.current;e!==void 0&&x(e,Ry(Iy,t)),I.current=void 0,le(),L.current?.()}else I.current=void 0});return}I.current=void 0,ce(!0)}}),U=fe.getPointerProps(),pe=fe.getTouchProps(),{moveNative:me,reset:he}=fe;L.current=he,W.useEffect(()=>{let e=D??O;if(!e)return;let t=e,n=sb(t);function r(e,r,i){let a=M?i.clientY-r.lastY:i.clientX-r.lastX;if(e.touches.length===2||LM(n,t)||!C||!w||A||VM(r,e,i,M))return;let o=r.scrollTarget;if(!o||o===n.documentElement||o===n.body){e.cancelable&&e.preventDefault(),e.stopPropagation(),me(e,t);return}if(!HM(o,j)){e.cancelable&&e.preventDefault(),e.stopPropagation();return}if(a!==0){let t=GM(o,j,u,a);r.allowSwipe?e.cancelable&&e.preventDefault():e.cancelable&&t?(r.allowSwipe=!0,e.preventDefault()):r.allowSwipe=!1}r.allowSwipe===!0&&(e.stopPropagation(),me(e,t))}function i(e){if(ie?.onTouchMove(e),re.current)return;let t=B.current,n=e.touches[0];n&&t&&(r(e,t,n),BM(t,n))}return Hy(n,`touchmove`,i,{passive:!1,capture:!0})},[w,A,C,O,M,j,u,me,D,ie]),X(()=>{ae&&!fe.swiping&&H(!C||T?0:oe??0,!0,!1)},[H,p,T,f,C,oe,ae,fe.swiping,s,k]),X(()=>{if(f)return C||f(0),()=>{f(0)}},[f,C]),X(()=>{C&&(h.current||he(),le())},[le,C,he,h]),X(()=>{let e=l.current;return()=>{k?.set({swipeProgress:0,frontmostHeight:0}),kM(e,!1);let t=l.current;t!==e&&kM(t,!1),V()}},[l,V,k]);let ge=W.useMemo(()=>({swiping:fe.swiping,getDragStyles:fe.getDragStyles,swipeStrength:P??null,setSwipeDismissed:ce}),[ce,fe.getDragStyles,fe.swiping,P]);function _e(e){re.current=e,B.current=null}function ve(){_e(!1),te.current=``,ne.current=!1}function ye(e){return te.current=``,e.pointerType!==`touch`}return(0,Z.jsx)(ij,{ref:t,className:r,style:i,render:n,...Kx(o,{onPointerDown(e){if(te.current=e.pointerType,ne.current=e.pointerType===`pen`,!C||!w||A)return;let t=Xj(e.currentTarget.getRootNode(),e.clientX,e.clientY);AM(t)||jM(t)||e.pointerType!==`touch`&&U.onPointerDown?.(e)},onPointerMove(e){e.pointerType!==`touch`&&U.onPointerMove?.(e)},onPointerUp(e){ye(e)&&U.onPointerUp?.(e)},onPointerCancel(e){ye(e)&&U.onPointerCancel?.(e)},onTouchStart(e){if(te.current===`pen`&&ne.current){ne.current=!1,_e(!1);return}if(!C||!w||A){_e(!1);return}let t=e.touches[0];if(!t)return;if(zM(e)){_e(!1);return}let n=e.currentTarget,r=Xj(n.getRootNode(),t.clientX,t.clientY),i=Fv(e.nativeEvent),a=pv(i)?i:n;if(!Pv(n,a)){_e(!0);return}if(ie?.onTouchStart(e),AM(r)){_e(!0);return}re.current=!1;let o=Yj(a,n,j),s=Yj(a,n,N)!=null,c=null;o&&(c=WM(o,j,u)?null:!1),B.current={startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,scrollTarget:o,hasCrossAxisScrollableContent:s,allowSwipe:c,preserveNativeCrossAxisScroll:!1,drawerAxisAttributed:!1},pe.onTouchStart?.(e)},onTouchEnd(e){ie?.onTouchEnd(e),ve(),pe.onTouchEnd?.(e)},onTouchCancel(e){ie?.onTouchCancel(),ve(),pe.onTouchCancel?.(e)},[fM]:void 0}),children:(0,Z.jsx)(Nj.Provider,{value:ge,children:a})})});function kM(e,t){e?.toggleAttribute(Ej,t)}function AM(e){return!!e?.closest(_S)}function jM(e){return!!e?.closest(DM)}function MM(e,t){return t===`left`||t===`right`?e.offsetWidth:e.offsetHeight}function NM(e,t){return Math.max(MM(e,t)*.5,hM)}function PM(e,t){return e instanceof t.HTMLInputElement&&e.type===`range`}function FM(e){return e.tagName===`INPUT`||e.tagName===`TEXTAREA`}function IM(e,t){let n=pv(e.anchorNode)?e.anchorNode:e.anchorNode?.parentElement,r=pv(e.focusNode)?e.focusNode:e.focusNode?.parentElement;return e.containsNode(t,!0)||Pv(t,n)||Pv(t,r)}function LM(e,t){let n=Nv(e);if(n&&Pv(t,n)&&FM(n)){let{selectionStart:e,selectionEnd:t}=n;if(e!=null&&t!=null&&e<t)return!0}let r=e.getSelection?.();return!r||r.isCollapsed?!1:IM(r,t)}function RM(e,t){return e.composedPath().some(e=>PM(e,t))}function zM(e){return RM(e.nativeEvent,uv(e.currentTarget))}function BM(e,t){e.lastX=t.clientX,e.lastY=t.clientY}function VM(e,t,n,r){if(e.preserveNativeCrossAxisScroll)return!0;if(e.drawerAxisAttributed||e.allowSwipe===!0||!e.hasCrossAxisScrollableContent)return!1;if(!t.cancelable)return e.preserveNativeCrossAxisScroll=!0,!0;let i=r?n.clientY-e.startY:n.clientX-e.startX,a=r?n.clientX-e.startX:n.clientY-e.startY,o=Math.abs(i),s=Math.abs(a);return s>=TM&&s>o+EM?(e.preserveNativeCrossAxisScroll=!0,!0):o>=TM?(e.drawerAxisAttributed=!0,!1):!0}function HM(e,t){return UM(e,t).max>0}function UM(e,t){if(t===`vertical`){let t=Math.max(0,e.scrollHeight-e.clientHeight);return{offset:e.scrollTop,max:t}}let n=Math.max(0,e.scrollWidth-e.clientWidth);return{offset:e.scrollLeft,max:n}}function WM(e,t,n){let r=KM(n,t),{offset:i,max:a}=UM(e,t);return r?i<=0:i>=a}function GM(e,t,n,r){return(KM(n,t)?r>0:r<0)&&WM(e,t,n)}function KM(e,t){return t===`vertical`?e===`down`:e===`right`}var qM=W.createContext(void 0);function JM(e){let t=W.useContext(qM);if(t===void 0&&!e)throw Error(F_(47));return t}var YM={...Ww,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},XM=class extends mw{constructor(e,t,n){let r=new Lw;super(ZM(e,r,t,n),QM(r),YM)}setOpen=(e,t)=>{let n=t.reason===Cy,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Aw(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=kw(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),xS.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function ZM(e,t,n,r=!1){let i={...Rw(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function QM(e){return{popupRef:W.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:W.createRef(),beforeContentFocusGuardRef:W.createRef(),stickIfOpenTimeout:new B_,triggerElements:e}}var $M=O_(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=tN(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Iw(u,d),Nw(u);let{forceUnmount:m}=Pw(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),W.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),W.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ry(Fy))}),[m,u]);let h=d||f;return(0,Z.jsxs)(qM.Provider,{value:u,children:[s&&(0,Z.jsx)(Ew,{handle:s,store:u}),h&&(0,Z.jsx)(nN,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function eN(e){return JM(!0)?(0,Z.jsx)($M,{props:e}):(0,Z.jsx)(FS,{children:(0,Z.jsx)($M,{props:e})})}function tN(e,t){let n=Tw((e,n)=>new XM(t,e,n));return W.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function nN({store:e,modal:t}){let n=QS(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Fw(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var rN=k_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=JM(!0),h=Gw(s)??m;if(!h)throw Error(F_(74));let g=OT(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=W.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Mw(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),O=iT(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:xT(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=KS(v,{stickIfOpen:T}),A=nD(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:N}=gD({disabled:a,native:o}),P={open(e){return e&&w===`trigger-press`?iy.open(e):ry.open(e)}},{preFocusGuardRef:F,handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=Xk(h,x),R=oS(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,O,j,A,{[mS]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:P}),ee=(0,Z.jsx)(W.Fragment,{children:R},g);return C&&!D?(0,Z.jsxs)(W.Fragment,{children:[(0,Z.jsx)(db,{ref:F,onFocus:I}),ee,(0,Z.jsx)(db,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):ee}),iN=W.createContext(void 0);function aN(){let e=W.useContext(iN);if(e===void 0)throw Error(F_(45));return e}var oN=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return JM().useState(`mounted`)||n?(0,Z.jsx)(iN.Provider,{value:n,children:(0,Z.jsx)(ES,{ref:t,...r})}):null}),sN=W.createContext(void 0);function cN(){let e=W.useContext(sN);if(!e)throw Error(F_(46));return e}var lN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=yS,..._}=e,v=JM(),y=aN(),b=NS(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=W.useRef(null),N=xw(O),P=nE({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),F=x.useState(`domReferenceElement`);X(()=>{let e=F,t=M.current;if(e&&(M.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return N(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[F,N,v]);let I=E===!0&&w!==`trigger-hover`;QD(C&&I,D===`touch`,O,T);let L=v.useStateSetter(`positionerElement`),R=oE(e,{open:C,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:k},{styles:P.positionerStyles,transitionStatus:A,props:_,refs:[t,L],hidden:!S,inert:!C});return(0,Z.jsxs)(sN.Provider,{value:P,children:[S&&I&&(0,Z.jsx)(LD,{inert:lE(!C),cutout:T}),(0,Z.jsx)(PS,{id:b,children:R})]})}),uN=W.createContext(void 0);function dN(){let[e,t]=W.useState(0),n=Q(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:W.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var fN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=JM(),l=cN(),u=iO(!0)!=null,{context:d,hasClosePart:f}=dN(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);Sw({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),nT(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?ww(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=oS(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...Cw,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&lO.has(e.key)&&e.stopPropagation()}},aE(g),s],stateAttributesMapping:oy});return(0,Z.jsx)(GS,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:mv(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Z.jsx)(uN.Provider,{value:d,children:M})})}),pN=e=>({className:t})=>(0,W.createElement)($o,{icon:e,"aria-hidden":!0,...t===void 0?{}:{className:t}}),mN={arrowLeft:pN(bo),arrowsExpand:pN(vo),arrowsToCenter:pN(So),bulletList:pN(Io),buttonCursor:pN(Do),chatBubble:pN(wo),chevronDown:pN(_o),chevronLeft:pN(yo),chevronRight:pN(xo),chevronUp:pN(Co),dividerY:pN(Ko),download:pN(Oo),envelope:pN(Lo),eye:pN(Zo),files:pN(ko),frame:pN(Ao),gridLayoutRows:pN(Fo),heading1:pN(jo),image:pN(Mo),layers:pN(No),message:pN(Ro),mobile:pN(Jo),monitor:pN(Eo),moon:pN(zo),palette:pN(Bo),paragraph:pN(Go),sidebarLeft:pN(Ho),sidebarLeftHide:pN(Vo),sidebarRight:pN(Wo),sidebarRightHide:pN(Uo),sliders:pN(qo),sparkle:pN(Yo),sun:pN(Xo),textColumns:pN(Po),xmark:pN(To)},hN=(0,W.createContext)(mN),gN=hN.Provider,_N=()=>(0,W.useContext)(hN),vN=(0,W.createContext)(null);function yN(){let e=(0,W.useContext)(vN);if(e===null)throw Error(`useEditorBundle must be used within an EditorProvider`);return e}function $(e){return rs(yN().store,e)}function bN(){return yN().store}var xN=e=>`${e.fileName}:${e.lineNumber}:${e.columnNumber}`,SN=e=>e.occurrences>1?`${e.tag} ${e.occurrence} of ${e.occurrences}`:e.tag,CN=(e,t)=>{let n=e.origins[0];if(n===void 0)return SN(e);let r=t.split(`
26
- `)[n.lineNumber-1];return r===void 0?SN(e):r.slice(Math.max(0,n.columnNumber-1)).match(/<([A-Za-z][A-Za-z0-9_.:-]*)/)?.[1]??SN(e)},wN=(e,t)=>{let n=t.slice(e.start,e.end).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,` `).replace(/<[^>]+>/g,` `).replace(/&nbsp;/gi,` `).replace(/&amp;/gi,`&`).replace(/&lt;/gi,`<`).replace(/&gt;/gi,`>`).replace(/&quot;/gi,`"`).replace(/&#39;/gi,`'`).replace(/\s+/g,` `).trim();if(n!==``)return n.length>72?`${n.slice(0,69).trimEnd()}…`:n},TN=e=>{let t=[],n=(e,r)=>{t.push({depth:r,node:e});for(let t of e.children)n(t,r+1)};for(let t of e.roots)n(t,0);return t},EN=e=>{let t=Jc(e),n=new Map,r=new Map,i=[];for(let t of e){let e=[];n.set(t.instancePath,e);let a={instancePath:t.instancePath,selection:t,children:e};r.set(t.instancePath,a);let o=t.parentPath===void 0?void 0:n.get(t.parentPath);o===void 0?i.push(a):o.push(a)}return{roots:i,index:t,nodes:r}},DN=(e,t)=>{let n=[],r=e.index.get(t)?.parentPath;for(;r!==void 0;)n.unshift(r),r=e.index.get(r)?.parentPath;return n},ON=(e,t)=>[...DN(e,t),t].flatMap(t=>{let n=e.index.get(t);return n===void 0?[]:[{instancePath:t,label:SN(n)}]}),kN=e=>{let t=new Set;if(e===null)return t;for(let n of e.roots){t.add(n.instancePath);for(let e of n.children)e.children.length>0&&t.add(e.instancePath)}return t},AN={kind:`document`},jN={kind:`envelope`},MN=e=>new TextEncoder().encode(e).length,NN=e=>Math.max(1,Math.round(e/1024)),PN=e=>e.render===null?0:e.channel===`email`?NN(MN(e.render.html)):e.channel===`sms`?NN(MN(e.render.text)):NN(MN(JSON.stringify(e.render))),FN=(e,t)=>({outline:e.channel===`email`&&e.render!==null?EN(e.render.selections):null,sizeKb:PN(e),checks:qN(e,t)}),IN=(e,t)=>e.origins.length===t.origins.length&&e.origins.every((e,n)=>{let r=t.origins[n];return r!==void 0&&r.fileName===e.fileName&&r.lineNumber===e.lineNumber&&r.columnNumber===e.columnNumber}),LN=(e,t)=>e.tag===t.tag&&e.authored===t.authored&&e.occurrence===t.occurrence&&e.occurrences===t.occurrences&&IN(e,t),RN=(e,t,n)=>{if(e.kind!==`element`)return e;if(t===null||t.channel!==`email`)return AN;let{render:r,fixture:i}=t;if(r===null||i===null)return AN;let a=r.selections.find(t=>t.instancePath===e.instancePath);if(a===void 0)return AN;if(e.revision===r.revision&&e.fixture===i)return e;let o=n?.index.get(e.instancePath);return o===void 0||!LN(o,a)?AN:{kind:`element`,instancePath:e.instancePath,revision:r.revision,fixture:i}},zN=(e,t,n)=>{let r=t.authoredSource!==void 0&&(n===null||n===t.authoredSource)?t.authoredSource:e.origin.authoredSource,i={...e.origin,authoredSource:r};if(t.channel!==e.channel)throw Error(`Host sent a ${t.channel} change for a ${e.channel} document`);return{...e,rev:t.rev,origin:i,fixtures:t.fixtures,fixture:t.fixture,preview:t.preview,render:t.render,diagnostics:t.diagnostics,...t.channel===`email`?{incompatibilities:t.incompatibilities}:{}}},BN=104448,VN=e=>e.severity===`error`?`error`:e.severity===`warning`?`warn`:`info`,HN=e=>e===`caniemail/system-ui-ui-serif-ui-sans-serif-ui-rounded-ui-monospace`?`System fonts`:e===`caniemail/media`?`Media queries`:e===`caniemail/color-scheme-meta-tag`?`Color scheme metadata`:e.startsWith(`caniemail/`)?e.slice(10).replace(/-property$/,``).replace(/-attribute$/,` attribute`).replace(/-element$/,` element`):e.replaceAll(`-`,` `),UN=(e,t)=>{let n=new Map;for(let t of e){let e=n.get(t.code)??new Map,r=JSON.stringify([t.severity,t.compatibility?.assessment,t.compatibility?.title,t.message,[...t.clients??[]].sort(),t.notes,t.provenance]),i=e.get(r),a=new Map;for(let e of i===void 0?[t]:[i,t])for(let t of e.occurrences??[e.origins])t.length>0&&a.set(JSON.stringify(t),t);e.set(r,{...t,origins:i?.origins??t.origins,fixtures:[...new Set([...i?.fixtures??[],...t.fixtures??[]])].sort(),occurrences:[...a.values()]}),n.set(t.code,e)}return[...n].map(([e,n])=>WN(`${t}:${e}`,[...n.values()]))},WN=(e,t)=>{let n=e=>e.compatibility?.assessment===`unverified`?0:e.compatibility?.assessment===`degradation`?1:2,r=[...t].sort((e,t)=>n(e)-n(t)),i=r.find(e=>e.severity===`error`)??r.find(e=>e.severity===`warning`)??r[0],a=new Set(r.flatMap(e=>e.fixtures??[])),o=new Set(r.flatMap(e=>e.clients??[]));return{id:e,severity:VN(i),label:i.compatibility?.title??HN(i.code),detail:[`${r.length} finding${r.length===1?``:`s`}`,...o.size===0?[]:[`${o.size} client${o.size===1?``:`s`}`],...a.size===0?[]:[`${a.size} fixture${a.size===1?``:`s`}`]].join(` · `),diagnostics:r}},GN=e=>{let t=MN(e.html);return t<=BN?{id:`size:gmail-clip`,severity:`ok`,label:`Gmail clipping`,detail:`HTML is ${Math.ceil(t/1024)} KB, under Gmail's 102 KB clipping threshold.`}:{id:`size:gmail-clip`,severity:`warn`,label:`Gmail clipping risk`,detail:`HTML is ${Math.ceil(t/1024)} KB, above Gmail's 102 KB clipping threshold.`}},KN={id:`build:no-render`,severity:`error`,label:`No render`,detail:`The template entry did not produce a render at this revision.`},qN=(e,t)=>{let n=[...UN(e.diagnostics,`diagnostic`),...e.channel===`email`?UN(e.incompatibilities,`compat`):[]];return e.render===null?[...n.length===0?[KN]:n,...t]:e.channel===`email`?[...n,GN(e.render),...t]:[...n,...t]},JN=e=>{let t=[],n=[],r=[],i=[];for(let a of e)a.severity===`error`?t.push(a):a.severity===`warn`?n.push(a):a.severity===`info`?r.push(a):i.push(a);return{actionable:[...t,...n],info:r,ok:i,errorCount:t.length,warnCount:n.length,badgeCount:t.length+n.length}},YN=e=>j(e,`_tag`)&&e._tag===`DocumentUnavailable`&&j(e,`reason`)&&typeof e.reason==`string`,XN=e=>YN(e)?e.reason:e instanceof Error?e.message:`The document session failed.`,ZN=(e,t)=>{let n=``,r=[],i=!1,a,o=!1,s=!1,c,l=[],u=0,d=()=>{let e=l;l=[];for(let t of e)t.resolve(n)},f=e=>{let t=l;l=[];for(let n of t)n.reject(e)},p=()=>{if(a!==void 0&&(clearTimeout(a),a=void 0),e.access!==`editable`)return;let s=e.writer;if(i)return;i=!0;let c=u;(async()=>{for(;r.length>0&&!o;){let e=r[0],a={kind:`authoredSource`,baseRev:n,authoredSource:e.authoredSource};try{let e=await s.save(a);if(u!==c)return;n=e.rev,t.onPersistedRevision(n),r.shift(),t.onStorageError(null)}catch(e){if(u!==c)return;if(YN(e)){t.onStorageError(e.reason),i=!1,f(e);return}r=[],o=!0,t.onConflict();break}}u===c&&(i=!1,d())})()},m=()=>{u+=1,i=!1,s=!1;let a=u,l=!1,d=[],f=e=>{if(u!==a)return;if(e.origin===`self`){t.onSelfAck(e);return}let i=r.length>0;i&&(o=!0),n=e.rev,t.onForeignChange(e,i)};e.document.open(e=>{l?f(e):d.push(e)},e=>{u===a&&(s=!1,t.onSessionError(XN(e)))}).then(({initial:e,close:i})=>{if(u!==a){i();return}c=i,l=!0,s=!0,n=e.rev,t.onInitial(e);for(let e of d)f(e);d.length=0,r.length>0&&p()}).catch(e=>{u===a&&t.onSessionError(XN(e))})};return{open:m,dispose:()=>{u+=1,a!==void 0&&clearTimeout(a),a=void 0,s=!1,c?.(),c=void 0},reload:()=>{o=!1,r=[],i=!1,a!==void 0&&clearTimeout(a),a=void 0,d(),c?.(),c=void 0,m()},enqueueAuthoredSource:(t,n)=>{if(e.access!==`editable`)return;let o={kind:`authoredSource`,authoredSource:t,coalesceKey:n?.coalesceKey},s=r.length-1,c=r[s],l=s>=+!!i;o.coalesceKey!==void 0&&l&&c?.kind===`authoredSource`&&c.coalesceKey===o.coalesceKey?r[s]=o:r.push(o),a!==void 0&&clearTimeout(a),a=setTimeout(p,300)},flushSaves:()=>(a!==void 0&&p(),r.length===0&&!i?Promise.resolve(n):new Promise((e,t)=>{l.push({resolve:e,reject:t})})),retrySave:()=>{if(e.access===`editable`){if(t.onStorageError(null),!s){c?.(),c=void 0,m();return}p()}},adoptRev:e=>{n=e,o=!1}}},QN={desktop:600,mobile:375},$N=`samva.editor.leftWidth`,eP=`samva.editor.assistantWidth`,tP=`samva.editor.rightWidth`,nP=260,rP=360,iP=320,aP=200,oP=420,sP=300,cP=520,lP=260,uP=440,dP=(e,t)=>{try{let n=localStorage.getItem(e);if(n===null)return t;let r=Number(n);return Number.isFinite(r)?r:t}catch{return t}},fP=(e,t)=>{try{localStorage.setItem(e,String(t))}catch{}},pP=e=>e!==null&&e.channel===`email`?e.render:null,mP=(e,t)=>{let n,r,i=t=>e.access!==`editable`||t.doc?.access.kind===`readonly`||t.lifecycleBusy,a=t=>t!==null&&e.access===`editable`&&e.sourceAccess===`editable`&&t.access.kind!==`readonly`,o=(e,t,n)=>{let r=FN(t,e.hostChecks),i=!e.layersSeeded&&r.outline!==null;return{doc:t,pendingAuthoredSource:n,...r,render:pP(t),expandedLayers:i?kN(r.outline):e.expandedLayers,layersSeeded:e.layersSeeded||i,selection:RN(e.selection,t,e.outline)}},s=ts((s,c)=>{let l=(e,t)=>{let r=c();r.doc!==null&&(s({doc:{...r.doc,origin:{...r.doc.origin,authoredSource:e}},pendingAuthoredSource:e,sourceEditError:null}),n.enqueueAuthoredSource(e,{coalesceKey:t?.coalesceKey??`authored-source`}))},u=e=>{let t=c();if(i(t)||!t.sourceEditable||t.conflict||t.doc===null)return;let n=e===`undo`?t.undoHistory:t.redoHistory,r=n.at(-1);if(r!==void 0){if(t.doc.origin.authoredSource!==(e===`undo`?r.after:r.before)){s({sourceEditError:`History conflicts with a newer change. Your current work is kept. Review the saved versions.`});return}s(e===`undo`?{undoHistory:n.slice(0,-1),redoHistory:[...t.redoHistory,r]}:{redoHistory:n.slice(0,-1),undoHistory:[...t.undoHistory,r]}),l(e===`undo`?r.before:r.after)}};return{sourceEditError:null,assistantOriginIndex:0,undoHistory:[],redoHistory:[],workspaceView:`visual`,doc:null,pendingAuthoredSource:null,editable:e.access===`editable`,sourceEditable:e.access===`editable`&&e.sourceAccess===`editable`,metadataEditable:e.access===`editable`&&e.metadataAccess!==`readonly`,readonlyReason:null,render:null,outline:null,sizeKb:0,checks:t.hostChecks,hostChecks:t.hostChecks,lifecycleCapability:e.lifecycle,versionsCapability:e.versions,telemetry:e.telemetry,assetsCapability:e.assets,fixtureCapability:e.fixtures,fixtureBusy:!1,fixtureError:null,diagnosticAssistance:null,selection:AN,renameActive:!1,expandedLayers:new Set,layersSeeded:!1,leftCollapsed:!1,rightCollapsed:!1,designView:`layers`,focusedPane:`assistant`,leftWidth:dP($N,nP),assistantWidth:Math.min(cP,Math.max(sP,dP(eP,rP))),rightWidth:dP(tP,iP),previewDevice:`desktop`,canvasZoom:`100`,layoutMode:`wide`,metadataSaving:!1,metadataError:null,lifecycleBusy:!1,conflict:!1,storageError:null,hoveredCandidatePath:null,actions:{requestSourceAssistance:e=>s({assistantOriginIndex:e,rightCollapsed:!1}),requestDiagnosticAssistance:e=>{let t=c();t.doc===null||i(t)||t.pendingAuthoredSource!==null||t.conflict||s({diagnosticAssistance:{id:(t.diagnosticAssistance?.id??0)+1,revision:t.doc.rev,check:e},rightCollapsed:!1})},openSource:()=>s({workspaceView:`source`}),undo:()=>u(`undo`),redo:()=>u(`redo`),applySourceEdit:e=>{let t=c();if(i(t)||!t.sourceEditable||t.conflict||t.doc===null)return;if(t.doc.rev!==e.revision||t.doc.origin.authoredSource!==e.source||t.pendingAuthoredSource!==null&&e.coalesceKey===void 0){s({sourceEditError:`That edit is stale. The preview moved on. Reselect the element and try again.`});return}let n=xg(e.source,e.edits,{profile:{entry:t.doc.origin.file}});if(!n.ok){s({sourceEditError:n.reason});return}if(n.source===e.source)return;let r=t.undoHistory.at(-1);s({undoHistory:e.coalesceKey!==void 0&&r?.key===e.coalesceKey&&r.after===e.source?[...t.undoHistory.slice(0,-1),{before:r.before,after:n.source,key:e.coalesceKey}]:[...t.undoHistory,{before:e.source,after:n.source,key:e.coalesceKey}],redoHistory:[]}),l(n.source,{coalesceKey:e.coalesceKey})},replaceAuthoredSource:e=>{let t=c();i(t)||!t.sourceEditable||t.doc===null||e===t.doc.origin.authoredSource||t.conflict||(s({undoHistory:[...t.undoHistory,{before:t.doc.origin.authoredSource,after:e}],redoHistory:[]}),l(e))},viewFixture:e=>{let t=c(),n=t.fixtureCapability;n?.status===`ready`&&t.doc!==null&&!t.fixtureBusy&&t.doc.fixtures.includes(e)&&t.doc.fixture!==e&&(s({fixtureBusy:!0,fixtureError:null}),n.api.view(e).then(()=>s({fixtureBusy:!1}),()=>s({fixtureBusy:!1,fixtureError:`Couldn't render the ${e} fixture.`})))},reload:()=>{c().lifecycleBusy||(s({conflict:!1,storageError:null,fixtureError:null}),n.reload())},flushSaves:()=>n.flushSaves(),beginLifecycle:()=>{let t=c();return t.lifecycleBusy||t.doc===null||e.access!==`editable`||t.doc.access.kind===`readonly`?!1:(s({lifecycleBusy:!0}),!0)},endLifecycle:()=>s({lifecycleBusy:!1}),adoptLifecycleSnapshot:e=>{n.adoptRev(e.rev),s(t=>{if(t.doc===null)return{conflict:!1};let n={...t.doc,rev:e.rev,origin:{...t.doc.origin,authoredSource:e.authoredSource}};return{...o(t,n,null),sourceEditable:a(n),conflict:!1}})},retrySave:()=>{i(c())||n.retrySave()},select:e=>{s(t=>{if(e===null)return{selection:AN};let{render:n,doc:r}=t;if(n===null||r?.channel!==`email`||r.fixture===null||!n.selections.some(t=>t.instancePath===e))return{selection:AN};let i=new Set(t.expandedLayers);if(t.outline!==null)for(let n of DN(t.outline,e))i.add(n);return{assistantOriginIndex:0,selection:{kind:`element`,instancePath:e,revision:n.revision,fixture:r.fixture},expandedLayers:i}});let{selection:t}=c();t.kind===`element`&&r?.({instancePath:t.instancePath,revision:t.revision,fixture:t.fixture})},selectDocument:()=>s({selection:AN}),selectEnvelope:()=>s({selection:jN}),toggleLeft:()=>s(e=>({leftCollapsed:!e.leftCollapsed})),toggleRight:()=>s(e=>({rightCollapsed:!e.rightCollapsed})),setDesignView:e=>{c().designView!==e&&s({designView:e})},setFocusedPane:e=>{c().focusedPane!==e&&s({focusedPane:e})},openReview:()=>s(e=>({designView:`review`,focusedPane:e.layoutMode===`narrow`?`assistant`:`design`})),setWorkspaceView:e=>s({workspaceView:e}),setLeftWidth:e=>{let t=Math.min(oP,Math.max(aP,Math.round(e)));fP($N,t),s({leftWidth:t})},setAssistantWidth:e=>{let t=Math.min(cP,Math.max(sP,Math.round(e)));fP(eP,t),s({assistantWidth:t})},setRightWidth:e=>{let t=Math.min(uP,Math.max(lP,Math.round(e)));fP(tP,t),s({rightWidth:t})},setPreviewDevice:e=>s({previewDevice:e}),setCanvasZoom:e=>s({canvasZoom:e}),setLayoutMode:e=>{if(c().layoutMode!==e){if(e===`wide`){s({layoutMode:e,leftCollapsed:!1,rightCollapsed:!1,canvasZoom:`100`});return}if(e===`standard`){s({layoutMode:e,leftCollapsed:!1,rightCollapsed:!0,canvasZoom:`fit`});return}s({layoutMode:e,leftCollapsed:!0,rightCollapsed:!0,canvasZoom:`fit`})}},setRenameActive:e=>s({renameActive:e}),rename:t=>{let n=c();if(i(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let r=e.writer,a=n.doc;if(a===null)return;let o=t.trim()||`Untitled template`;o!==a.name&&(s(e=>e.doc===null?e:{doc:{...e.doc,name:o},metadataSaving:!0,metadataError:null}),r.save({kind:`metadata`,patch:{name:o}}).then(()=>s({metadataSaving:!1}),()=>{s(e=>({doc:e.doc===null?e.doc:{...e.doc,name:a.name},metadataSaving:!1,metadataError:`Couldn't save the template name.`}))}))},saveMetadata:t=>{let n=c();if(i(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let r=e.writer,a=n.doc;a!==null&&(s(e=>e.doc===null?e:{doc:{...e.doc,metadata:{fromDefault:t.fromDefault===void 0?e.doc.metadata.fromDefault:t.fromDefault??void 0,replyToDefault:t.replyToDefault===void 0?e.doc.metadata.replyToDefault:t.replyToDefault??void 0}},metadataSaving:!0,metadataError:null}),r.save({kind:`metadata`,patch:t}).then(()=>s({metadataSaving:!1}),()=>{s(e=>({doc:e.doc===null?e.doc:{...e.doc,metadata:a.metadata},metadataSaving:!1,metadataError:`Couldn't save the sender defaults.`}))}))},toggleLayerExpand:e=>s(t=>{let n=new Set(t.expandedLayers);return n.has(e)?n.delete(e):n.add(e),{expandedLayers:n}}),ancestryOf:e=>{let{outline:t}=c();return t===null?[]:DN(t,e)},breadcrumbOf:e=>{let{outline:t}=c();return t===null?[]:ON(t,e)},setHovered:e=>s({hoveredCandidatePath:e}),setHostChecks:e=>{Object.is(c().hostChecks,e)||s(t=>({hostChecks:e,checks:t.doc===null?e:qN(t.doc,e)}))}}}}),c=(e,t)=>{s.setState(n=>{if(n.doc===null)return n;let r=t?n.pendingAuthoredSource:null,i=zN(n.doc,e,r),a=e.authoredSource!==void 0&&e.authoredSource===i.origin.authoredSource;return o(n,i,a?null:r)})};return n=ZN(e,{onInitial:t=>{s.setState(n=>({...o(n,t,null),editable:e.access===`editable`&&t.access.kind!==`readonly`,sourceEditable:a(t),readonlyReason:t.access.kind===`readonly`?t.access.reason:null}))},onPersistedRevision:e=>{s.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e}})},onSelfAck:e=>c(e,!0),onForeignChange:(e,t)=>{if(t){s.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e.rev},sourceEditable:!1,conflict:!0});return}c(e,!1),s.setState(e=>({sourceEditable:a(e.doc)}))},onConflict:()=>s.setState({conflict:!0,sourceEditable:!1}),onStorageError:e=>s.setState({storageError:e}),onSessionError:e=>s.setState({storageError:e})}),{host:e,store:s,spine:n,setUserSelectListener:e=>{r=e}}},hP=[];function gP({host:e,checks:t=hP,icons:n,onSelectElement:r,children:i}){let[a,o]=(0,W.useState)(()=>mP(e,{hostChecks:t}));a.host!==e&&o(mP(e,{hostChecks:t})),(0,W.useEffect)(()=>(a.spine.open(),()=>a.spine.dispose()),[a]),(0,W.useEffect)(()=>{a.store.getState().actions.setHostChecks(t)},[a,t]),(0,W.useLayoutEffect)(()=>(a.setUserSelectListener(r),()=>a.setUserSelectListener(void 0)),[a,r]);let s=(0,W.useMemo)(()=>n===void 0?mN:{...mN,...n},[n]);return(0,Z.jsx)(vN.Provider,{value:a,children:(0,Z.jsx)(gN,{value:s,children:i})})}var _P=e=>{let t=({className:t})=>{let n=_N()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})};return t.displayName=`EditorIcon(${e})`,t},vP=_P(`arrowsExpand`),yP=_P(`arrowsToCenter`),bP=_P(`bulletList`),xP=_P(`buttonCursor`),SP=_P(`chevronDown`),CP=_P(`chevronLeft`),wP=_P(`chevronRight`),TP=_P(`chevronUp`),EP=_P(`dividerY`),DP=_P(`download`),OP=_P(`envelope`),kP=_P(`eye`),AP=_P(`files`),jP=_P(`frame`),MP=_P(`gridLayoutRows`),NP=_P(`heading1`),PP=_P(`image`),FP=_P(`layers`),IP=_P(`mobile`),LP=_P(`monitor`),RP=_P(`palette`),zP=_P(`paragraph`),BP=_P(`sidebarLeft`),VP=_P(`sidebarLeftHide`),HP=_P(`sidebarRight`),UP=_P(`sidebarRightHide`),WP=_P(`sliders`),GP=_P(`sparkle`),KP=_P(`textColumns`),qP=_P(`xmark`);function JP(...e){return VO(e)}var YP=`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,XP=JP(`inline-flex items-center justify-center gap-1.5 rounded-[7px] font-medium transition-all outline-none disabled:pointer-events-none disabled:opacity-50`,`bg-[var(--editor-raised-bg)] text-[color:var(--editor-raised-fg)] shadow-[var(--editor-raised-shadow)]`,`hover:bg-[var(--editor-raised-bg-hover)] aria-expanded:bg-[var(--editor-raised-bg-hover)] data-popup-open:bg-[var(--editor-raised-bg-hover)]`,`active:translate-y-px active:shadow-[var(--editor-raised-shadow-pressed)] disabled:shadow-none data-disabled:shadow-none`,YP),ZP=JP(`inline-flex items-center justify-center gap-1.5 rounded-md border border-transparent font-medium whitespace-nowrap text-muted-foreground outline-none`,`hover:bg-muted hover:text-foreground`,`transition-[color,background-color,border-color,box-shadow] duration-150 ease-out`,YP,`data-[pressed]:border-[color:var(--editor-chip-border)] data-[pressed]:bg-[var(--editor-chip-bg)] data-[pressed]:text-[color:var(--editor-chip-fg)] data-[pressed]:shadow-[var(--editor-chip-shadow)]`,`data-active:border-[color:var(--editor-chip-border)] data-active:bg-[var(--editor-chip-bg)] data-active:text-[color:var(--editor-chip-fg)] data-active:shadow-[var(--editor-chip-shadow)]`,`aria-pressed:border-[color:var(--editor-chip-border)] aria-pressed:bg-[var(--editor-chip-bg)] aria-pressed:text-[color:var(--editor-chip-fg)] aria-pressed:shadow-[var(--editor-chip-shadow)]`),QP=JP(`min-h-9 w-full rounded-lg border border-border bg-background px-2.5 text-[13px] text-foreground outline-none disabled:cursor-not-allowed disabled:bg-surface-inset disabled:text-muted-foreground`,YP),$P=new Set([`frame.start`,`document.switcher`,`rail.assistant`,`rail.review`,`statusbar.headline`]),eF=e=>{let t=new Set,n=new Map;for(let r of e){if(t.has(r.id))throw Error(`Editor contribution id "${r.id}" is used twice.`);t.add(r.id);let e=n.get(r.slot)??[];if($P.has(r.slot)&&e.length>0)throw Error(`Editor region "${r.slot}" holds one contribution; "${e[0].id}" and "${r.id}" both target it.`);e.push(r),n.set(r.slot,e)}let r=n.get(`toolbar.actions`);if(r!==void 0){let e=e=>e.slot===`toolbar.actions`?e.order:void 0;n.set(`toolbar.actions`,r.toSorted((t,n)=>{let r=e(t),i=e(n);return r===void 0||i===void 0?r===i?0:r===void 0?1:-1:r-i}))}let i=e=>(n.get(e)??[]).filter(t=>t.slot===e);return{all:i,one:e=>i(e)[0]}},tF=(0,W.createContext)(eF([])),nF=tF.Provider,rF=e=>(0,W.useContext)(tF).one(e),iF=e=>(0,W.useContext)(tF).all(e),aF=(0,W.createContext)(null),oF=aF.Provider;function sF(){let e=rF(`rail.assistant`),t=rF(`rail.review`),n=(0,W.useContext)(aF),r=bN(),{doc:i,render:a,outline:o,selection:s,originIndex:c,checks:l,diagnosticAssistance:u,layout:d,canFix:f}=$(zO(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,originIndex:e.assistantOriginIndex,checks:e.checks,diagnosticAssistance:e.diagnosticAssistance,layout:e.layoutMode,canFix:e.sourceEditable&&!e.conflict&&e.pendingAuthoredSource===null&&!e.lifecycleBusy})));if(e===void 0||n===null)return null;let p=JN(l),m=s.kind===`element`?o?.index.get(s.instancePath)??null:null,h=m===null||s.kind!==`element`?null:{originIndex:c,instancePath:m.instancePath,fixture:s.fixture,label:SN(m)},g=i?.channel===`email`?i.fixture:null,_=o===null||g===null||a===null||i===null?[]:TN(o).map(({depth:e,node:t})=>{let n=wN(t.selection,a.html);return{instancePath:t.instancePath,fixture:g,...t.selection.origins[c]===void 0?{}:{originIndex:c},label:CN(t.selection,i.origin.authoredSource),...n===void 0?{}:{detail:n},depth:e,active:s.kind===`element`&&s.instancePath===t.instancePath}});return{panel:e.render({flushSaves:()=>r.getState().actions.flushSaves(),exportHtml:n.exportHtml,canExport:n.canExport,openReview:t===void 0?void 0:()=>r.getState().actions.openReview(),workspace:{draftRevision:i?.rev??null,saveVersionStatus:n.saveVersionStatus,checks:{errors:p.errorCount,warnings:p.warnCount,findings:p.actionable,canFix:f},diagnosticAssistance:u,pointedElement:h,availableInstancePaths:o===null?[]:[...o.index.keys()],layout:d,layers:_}}),header:e.header??null}}function cF({hidden:e=!1}){let t=sF(),n=$(e=>e.assistantWidth),r=$(e=>e.layoutMode),i=r===`compact`||r===`narrow`;return t===null?null:(0,Z.jsx)(`aside`,{"aria-label":`Assistant`,hidden:e,"data-editor-rail":`left`,"data-testid":`agent-column`,style:i?void 0:{width:n},className:JP(`min-h-0 min-w-0 flex-col overflow-hidden bg-background`,e?`hidden`:`flex`,i&&`h-full w-full flex-1`,!i&&`h-full shrink-0 border-r border-border`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,style:i?void 0:{width:n,maxWidth:`100%`},children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex min-h-11 shrink-0 items-center gap-2 border-b px-3 py-2`,children:[(0,Z.jsx)(GP,{className:`text-accent-orange size-[15px] shrink-0`}),(0,Z.jsx)(`p`,{className:`text-foreground truncate text-[13px] leading-none font-semibold`,children:`Assistant`}),t.header!==null&&(0,Z.jsx)(`div`,{className:`ml-auto shrink-0`,children:t.header})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:t.panel})]})})}function lF(){let e=sF(),{rightCollapsed:t,rightWidth:n,layoutMode:r}=$(zO(e=>({rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode})));if(e===null)return null;let i=r===`compact`||r===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Assistant`,"aria-hidden":t||void 0,inert:t||void 0,"data-editor-rail":`right`,style:{width:t?0:n,maxWidth:i?`calc(100% - 48px)`:void 0},className:JP(`flex h-full shrink-0 flex-col overflow-hidden border-l border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,i&&`absolute inset-y-0 right-0 z-40 shadow-[var(--shadow-floating)]`,t&&`border-l-0`),children:(0,Z.jsx)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:n,maxWidth:`100%`},children:(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:e.panel})})})}var uF=(0,W.createContext)(void 0),dF=()=>(0,W.useContext)(uF);function fF({label:e,source:t,editable:n,onChange:r,testId:i}){return(0,Z.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{className:`border-border-subtle bg-surface-inset text-muted-foreground border-b px-4 py-2 font-mono text-[11px] font-medium`,children:e}),(0,Z.jsx)(`textarea`,{"aria-label":e,"data-testid":i,readOnly:!n,spellCheck:!1,value:t,onChange:e=>r?.(e.target.value),className:JP(`border border-[color:var(--editor-well-border)] bg-[var(--editor-well-bg)] shadow-[var(--editor-well-shadow)]`,`samva-editor-scroll text-foreground min-h-0 flex-1 resize-none border-t-0 p-4 font-mono text-[12.5px] leading-5 outline-none`,`read-only:bg-muted read-only:shadow-none dark:read-only:bg-muted/40`)})]})}function pF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),{replaceAuthoredSource:n}=$(e=>e.actions);return e===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid flex-1 place-items-center text-sm`,children:`Loading…`}):(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:(0,Z.jsx)(fF,{label:`Authored TSX · ${e.origin.file}`,source:e.origin.authoredSource,editable:t,testId:`source-workspace.authored-tsx`,onChange:t?n:void 0})})}function mF(e){let t=bN(),{applySourceEdit:n}=$(e=>e.actions);return(0,W.useCallback)((r,i)=>{let{doc:a}=t.getState();if(a===null)return;let o=a.origin.authoredSource,s=e(o,r);if(!s.ok){t.setState({sourceEditError:s.reason});return}s.edits.length!==0&&n({revision:a.rev,source:o,edits:s.edits,coalesceKey:i})},[n,e,t])}function hF(e,t){return`${e}-view-tab-${t}`}var gF=JP(ZP,`h-7 px-2.5 text-[12px] capitalize`);function _F({value:e,onChange:t,children:n,panelId:r,idBase:i}){let a=(0,W.useId)(),o=i??a,s=`${o}-view-panel`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($O,{role:`tablist`,"aria-label":`Workspace view`,value:[e],onValueChange:e=>{let n=e[0];(n===`visual`||n===`source`)&&t(n)},className:`border-border bg-background flex h-10 shrink-0 items-center gap-1 border-b px-3`,children:[`visual`,`source`].map(t=>(0,Z.jsx)(KO,{id:hF(o,t),type:`button`,role:`tab`,"aria-selected":e===t,"aria-controls":r??s,"aria-pressed":void 0,value:t,"data-testid":`workspace.tab.${t}`,className:gF,children:t},t))}),r===void 0&&(0,Z.jsx)(`div`,{role:`tabpanel`,id:s,"aria-labelledby":hF(o,e),className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:n})]})}function vF({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-foreground font-medium`,children:e}),t]})}function yF({summary:e}){return(0,Z.jsxs)(`div`,{className:`border-border bg-surface-inset rounded-lg border border-dashed px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-foreground truncate font-mono text-[11.5px]`,children:e}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-0.5 text-[11px]`,children:`Locked structure. Preserved as is. Edit it in Source.`})]})}function bF({summary:e}){return(0,Z.jsx)(`span`,{title:`Locked expression. Edit it in Source.`,"data-testid":`channel-workspace.locked-chip`,className:`border-border bg-surface-inset text-muted-foreground inline-flex max-w-full shrink-0 truncate rounded-md border border-dashed px-1.5 py-0.5 font-mono text-[11.5px]`,children:e})}function xF({diagnostics:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{className:`grid gap-2`,children:e.map((e,t)=>(0,Z.jsx)(`li`,{className:`border-status-error/30 bg-status-error/5 text-status-error rounded-lg border px-3 py-2 text-[12px]`,children:e.message},`${e.code}-${t}`))})}function SF({variables:e}){return e.length===0?null:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,Z.jsx)(`span`,{className:`border-border-subtle bg-surface-inset rounded-full border px-2 py-0.5 font-mono text-[11px]`,children:e},e))})}function CF({text:e,className:t}){let n=y_(e);return(0,Z.jsxs)(`p`,{"data-testid":`sms-counter`,className:JP(`text-muted-foreground`,t),children:[n.encoding.toUpperCase(),` · `,n.characterCount,` character`,n.characterCount===1?``:`s`,` · `,n.segmentCount,` segment`,n.segmentCount===1?``:`s`]})}function wF({reason:e}){return e===null?null:(0,Z.jsx)(`p`,{role:`alert`,"data-testid":`channel-workspace.edit-refusal`,className:`border-status-error/30 bg-status-error/5 text-status-error rounded-lg border px-3 py-2 text-[12px]`,children:e})}var TF=`none`;function EF({segments:e,editable:t,onChange:n}){let r=(0,W.useRef)(!1);return(0,Z.jsx)(`div`,{className:`bg-muted text-foreground rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:e.map((e,i)=>e.kind===`locked`?(0,Z.jsx)(`span`,{contentEditable:!1,title:`Locked structure — edit in Source`,"data-testid":`sms-workspace.locked-segment`,className:`border-border bg-surface-inset text-muted-foreground mx-0.5 inline-flex rounded-md border border-dashed px-1.5 py-0.5 font-mono text-[11.5px]`,children:e.summary},`locked-${i}`):(0,Z.jsx)(`span`,{role:`textbox`,"aria-label":`SMS message preview segment ${i+1}`,"data-testid":`sms-workspace.preview-segment.${i+1}`,"aria-multiline":`true`,contentEditable:t?`plaintext-only`:!1,suppressContentEditableWarning:!0,onCompositionStart:()=>{r.current=!0},onCompositionEnd:e=>{r.current=!1,n(i,e.currentTarget.textContent??``)},onInput:e=>{r.current||n(i,e.currentTarget.textContent??``)},className:`focus:bg-background focus-visible:ring-ring/50 rounded-sm outline-none focus-visible:ring-[3px]`,children:e.text},`text-${i}`))})}function DF({form:e,editable:t,onEdit:n}){let r=dF(),i=e.category.kind===`literal`?e.category.value:void 0;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(vF,{label:`Category`,children:(0,Z.jsxs)(sD,{value:i??TF,disabled:!t||e.category.kind===`expression`,onValueChange:e=>n({kind:`category`,value:po.find(t=>t.value===e)?.value}),children:[(0,Z.jsx)(SD,{"data-testid":`sms-workspace.category`,className:QP,children:(0,Z.jsx)(wD,{})}),(0,Z.jsx)(TD,{container:r,children:(0,Z.jsx)(eO,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsxs)(xO,{className:`samva-editor-shell border-border bg-surface-elevated min-w-[var(--anchor-width)] rounded-lg border p-1 shadow-[var(--shadow-lg)]`,children:[(0,Z.jsx)(MO,{value:TF,"data-testid":`sms-workspace.category-option.none`,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(NO,{children:`Not set`})}),po.map(e=>(0,Z.jsx)(MO,{value:e.value,"data-testid":`sms-workspace.category-option.${e.value}`,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(NO,{children:e.label})},e.value))]})})})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Message body`}),e.segments.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`locked-${r}`):(0,Z.jsx)(`textarea`,{"aria-label":`Message body segment ${r+1}`,"data-testid":`sms-workspace.body-segment.${r+1}`,value:e.text,disabled:!t,onChange:e=>n({kind:`text`,segment:r,text:e.target.value},`sms-${r}`),rows:5,className:`${QP} resize-y py-2`},`text-${r}`))]}),(0,Z.jsx)(SF,{variables:e.variables})]})}function OF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=mF(a_),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>i_(o),[o]),c=e?.channel===`sms`?e.render:null;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(_F,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(`aside`,{className:`samva-editor-scroll border-border bg-background w-[380px] shrink-0 overflow-y-auto border-r p-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(xF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(wF,{reason:n}),s===null?(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[12.5px]`,children:[`The SMS body is not a `,(0,Z.jsx)(`code`,{children:`<Sms>`}),` written in place, so it is edited in Source.`]}):(0,Z.jsx)(DF,{form:s,editable:t,onEdit:a})]})}),(0,Z.jsx)(`main`,{className:`samva-editor-workspace samva-editor-scroll min-w-0 flex-1 overflow-auto p-8`,children:(0,Z.jsxs)(`div`,{className:`border-border bg-background mx-auto max-w-[420px] rounded-[28px] border p-5 shadow-[var(--shadow-lg)]`,children:[(0,Z.jsx)(`div`,{"data-testid":`sms-workspace.preview-heading`,className:`border-border-subtle text-muted-foreground mb-5 border-b pb-3 text-center text-[12px] font-medium`,children:`SMS preview`}),s===null?(0,Z.jsx)(`div`,{className:`bg-muted text-muted-foreground rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:c?.text||`Message preview`}):(0,Z.jsx)(EF,{segments:s.segments,editable:t,onChange:(e,t)=>a({kind:`text`,segment:e,text:t},`sms-${e}`)}),c!==null&&(0,Z.jsx)(CF,{text:c.text,className:`mt-4 text-center text-[11.5px]`})]})}),(0,Z.jsx)(lF,{})]})})})}var kF=[{kind:`text`,text:``,start:0,end:0}],AF=e=>e.kind===`literal`?e.value:e.kind===`expression`?e.source:``;function jF({value:e,options:t,disabled:n,ariaLabel:r,onChange:i}){let a=dF();return(0,Z.jsxs)(sD,{value:e,disabled:n,onValueChange:e=>{let n=t.find(t=>t.value===e);n!==void 0&&i(n.value)},children:[(0,Z.jsx)(SD,{"aria-label":r,className:QP,children:(0,Z.jsx)(wD,{})}),(0,Z.jsx)(TD,{container:a,children:(0,Z.jsx)(eO,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsx)(xO,{className:`samva-editor-shell border-border bg-surface-elevated min-w-[var(--anchor-width)] rounded-lg border p-1 shadow-[var(--shadow-lg)]`,children:t.map(e=>(0,Z.jsx)(MO,{value:e.value,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(NO,{children:e.label})},e.value))})})})]})}function MF({label:e,part:t,segments:n,editable:r,onEdit:i}){let a=n??kF,o=`whatsapp-workspace.slot.${e.toLowerCase()}`;return(0,Z.jsxs)(`div`,{className:`grid gap-1.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-foreground font-medium`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:a.map((n,a)=>n.kind===`locked`?(0,Z.jsx)(bF,{summary:n.summary},`locked-${a}`):(0,Z.jsx)(`input`,{"aria-label":a===0?e:`${e} ${a+1}`,value:n.text,disabled:!r,"data-testid":a===0?o:`${o}.${a+1}`,onChange:e=>i({kind:`text`,part:t,segment:a,text:e.target.value},`whatsapp-${t}-${a}`),className:`${QP} min-w-[8ch] flex-1`},`text-${a}`))})]})}function NF({ariaLabel:e,state:t,editable:n,onChange:r,testId:i}){return(0,Z.jsx)(`input`,{"aria-label":e,"data-testid":i,value:AF(t),disabled:!n||t.kind===`expression`,title:t.kind===`expression`?`Read from the input. Edit it in Source.`:void 0,onChange:e=>r(e.target.value),className:QP})}function PF({buttons:e,editable:t,onEdit:n}){let[r,i]=(0,W.useState)(`quick-reply`);return(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Buttons`}),e.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`locked-${r}`):(0,Z.jsxs)(`div`,{className:`border-border grid gap-2 rounded-lg border p-3`,children:[(0,Z.jsx)(jF,{value:e.type,options:go,disabled:!t,ariaLabel:`Button ${r+1} type`,onChange:e=>n({kind:`buttonType`,button:r,type:e})}),(0,Z.jsx)(`input`,{"aria-label":`Button ${r+1} label`,value:e.text,disabled:!t,onChange:e=>n({kind:`buttonText`,button:r,text:e.target.value},`whatsapp-button-${r}-text`),className:QP}),e.type===`url`&&(0,Z.jsx)(NF,{ariaLabel:`Button ${r+1} URL`,state:e.url,editable:t,onChange:e=>n({kind:`buttonAttribute`,button:r,name:`url`,value:e},`whatsapp-button-${r}-url`)}),e.type===`phone`&&(0,Z.jsx)(NF,{ariaLabel:`Button ${r+1} phone`,state:e.phone,editable:t,onChange:e=>n({kind:`buttonAttribute`,button:r,name:`phone`,value:e},`whatsapp-button-${r}-phone`)}),t&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Remove button ${r+1}`,onClick:()=>n({kind:`buttonRemove`,button:r}),className:`text-muted-foreground hover:text-status-error justify-self-end text-[11.5px]`,children:`Remove`})]},`button-${r}`)),t&&(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(jF,{value:r,options:go,disabled:!1,ariaLabel:`New button type`,onChange:i}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`whatsapp-workspace.add-button`,onClick:()=>n({kind:`buttonAdd`,type:r}),className:`border-border hover:bg-muted shrink-0 rounded-lg border px-3 text-[12px]`,children:`Add`})]})]})}function FF({form:e,editable:t,onEdit:n}){let r=AF(e.category),i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(vF,{label:`Template name`,children:(0,Z.jsx)(NF,{ariaLabel:`Template name`,testId:`whatsapp-workspace.name`,state:e.name,editable:t,onChange:e=>n({kind:`attribute`,name:`name`,value:e},`whatsapp-name`)})}),(0,Z.jsx)(vF,{label:`Language`,children:(0,Z.jsx)(NF,{ariaLabel:`Language`,state:e.language,editable:t,onChange:e=>n({kind:`attribute`,name:`language`,value:e},`whatsapp-language`)})}),(0,Z.jsx)(vF,{label:`Category`,children:(0,Z.jsx)(jF,{value:r,options:mo,disabled:!t||e.category.kind!==`literal`,onChange:e=>n({kind:`attribute`,name:`category`,value:e})})}),(0,Z.jsx)(vF,{label:`Header type`,children:(0,Z.jsx)(jF,{value:i,options:ho,disabled:!t||e.header===null||e.headerType.kind===`expression`,onChange:e=>n({kind:`headerType`,value:e})})}),(0,Z.jsx)(MF,{label:`Header`,part:`header`,segments:e.header,editable:t,onEdit:n}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Body`}),e.body.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`body-locked-${r}`):(0,Z.jsx)(`textarea`,{"aria-label":`Body segment ${r+1}`,"data-testid":`whatsapp-workspace.body.${r+1}`,value:e.text,disabled:!t,onChange:e=>n({kind:`text`,part:`body`,segment:r,text:e.target.value},`whatsapp-body-${r}`),rows:4,className:`${QP} resize-y py-2`},`body-text-${r}`))]}),(0,Z.jsx)(MF,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,onEdit:n}),(0,Z.jsx)(PF,{buttons:e.buttons,editable:t,onEdit:n}),(0,Z.jsx)(SF,{variables:e.variables})]})}function IF({label:e,part:t,segments:n,editable:r,placeholder:i,className:a,onEdit:o}){return(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:(n??kF).map((n,s)=>n.kind===`locked`?(0,Z.jsx)(bF,{summary:n.summary},`locked-${s}`):(0,Z.jsx)(`input`,{"aria-label":s===0?`${e} preview`:`${e} preview ${s+1}`,"data-testid":s===0?`whatsapp-workspace.preview.${e.toLowerCase()}`:`whatsapp-workspace.preview.${e.toLowerCase()}.${s+1}`,value:n.text,readOnly:!r,placeholder:i,onChange:e=>o({kind:`text`,part:t,segment:s,text:e.target.value},`whatsapp-${t}-${s}`),className:`placeholder:text-muted-foreground/60 min-w-0 flex-1 bg-transparent outline-none ${a} ${r?`focus-visible:ring-ring/50 rounded-sm focus-visible:ring-2`:`cursor-default`}`},`text-${s}`))})}var LF=e=>e.type===`copy-code`?`Copy code`:e.text;function RF({form:e,editable:t,render:n,onEdit:r}){let i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`border-border mx-auto max-w-[420px] rounded-[28px] border bg-[#e9e2d8] p-5 shadow-[var(--shadow-lg)] dark:bg-[#0b141a]`,children:[(0,Z.jsx)(`div`,{"data-testid":`whatsapp-workspace.preview-heading`,className:`text-muted-foreground mb-4 text-center text-[12px] font-medium`,children:`WhatsApp business preview`}),(0,Z.jsxs)(`div`,{className:`bg-background rounded-xl px-3.5 py-3 shadow-[var(--shadow-sm)]`,children:[(0,Z.jsx)(IF,{label:`Header`,part:`header`,segments:e.header,editable:t&&i===`text`,placeholder:i===`text`?`Add header`:`${i} header`,className:`mb-1 font-semibold`,onEdit:r}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:e.body.map((e,n)=>e.kind===`locked`?(0,Z.jsx)(bF,{summary:e.summary},`body-locked-${n}`):(0,Z.jsx)(`textarea`,{"aria-label":`Body preview segment ${n+1}`,"data-testid":`whatsapp-workspace.body-preview.${n+1}`,value:e.text,readOnly:!t,placeholder:`Write your message`,rows:Math.max(1,e.text.split(`
27
- `).length),onChange:e=>r({kind:`text`,part:`body`,segment:n,text:e.target.value},`whatsapp-body-${n}`),className:`placeholder:text-muted-foreground/60 min-h-5 w-full resize-none overflow-hidden bg-transparent text-[14px] whitespace-pre-wrap outline-none ${t?`focus-visible:ring-ring/50 rounded-sm focus-visible:ring-2`:`cursor-default`}`},`body-text-${n}`))}),(0,Z.jsx)(IF,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,placeholder:`Add footer`,className:`text-muted-foreground mt-2 text-[11.5px]`,onEdit:r}),(n?.buttons??[]).map((e,t)=>(0,Z.jsx)(`div`,{className:`border-border-subtle text-accent-email mt-2 border-t pt-2 text-center text-[12px]`,children:LF(e)},`${LF(e)}-${t}`))]}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-4 text-center text-[11.5px] capitalize`,children:[n?.category??(AF(e.category)||`utility`),` template`]})]})}function zF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=mF(h_),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>d_(o),[o]),c=e?.channel===`whatsapp`?e.render:null;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(_F,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(`aside`,{className:`samva-editor-scroll border-border bg-background w-[400px] shrink-0 overflow-y-auto border-r p-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(xF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(wF,{reason:n}),s===null?(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[12.5px]`,children:[`The WhatsApp body is not a `,(0,Z.jsx)(`code`,{children:`<WhatsApp>`}),` written in place with a body, so it is edited in Source.`]}):(0,Z.jsx)(FF,{form:s,editable:t,onEdit:a})]})}),(0,Z.jsx)(`main`,{className:`samva-editor-workspace samva-editor-scroll min-w-0 flex-1 overflow-auto p-8`,children:s!==null&&(0,Z.jsx)(RF,{form:s,editable:t,render:c,onEdit:a})}),(0,Z.jsx)(lF,{})]})})})}var BF=e=>({top:e.top,left:e.left,width:e.width,height:e.height}),VF=(e,t)=>{let n=e.querySelectorAll(`[${Gc}="${CSS.escape(t)}"]`),r=null;for(let e of n){let t=BF(e.getBoundingClientRect());if(r??=t,t.width>0&&t.height>0)return t}return r},HF=`a[href],button,input[type="button"],input[type="submit"],input[type="image"]`,UF=e=>e!==null&&`closest`in e&&typeof e.closest==`function`,WF=e=>UF(e)&&e.closest(HF)!==null,GF=e=>UF(e)?e.closest(`[data-samva-instance]`)?.getAttribute(`data-samva-instance`)??null:null,KF=`html,body{margin:0;padding:0;overflow:hidden}`,qF={"--editor-canvas-hover":`#93c5fd`,"--editor-canvas-selected":`#2563eb`,"--editor-canvas-selected-fg":`#fff`,"--editor-canvas-generated":`#a855f7`},JF=e=>`:root{${Object.entries(qF).map(([t,n])=>`${t}:${e[t]?.trim()||n}`).join(`;`)}}`,YF=e=>{let t=e.parentElement;if(t===null)return{};let n=document.createElement(`span`);n.hidden=!0,t.appendChild(n);let r=Object.fromEntries(Object.keys(qF).map(e=>(n.style.color=`var(${e})`,[e,getComputedStyle(n).color])));return n.remove(),r},XF=/@media\s*\(\s*prefers-color-scheme:\s*dark\s*\)/g,ZF=(e,t)=>e.replace(XF,t===`dark`?`@media all`:`@media not all`),QF=e=>e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.button!==0,$F=e=>{let t=e.contentDocument;if(t===null)return null;let n=t.body.getBoundingClientRect(),r=Math.max(n.height,t.body.offsetHeight),i=Math.ceil(r>0?r:Math.max(t.body.scrollHeight,t.documentElement.scrollHeight));return e.style.height=`${i}px`,i},eI=({document_:e,width:t,dark:n,overlay:r,onSelect:i,onHover:a,onContextMenu:o})=>{let s=(0,W.useRef)(null),[c,l]=(0,W.useState)(null),u=(0,W.useRef)({onSelect:i,onHover:a,onContextMenu:o});return(0,W.useLayoutEffect)(()=>{u.current={onSelect:i,onHover:a,onContextMenu:o}},[i,a,o]),(0,W.useLayoutEffect)(()=>{let t=s.current;if(t===null)return;let n=null,r=()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,$F(t)}))},i=new ResizeObserver(r),a=new MutationObserver(r),o=()=>{let e=t.contentDocument;if(e===null)return;let n=e.head.querySelector(`style[data-samva-editor-chrome]`);n===null&&(n=e.createElement(`style`),n.dataset.samvaEditorChrome=``,e.head.appendChild(n)),n.textContent=`${KF}${JF(YF(t))}`},c=()=>{let n=t.contentDocument;n!==null&&(n.open(),n.write(e),n.close(),o(),l(n.body),i.disconnect(),i.observe(n.body),a.disconnect(),a.observe(n.body,{childList:!0,subtree:!0}),$F(t))},d=e=>{!QF(e)&&WF(e.target)&&e.preventDefault(),u.current.onSelect?.(GF(e.target))},f=e=>u.current.onHover?.(GF(e.target)),p=()=>u.current.onHover?.(null),m=e=>{let n=u.current.onContextMenu;if(n===void 0)return;e.preventDefault();let r=t.getBoundingClientRect(),i=t.clientWidth===0?1:r.width/t.clientWidth,a=t.clientHeight===0?1:r.height/t.clientHeight;n({instancePath:GF(e.target),clientX:r.left+e.clientX*i,clientY:r.top+e.clientY*a})},h=()=>{let e=t.contentDocument;e!==null&&(e.addEventListener(`click`,d),e.addEventListener(`mousemove`,f),e.addEventListener(`mouseleave`,p),e.addEventListener(`contextmenu`,m))},g=()=>{let e=t.contentDocument;e!==null&&(e.removeEventListener(`click`,d),e.removeEventListener(`mousemove`,f),e.removeEventListener(`mouseleave`,p),e.removeEventListener(`contextmenu`,m))};c(),h();let _=new MutationObserver(o);return _.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{g(),i.disconnect(),a.disconnect(),_.disconnect(),n!==null&&cancelAnimationFrame(n)}},[e]),(0,Z.jsx)(`iframe`,{ref:s,"data-testid":`canvas.frame`,title:`Email canvas`,sandbox:`allow-same-origin`,style:{width:t,height:0,display:`block`,border:`none`,background:n?`#0a0a0a`:`var(--editor-canvas-document-bg, #fff)`,colorScheme:n?`dark`:`light`},children:c!==null&&r!==void 0?(0,xS.createPortal)(r,c):null})},tI=({html:e,forceColorScheme:t,...n})=>{let r=t===void 0?e:ZF(e,t);return(0,Z.jsx)(eI,{document_:r,dark:t===`dark`,...n},r)},nI=(e,t,n)=>({position:`fixed`,top:e.top,left:e.left,width:e.width,height:e.height,outline:`${n}px solid ${t}`,outlineOffset:-n,pointerEvents:`none`,zIndex:2147483646}),rI=({renderRevision:e,selected:t,hovered:n})=>{let r=(0,W.useRef)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),c=t?.instancePath??null,l=n?.instancePath??null;return(0,W.useLayoutEffect)(()=>{let e=r.current?.ownerDocument;e!==void 0&&(a(c===null?null:VF(e,c)),s(l===null||l===c?null:VF(e,l)))},[e,c,l]),(0,Z.jsxs)(`div`,{ref:r,"data-samva-overlay":!0,style:{position:`fixed`,inset:0,pointerEvents:`none`},children:[o===null?null:(0,Z.jsx)(`div`,{style:nI(o,`var(--editor-canvas-hover)`,1)}),i!==null&&t!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:nI(i,t.authored?`var(--editor-canvas-selected)`:`var(--editor-canvas-generated)`,2)}),(0,Z.jsx)(`div`,{"data-samva-chip":!0,style:{position:`fixed`,top:Math.max(0,i.top-18),left:i.left,padding:`1px 6px`,borderRadius:4,background:t.authored?`var(--editor-canvas-selected)`:`var(--editor-canvas-generated)`,color:`var(--editor-canvas-selected-fg)`,font:`11px/1.4 ui-sans-serif, system-ui, sans-serif`,pointerEvents:`none`,zIndex:2147483647},children:t.authored?SN(t):`${SN(t)} · generated`})]}):null]})},iI=(e,t,n)=>{let r=new Map;for(let i of e.diagnostics??[])if(i.code===`caniemail/target-attribute`&&i.severity===`warning`)for(let e of i.occurrences??[i.origins]){let i=e[0];if(i===void 0)continue;let a=gg(t,n,i);if(a===null||a.tag!==`a`||a.hasSpread)continue;let o=a.properties.filter(e=>e.name===`target`),s=o[0];if(o.length!==1||s===void 0||s.kind!==`literal`||![`_self`,`_parent`,`_top`].includes(s.value))continue;let c=vg(t,s,`_blank`);c!==null&&r.set(c.start,c)}return[...r.values()].sort((e,t)=>e.start-t.start)};function aI({check:e}){let t=rF(`rail.assistant`)!==void 0,{doc:n,sourceEditable:r,pending:i,conflict:a,lifecycleBusy:o}=$(zO(e=>({doc:e.doc,sourceEditable:e.sourceEditable,pending:e.pendingAuthoredSource!==null,conflict:e.conflict,lifecycleBusy:e.lifecycleBusy}))),s=$(e=>e.actions.applySourceEdit),c=$(e=>e.actions.requestDiagnosticAssistance);if(n===null||!r)return null;let l=iI(e,n.origin.authoredSource,n.origin.file);if(l.length===0&&!t)return null;let u=e.diagnostics?.some(e=>Cs(e.code)),d=i||a||o;return(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[l.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:[`Set `,l.length,` local link target`,l.length===1?``:`s`,` to _blank to match these clients.`]}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`check.fix-target`,disabled:d,className:`border-border hover:bg-muted rounded border px-2 py-1 text-[11.5px] disabled:opacity-50`,onClick:()=>s({revision:n.rev,source:n.origin.authoredSource,edits:l}),children:`Use new-window links`})]}),t&&(0,Z.jsx)(`button`,{type:`button`,"data-testid":u?`check.upgrade-with-assistant`:`check.fix-with-assistant`,disabled:d,className:`border-border hover:bg-muted rounded border px-2 py-1 text-[11.5px] disabled:opacity-50`,onClick:()=>c(e),children:u?`Upgrade with Assistant`:`Fix with Assistant`})]})}var oI={risk:`Known risk`,unverified:`Needs verification`,degradation:`Expected differences`,"not-applicable":`Not affected`};function sI({check:e,actions:t}){return e.diagnostics===void 0?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-foreground text-[12.5px]`,children:e.label}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:e.detail})]}):(0,Z.jsxs)(`details`,{className:`min-w-0 flex-1`,"data-testid":`check.${e.id}`,children:[(0,Z.jsxs)(`summary`,{className:`text-foreground cursor-pointer text-[12.5px] break-words`,children:[e.label,(0,Z.jsx)(`span`,{className:`text-muted-foreground mt-0.5 block text-[11.5px]`,children:e.detail})]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-3 text-[11.5px] break-words`,children:[e.diagnostics.map((e,t)=>(0,Z.jsxs)(`div`,{className:`border-border-subtle border-l pl-2`,children:[e.compatibility!==void 0&&(0,Z.jsxs)(`p`,{className:`mb-1 font-medium`,children:[e.compatibility.title,` ·`,` `,oI[e.compatibility.assessment]]}),(0,Z.jsx)(`p`,{children:e.message}),e.clients!==void 0&&!e.clients.every(t=>e.message.includes(t))&&(0,Z.jsxs)(`p`,{className:`mt-1`,children:[`Clients: `,e.clients.join(`, `)]}),e.notes!==void 0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.notes}),(e.fixtures?.length??0)>0&&(0,Z.jsxs)(`p`,{className:`mt-1`,children:[`Fixtures: `,e.fixtures.join(`, `)]}),(e.occurrences??[e.origins]).map((e,t)=>e.length===0?null:(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 break-all`,children:e.map(xN).join(` → `)},t)),e.provenance!==void 0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.provenance})]},t)),(0,Z.jsx)(`p`,{className:`text-muted-foreground font-mono break-all`,children:e.diagnostics[0]?.code}),t]})]})}var cI=e=>e===void 0?`No default sender`:e.name?`${e.name} <${e.email}>`:e.email;function lI(){return(0,Z.jsx)(`span`,{title:`Overridable per send`,className:`border-border-subtle text-placeholder shrink-0 rounded-full border px-2 py-px text-[10px]`,children:`default`})}function uI({value:e,placeholder:t,testId:n}){return(0,Z.jsx)(`span`,{"data-testid":n,className:`text-foreground min-w-0 flex-1 truncate`,children:e.length>0?e:(0,Z.jsx)(`span`,{className:`text-placeholder`,children:t})})}function dI(){let{doc:e,render:t,selected:n,layoutMode:r}=$(zO(e=>({doc:e.doc,render:e.render,selected:e.selection.kind===`envelope`,layoutMode:e.layoutMode}))),{selectEnvelope:i}=$(e=>e.actions),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=(0,W.useRef)(!1),l=e?.metadata.fromDefault,u=e?.metadata.replyToDefault??[],d=t?.subject??``,f=t?.preheader??``,p=r===`compact`||r===`narrow`;return(0,W.useEffect)(()=>{p&&!a&&c.current&&(c.current=!1,s.current?.focus())},[p,a]),(0,Z.jsxs)(dk,{open:!p||a,onOpenChange:e=>{e||(c.current=!0),o(e)},children:[p&&!a&&(0,Z.jsxs)(pk,{ref:s,"aria-label":`Expand envelope`,"data-testid":`envelope.expand`,onClick:e=>{e.stopPropagation(),i()},className:JP(`mb-4 flex h-11 w-full items-center gap-3 rounded-xl border bg-background px-3 text-left shadow-[var(--shadow-xs)] transition-[border-color,box-shadow] hover:border-sel-mid`,n&&`border-accent-email shadow-[0_0_0_1px_var(--accent-email)]`),children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`Envelope`}),(0,Z.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-[12px]`,children:d===``?`No subject`:d}),(0,Z.jsx)(SP,{className:`text-muted-foreground size-4 shrink-0`})]}),(0,Z.jsx)(Ck,{children:(0,Z.jsxs)(`div`,{onClick:e=>{e.stopPropagation(),i()},className:JP(`mb-6 cursor-pointer overflow-hidden rounded-2xl border transition-shadow`,n?`border-accent-email shadow-[0_0_0_1px_var(--accent-email)]`:`border-border/80 hover:border-sel-mid`),children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle bg-surface-inset/80 flex items-center justify-between border-b px-3 py-1.5`,children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Select envelope`,"data-testid":`envelope.select`,onClick:e=>{e.stopPropagation(),i()},className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded px-1 py-0.5 text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`Envelope`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder text-[10px]`,children:`defaults muted · subject & preview rendered`}),p&&(0,Z.jsx)(pk,{"aria-label":`Collapse envelope`,"data-testid":`envelope.collapse`,onClick:e=>{e.stopPropagation()},className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded p-1`,children:(0,Z.jsx)(TP,{className:`size-3.5`})})]})]}),(0,Z.jsxs)(`div`,{className:`border-border-subtle bg-surface-inset/40 border-b`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`From`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate`,children:cI(l)}),(0,Z.jsx)(lI,{})]}),(0,Z.jsxs)(`div`,{"data-testid":`envelope.reply-to-row`,className:`flex items-center gap-3 px-4 py-2 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Reply-To`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate`,children:u.length>0?u.join(`, `):`None`}),(0,Z.jsx)(lI,{})]})]}),(0,Z.jsxs)(`div`,{className:`bg-background`,children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex items-center gap-3 border-b px-4 py-2.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Subject`}),(0,Z.jsx)(uI,{value:d,placeholder:`No subject`,testId:`envelope.subject-value`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Preview`}),(0,Z.jsx)(uI,{value:f,placeholder:`No preview text`,testId:`envelope.preview-value`})]})]})]})})]})}var fI=JP(`samva-editor-context-item`,`grid min-h-8 grid-cols-[1fr_auto] items-center gap-5 rounded-md px-2.5 text-[12.5px] text-foreground outline-none`,`data-[highlighted]:bg-sel-soft data-[highlighted]:text-accent-email`);function pI({children:e,ancestors:t,onSelect:n,onOpenChange:r,portalContainer:i,open:a,anchor:o}){return(0,Z.jsxs)(Zk,{open:a,onOpenChange:r,children:[(0,Z.jsx)($k,{render:e}),(0,Z.jsx)(Lk,{container:i,children:(0,Z.jsx)(eA,{anchor:o,sideOffset:2,children:(0,Z.jsxs)(Pk,{"aria-label":`Select element`,"data-testid":`node-context-menu.popup`,className:`samva-editor-context-popup samva-editor-shell border-border bg-surface-elevated z-50 min-w-52 rounded-lg border p-1 shadow-[var(--shadow-lg)] outline-none`,children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground px-2.5 py-1 text-[11px]`,children:`Select`}),t.map(e=>(0,Z.jsxs)(Nk,{className:fI,"data-testid":`node-context-menu.item.${e.instancePath}`,onClick:()=>n(e.instancePath),children:[(0,Z.jsx)(`span`,{children:e.label}),e.generated?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`generated`}):null]},e.instancePath))]})})})]})}function mI({name:e,className:t}){return(0,Z.jsx)(`span`,{className:JP(`inline-flex items-baseline rounded-md bg-accent-teal/20 px-1.5 py-px font-mono text-[0.82em] font-medium text-foreground ring-1 ring-inset ring-accent-teal/20`,t),children:`{{${e}}}`})}function hI({children:e}){return(0,Z.jsx)(`div`,{className:`text-muted-foreground mb-2 flex items-center justify-between text-[10.5px] font-semibold tracking-[0.06em] uppercase`,children:e})}function gI({children:e,className:t,title:n,help:r=n,pressed:i,onClick:a,disabled:o,testId:s}){let c=dF();return(0,Z.jsxs)(ET,{disabled:o,children:[(0,Z.jsx)(PT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":n,"aria-pressed":i,disabled:o,"data-testid":s,onClick:a,className:JP(`inline-flex h-7.5 items-center gap-1.5 rounded-[7px] px-2.5 text-muted-foreground outline-none transition-all hover:bg-muted hover:text-foreground active:translate-y-px disabled:opacity-40`,`aria-pressed:bg-[var(--editor-pressed-bg)] aria-pressed:shadow-[var(--editor-pressed-shadow)]`,`aria-pressed:text-accent-foreground`,YP,t)}),children:e}),(0,Z.jsx)(RT,{container:c,children:(0,Z.jsx)(sE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(cE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:r})})})]})}function _I({ariaLabel:e,options:t,value:n,onChange:r,size:i=`md`,testId:a}){let o=dF();return(0,Z.jsx)($O,{"aria-label":e,value:[n],"data-testid":a,onValueChange:e=>{let t=e[0];t!==void 0&&r(t)},className:JP(`bg-muted inline-flex gap-0.5 rounded-lg p-0.5`,i===`sm`&&`rounded-[7px]`),children:t.map(e=>{let t=(0,Z.jsx)(KO,{type:`button`,"aria-label":e.title,"data-testid":e.testId,value:e.value,className:JP(ZP,i===`sm`?`h-6 px-2 text-xs`:`h-7 px-2.5 text-xs`),children:e.label},e.value);return e.title===void 0?t:(0,Z.jsxs)(ET,{children:[(0,Z.jsx)(PT,{render:t}),(0,Z.jsx)(RT,{container:o,children:(0,Z.jsx)(sE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(cE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:e.title})})})]},e.value)})})}function vI({children:e,className:t,overridden:n,testId:r}){return(0,Z.jsxs)(`span`,{"data-testid":r,className:JP(`inline-flex h-7 max-w-[170px] items-center gap-1.5 overflow-hidden rounded-[7px] border border-border bg-background px-2.5 font-mono text-xs whitespace-nowrap text-foreground`,n&&`border-accent-email/40 bg-sel-soft ring-1 ring-accent-email/20`,t),title:n?`Overridden on mobile`:void 0,children:[e,n&&(0,Z.jsx)(`span`,{className:`text-accent-email ml-auto text-[9px] font-semibold tracking-wide uppercase`,children:`M`})]})}function yI({pointing:e=!1}){let{doc:t,render:n,outline:r,selection:i,previewDevice:a,canvasZoom:o}=$(zO(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,previewDevice:e.previewDevice,canvasZoom:e.canvasZoom}))),{select:s,selectDocument:c,setHovered:l,setPreviewDevice:u,setCanvasZoom:d}=$(e=>e.actions),f=$(e=>e.hoveredCandidatePath===null?null:e.outline?.index.get(e.hoveredCandidatePath)??null),p=dF(),m=iF(`canvas.overlay`),h=(0,W.useRef)(null),[g,_]=(0,W.useState)(1),[v,y]=(0,W.useState)([]),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(null),w=i.kind===`element`?r?.index.get(i.instancePath)??null:null,T=a===`mobile`?375:600;(0,W.useLayoutEffect)(()=>{let e=h.current;if(e===null||typeof ResizeObserver>`u`)return;let t=()=>{let t=Math.max(240,e.clientWidth-80);_(Math.min(1,Math.max(.5,t/T)))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[T]);let E=o===`fit`?g:1,D=(0,W.useCallback)(t=>{if(e||r===null||t.instancePath===null){x(!1);return}let n=[...DN(r,t.instancePath),t.instancePath].toReversed().flatMap(e=>{let t=r.index.get(e);return t===void 0?[]:[{instancePath:e,label:SN(t),generated:!t.authored}]});if(n.length===0){x(!1);return}s(t.instancePath),y(n);let{clientX:i,clientY:a}=t;C({getBoundingClientRect:()=>DOMRect.fromRect({x:i,y:a})}),queueMicrotask(()=>x(!0))},[r,e,s]),O=n===null?null:(0,Z.jsx)(tI,{html:n.html,width:T,onSelect:s,onHover:l,onContextMenu:e?void 0:D,overlay:(0,Z.jsx)(rI,{renderRevision:n.revision,selected:w,hovered:f})});return(0,Z.jsxs)(`div`,{className:`samva-editor-workspace relative flex min-w-0 flex-1 flex-col`,children:[m.length>0&&(0,Z.jsx)(`div`,{"data-samva-canvas-status":!0,className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:m.map(e=>(0,Z.jsx)(W.Fragment,{children:e.render()},e.id))}),(0,Z.jsx)(`div`,{ref:h,"data-samva-canvas-viewport":!0,className:`samva-editor-scroll relative flex-1 overflow-auto px-10 pt-10 pb-24 [overflow-anchor:none]`,onClick:c,children:t===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid h-full place-items-center text-[12.5px]`,children:`Loading document…`}):(0,Z.jsxs)(`div`,{className:`mx-auto`,"data-canvas-zoom":o,style:{width:T,zoom:E},onClick:e=>e.stopPropagation(),children:[t.channel===`email`&&t.preview.status===`stale`&&(0,Z.jsxs)(`div`,{"data-testid":`canvas.preview-stale`,className:`border-warning/35 bg-warning/10 text-foreground mb-3 rounded-[9px] border px-3 py-2 text-[12px] shadow-sm`,children:[`Showing the last preview that worked. Your latest edit has a problem:`,` `,t.preview.reason]}),(0,Z.jsx)(dI,{}),O===null?(0,Z.jsx)(bI,{}):e?O:(0,Z.jsx)(pI,{ancestors:v,onSelect:s,portalContainer:p,anchor:S??void 0,open:b,onOpenChange:e=>x(e&&v.length>0),children:O})]})}),t!==null&&(0,Z.jsxs)(`div`,{className:`border-border bg-background/95 absolute bottom-3 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1 rounded-[9px] border p-1 shadow-[var(--shadow-lg)] backdrop-blur-md`,children:[(0,Z.jsx)(_I,{ariaLabel:`Canvas preview width`,value:a,onChange:e=>u(e),size:`sm`,options:[{value:`desktop`,title:`Preview desktop width`,testId:`canvas.device.desktop`,label:(0,Z.jsx)(LP,{className:`size-[13px]`})},{value:`mobile`,title:`Preview mobile width`,testId:`canvas.device.mobile`,label:(0,Z.jsx)(IP,{className:`size-[13px]`})}]}),(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`canvas.zoom`,title:o===`fit`?`Show canvas at 100%`:`Fit canvas to workspace`,"aria-label":o===`fit`?`Show canvas at 100%`:`Fit canvas to workspace`,onClick:()=>d(o===`fit`?`100`:`fit`),className:JP(`text-muted-foreground hover:bg-muted hover:text-foreground inline-flex h-7 items-center gap-1.5 rounded-[6px] px-2 text-[11.5px] transition-colors`,o===`fit`&&`bg-sel-soft text-accent-email`),children:[(0,Z.jsx)(yP,{className:`size-[14px]`}),o===`fit`?`Fit`:`100%`]})]})]})}function bI(){let e=$(zO(e=>e.checks.filter(e=>e.severity===`error`))),t=e.length>0;return(0,Z.jsxs)(`div`,{"data-testid":`canvas.unbuilt`,"data-unbuilt-reason":t?`failed`:`not-built`,className:`border-border bg-surface-inset text-foreground rounded-xl border border-dashed p-6 text-[12.5px]`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:t?`No preview`:`No preview yet`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:t?`The current draft broke the preview. Fix the source and it will come back.`:`Nothing has run this entry yet. The next pass puts the preview here.`}),t&&(0,Z.jsx)(`ul`,{className:`mt-4 space-y-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(sI,{check:e,actions:(0,Z.jsx)(aI,{check:e})})},e.id))})]})}function xI({checks:e,editable:t=!1}){let{actionable:n}=JN(e),r=e.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)).length;return(0,Z.jsxs)(`section`,{className:`space-y-3`,"aria-label":`Needs attention`,children:[(0,Z.jsxs)(`h3`,{className:`text-foreground text-[13px] font-semibold`,children:[`Needs attention`,n.length>0?` · ${n.length}`:``]}),n.length===0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.length===0?`No checks yet.`:`No known risks found.`}):n.map(e=>(0,Z.jsx)(sI,{check:e,actions:t?(0,Z.jsx)(aI,{check:e}):void 0},e.id)),(0,Z.jsx)(SI,{checks:e,editable:t}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:r>0?`${r} finding group${r===1?` needs`:`s need`} client verification.`:`These checks do not confirm rendering in every inbox.`})]})}function SI({checks:e,editable:t=!1}){let n=dF(),r=Object.fromEntries(Object.keys(oI).map(t=>[t,e.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===t)).length])),[i,a]=(0,W.useState)(`all`),[o,s]=(0,W.useState)(`all`),c=[...new Set(e.flatMap(e=>e.diagnostics?.flatMap(e=>e.clients??[])??[]))].sort(),l=e.flatMap(e=>{if(e.diagnostics===void 0)return i===`all`&&o===`all`?[e]:[];let t=e.diagnostics.filter(e=>(i===`all`||e.compatibility?.assessment===i)&&(o===`all`||e.clients?.includes(o)));return t.length===0?[]:[WN(e.id,t)]}),u=e=>e.severity===`error`||e.severity===`warn`?0:e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)?1:e.diagnostics?.some(e=>e.compatibility?.assessment===`degradation`)?2:3;return l.sort((e,t)=>u(e)-u(t)),(0,Z.jsxs)(rj,{onOpenChange:e=>{e&&(a(r.unverified>0?`unverified`:`all`),s(`all`))},children:[(0,Z.jsx)(oj,{"data-testid":`checks.compatibility-report`,className:`border-border text-foreground hover:bg-muted rounded-md border px-2.5 py-1.5 text-xs`,children:`Compatibility report`}),(0,Z.jsxs)(XA,{container:n,children:[(0,Z.jsx)(VA,{className:`fixed inset-0 z-[130] bg-black/30`}),(0,Z.jsxs)(YA,{"data-testid":`checks.report`,className:`samva-editor-shell border-border bg-surface-elevated text-foreground fixed top-1/2 left-1/2 z-[131] flex max-h-[85dvh] w-[min(840px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border p-5 shadow-xl`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(aj,{className:`text-lg font-semibold`,children:`Compatibility report`}),(0,Z.jsx)(HA,{"data-testid":`checks.report.close`,"aria-label":`Close compatibility report`,className:`hover:bg-muted rounded border px-2 py-1 text-xs`,children:`Close`})]}),(0,Z.jsx)(UA,{className:`text-muted-foreground mt-2 text-sm`,children:`Client verification remains. Review known risks, unverified behavior and fallbacks before testing in your recipients’ inboxes.`}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:[Object.entries(oI).map(([e,t])=>`${r[e]} ${t.toLowerCase()}`).join(` · `),`. Groups can appear in more than one category.`]}),(0,Z.jsxs)(`div`,{className:`my-4 flex flex-wrap gap-3 text-xs`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[`Assessment`,(0,Z.jsxs)(`select`,{"data-testid":`checks.report.assessment`,"aria-label":`Assessment`,value:i,onChange:e=>a(e.target.value),className:`border-border bg-background rounded border p-2`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All assessments`}),Object.entries(oI).map(([e,t])=>(0,Z.jsxs)(`option`,{value:e,children:[t,` (`,r[e],`)`]},e))]})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[`Client`,(0,Z.jsxs)(`select`,{"data-testid":`checks.report.client`,"aria-label":`Client`,value:o,onChange:e=>s(e.target.value),className:`border-border bg-background rounded border p-2`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All clients`}),c.map(e=>(0,Z.jsx)(`option`,{children:e},e))]})]})]}),(0,Z.jsx)(`div`,{className:`samva-editor-scroll min-h-0 space-y-4 overflow-y-auto`,children:l.length===0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No evidence matches these filters.`}):l.map(e=>(0,Z.jsx)(`div`,{className:`border-border-subtle border-t pt-3`,children:(0,Z.jsx)(sI,{check:e,actions:t?(0,Z.jsx)(aI,{check:e}):void 0})},e.id))})]})]})]})}var CI=JP(`border-border bg-background text-foreground w-full rounded border px-2 py-1.5 text-xs`,YP),wI=JP(`border-border hover:bg-muted rounded border px-2 py-1 text-xs disabled:opacity-50`,YP);function TI({field:e,source:t,propose:n,apply:r}){let[i,a]=(0,W.useState)(e.value),[o,s]=(0,W.useState)(e.kind===`literal`&&e.literalType===`string`?JSON.stringify(e.value):e.value);return(0,Z.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[EI(e.name),` · `,e.kind,e.kind===`literal`?(0,Z.jsx)(`input`,{"aria-label":`${e.name} literal`,"data-testid":`source.property.${e.name}.literal`,type:e.literalType===`number`?`number`:`text`,className:CI,value:i,onChange:e=>a(e.target.value)}):(0,Z.jsx)(`code`,{className:`bg-muted mt-1 block rounded p-2 break-all`,children:e.value})]}),e.kind===`literal`&&(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.apply`,type:`button`,className:wI,disabled:vg(t,e,i)===null,onClick:()=>{let n=vg(t,e,i);n!==null&&r(n)},children:`Apply literal`}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{"data-testid":`source.property.${e.name}.expression-toggle`,className:`cursor-pointer text-xs`,children:e.kind===`literal`?`Change to a binding or expression`:`Review a binding or expression change`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground my-1 text-xs`,children:`This changes template logic. Fixture values are edited separately.`}),(0,Z.jsx)(`textarea`,{"aria-label":`${e.name} expression`,"data-testid":`source.property.${e.name}.expression`,className:CI,value:o,onChange:e=>s(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.review`,type:`button`,className:wI,onClick:()=>n(yg(t,e,o)),children:`Review expression diff`})]})]})}var EI=e=>e===`children`||e.startsWith(`text.`)?`Text`:e===`className`?`Style classes`:e,DI=e=>e instanceof Error&&e.message!==``?e.message:`The host could not save this.`;function OI(e){let t=$(e=>e.lifecycleCapability),{flushSaves:n}=$(e=>e.actions),[r,i]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(e===null||t?.status!==`ready`)return;let r=!1;return n().then(()=>t.api.inspect()).then(e=>{if(r)return;let t={};for(let n of e.files)n.binary!==!0&&n.status!==`deleted`&&n.content!==null&&(t[n.path]=n.content);i(t)}).catch(()=>{r||i(`failed`)}),()=>{r=!0}},[e,t,n]),e===null?{status:`entry`}:t?.status===`ready`?r===null?{status:`loading`}:r===`failed`?{status:`unavailable`}:{status:`ready`,files:r,api:t.api}:{status:`unavailable`}}function kI(e){return e.busy?`Waiting for the latest source to render.`:e.file!==null&&e.project===`loading`?`Reading ${e.file}.`:e.file!==null&&e.project===`unavailable`?`This element is written in ${e.file}, outside the template entry, and this host cannot edit project files from here. Open Source or ask the agent.`:e.resolved?`This source is read-only.`:`This origin cannot be resolved in its file. Open its source or ask the agent.`}function AI(e,t){return`${e.occurrences>1?`This element renders ${e.occurrences} times here (a loop or a repeated component), so one edit changes all ${e.occurrences}.`:`This changes this element.`}${t?` It is written in a partial, so every template that uses the partial changes too.`:``} Fixture items remain separate data.`}function jI({selection:e}){let{doc:t,pending:n,revision:r,editable:i,storeError:a,lifecycleBusy:o}=$(zO(e=>({doc:e.doc,pending:e.pendingAuthoredSource,revision:e.render?.revision,editable:e.sourceEditable,storeError:e.sourceEditError,lifecycleBusy:e.lifecycleBusy}))),{applySourceEdit:s,openSource:c,requestSourceAssistance:l,beginLifecycle:u,endLifecycle:d}=$(e=>e.actions),{flushSaves:f}=$(e=>e.actions),p=rF(`rail.assistant`)!==void 0,[m,h]=(0,W.useState)(0),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(``),[w,T]=(0,W.useState)(`<p>New content</p>`),[E,D]=(0,W.useState)(``),[O,k]=(0,W.useState)(null),[A,j]=(0,W.useState)(null),M=e.origins[m],N=t?.origin.file,P=M!==void 0&&M.fileName!==N,F=OI(P?M.fileName:null);if(t===null||N===void 0)return null;let I=t.origin.authoredSource,L=P&&M!==void 0?F.status===`ready`?F.files[M.fileName]??null:null:I,R=M===void 0||L===null?null:gg(L,M.fileName,M),ee=P?{entry:N,file:M.fileName,files:{...F.status===`ready`?F.files:{},[N]:I}}:{entry:N},z=i&&n===null&&!o&&!b&&r===t.rev&&R!==null&&L!==null,te=e=>{let t=xg(L??``,e,{profile:ee});return{edits:e,refusal:t.ok?null:t.reason}},ne=e=>{if(L===null)return;if(y(null),_(null),!P){s({revision:r??``,source:L,edits:e});return}let t=xg(L,e,{profile:ee});if(!t.ok){y(t.reason);return}F.status===`ready`&&u()&&(x(!0),f().then(e=>F.api.updateFile({path:M.fileName,baseRev:e,content:t.source})).catch(e=>y(DI(e))).finally(()=>{d(),x(!1)}))},re=e=>{ne([e]),j(null)},B=v??a,ie=R?.properties.find(e=>e.name===`className`),ae=R===null||L===null||ie?.kind===`literal`?null:(()=>{let e=Og(L,R,{kind:`add`,tokens:`x`});return e.ok?null:e.reason})(),oe=e.origins.length>1;return(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Source properties`}),oe&&(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[`Edit scope`,(0,Z.jsx)(`select`,{"aria-label":`Edit scope`,"data-testid":`source.scope`,className:CI,value:m,onChange:e=>{h(Number(e.target.value)),j(null)},children:e.origins.map((e,t)=>(0,Z.jsxs)(`option`,{value:t,children:[t===0?`Element`:`Call site ${t}`,` · `,xN(e)]},t))})]}),(0,Z.jsx)(`p`,{"data-testid":`source.scope-note`,className:`text-muted-foreground mt-2 text-xs`,children:oe&&m>0?`Changes this call site, including every loop iteration it produces. Fixture items remain separate data.`:AI(e,P)}),P&&(0,Z.jsxs)(`p`,{"data-testid":`source.partial-warning`,className:`border-border bg-muted mt-2 rounded border p-2 text-xs`,children:[`Edits apply to every template that uses this partial (`,M.fileName,`).`]}),z?(0,Z.jsxs)(Z.Fragment,{children:[R.properties.length===0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:`No unambiguous scalar properties here. Use source or the agent for this shape.`}),R.hasSpread&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:`Spread properties can override attributes here. Edit attributes in Source or ask the agent.`}),R.properties.filter(e=>!R.hasSpread||e.syntax===`child`).map(e=>(0,Z.jsx)(TI,{field:e,source:L,apply:re,propose:e=>j(te([e]))},`${t.rev}:${L}:${m}:${e.name}`)),ae!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.class-refusal`,className:`text-muted-foreground mt-3 text-xs`,children:ae}),ae===null&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[ie===void 0?`Style classes · literal`:`Add style classes`,(0,Z.jsx)(`input`,{"aria-label":`Style classes`,"data-testid":`source.classes`,className:CI,value:S,onChange:e=>C(e.target.value)})]}),(0,Z.jsx)(`button`,{"data-testid":`source.classes-add`,type:`button`,className:wI,disabled:S.trim()===``,onClick:()=>{let e=Og(L,R,{kind:`add`,tokens:S});e.ok?ne(e.edits):y(e.reason),C(``)},children:ie===void 0?`Apply styles`:`Add classes`})]}),(0,Z.jsxs)(`details`,{className:`mt-3`,children:[(0,Z.jsx)(`summary`,{"data-testid":`source.structure-toggle`,className:`cursor-pointer text-xs`,children:`Structure · authored block`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground my-2 text-xs`,children:`This changes the whole source block at the scope above. A rendered loop instance has no independent source block. Change fixture items separately; edit loop or conditional logic in Source.`}),(0,Z.jsx)(`textarea`,{"aria-label":`Insert TSX`,"data-testid":`source.insert`,value:w,className:CI,onChange:e=>T(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.review-insert`,type:`button`,className:wI,disabled:R.contentEnd===null,onClick:()=>{let e=wg(L,R,{kind:`insert`,tsx:w});k(e===null?null:te(e))},children:`Review insert`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-delete`,type:`button`,className:wI,disabled:!R.structural,onClick:()=>{let e=wg(L,R,{kind:`delete`});k(e===null?null:te(e))},children:`Review delete`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-duplicate`,type:`button`,className:wI,disabled:!R.structural,onClick:()=>{let e=wg(L,R,{kind:`duplicate`});k(e===null?null:te(e))},children:`Review duplicate`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-move-up`,type:`button`,className:wI,disabled:R.previous===null,onClick:()=>{let e=wg(L,R,{kind:`reorder`,direction:`before`});k(e===null?null:te(e))},children:`Move earlier`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-move-down`,type:`button`,className:wI,disabled:R.next===null,onClick:()=>{let e=wg(L,R,{kind:`reorder`,direction:`after`});k(e===null?null:te(e))},children:`Move later`}),!P&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`mt-2 block text-xs`,children:[`Move into shared source container`,(0,Z.jsxs)(`select`,{"aria-label":`Move destination`,"data-testid":`source.destination`,value:E,className:CI,onChange:e=>D(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose destination`}),t.channel===`email`&&t.render?.selections.map(e=>(0,Z.jsxs)(`option`,{value:e.instancePath,children:[e.tag,` · `,e.instancePath,` ·`,` `,e.origins[0]===void 0?`generated`:xN(e.origins[0])]},e.instancePath))]})]}),(0,Z.jsx)(`button`,{"data-testid":`source.review-move`,type:`button`,className:wI,disabled:!R.structural||E===``,onClick:()=>{let e=(t.channel===`email`?t.render?.selections.find(e=>e.instancePath===E):void 0)?.origins[0],n=e===void 0?null:gg(L,N,e),r=n===null?null:wg(L,R,{kind:`move`,destination:n});k(r===null?null:te(r)),_(r===null?`This destination cannot accept the selected block. Choose another source container or use Source.`:null)},children:`Review move`})]}),g!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error text-xs`,children:g}),O!==null&&(0,Z.jsxs)(`div`,{role:`region`,"aria-label":`Structural source diff`,className:`mt-2`,children:[(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:O.edits.map(e=>`- ${e.before}\n+ ${e.after}`).join(`
28
- `)}),O.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.structure-refusal`,className:`text-status-error text-xs`,children:O.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-structure`,type:`button`,className:wI,disabled:O.refusal!==null,onClick:()=>{ne(O.edits),k(null)},children:`Apply structural change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:()=>k(null),children:`Cancel`})]})]}),A!==null&&(0,Z.jsxs)(`div`,{role:`region`,"aria-label":`Proposed source diff`,className:`mt-3 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs`,children:`Review the exact source change`}),(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:A.edits.map(e=>`- ${e.before}\n+ ${e.after}`).join(`
29
- `)}),A.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.proposal-refusal`,className:`text-status-error text-xs`,children:A.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-reviewed`,type:`button`,className:wI,disabled:A.refusal!==null,onClick:()=>{ne(A.edits),j(null)},children:`Apply reviewed change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:()=>j(null),children:`Cancel`})]})]}):(0,Z.jsx)(`p`,{"data-testid":`source.unavailable`,className:`text-muted-foreground mt-2 text-xs`,children:kI({busy:n!==null||b||o,file:P?M.fileName:null,project:F.status,resolved:R!==null})}),B!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.edit-error`,className:`text-status-error mt-2 text-xs`,children:B}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:c,children:`Open source`}),p&&(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:()=>l(m),children:`Ask agent`})]})]})}function MI(){let{undo:e,redo:t,error:n,editable:r}=$(zO(e=>({undo:e.undoHistory.length,redo:e.redoHistory.length,error:e.sourceEditError,editable:e.sourceEditable}))),i=$(e=>e.actions);return(0,Z.jsxs)(`div`,{className:`border-border border-b px-3 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`button`,{"data-testid":`source.undo`,type:`button`,className:wI,disabled:!r||e===0,onClick:i.undo,children:`Undo`}),(0,Z.jsx)(`button`,{"data-testid":`source.redo`,type:`button`,className:wI,disabled:!r||t===0,onClick:i.redo,children:`Redo`})]}),n!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error mt-1 text-xs`,children:n})]})}function NI(){let e=$(e=>e.doc),t=$(e=>e.pendingAuthoredSource),n=$(e=>e.sourceEditable),{applySourceEdit:r,openSource:i}=$(e=>e.actions),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(!1);if(e?.channel!==`email`)return null;let l=Eg(e.origin.authoredSource).find(t=>t.name===e.fixture);return(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsxs)(hI,{children:[`Fixture data · `,e.fixture]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Example input for this fixture. Changes do not replace template bindings or change other fixtures.`}),l===void 0?(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:i,children:`Open fixture source`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`textarea`,{"aria-label":`Fixture data source`,"data-testid":`source.fixture-data`,className:CI,value:a??l.source,onChange:e=>{o(e.target.value),c(!1)},disabled:!n||t!==null}),(0,Z.jsx)(`button`,{"data-testid":`source.fixture-review`,type:`button`,className:wI,disabled:!n||t!==null||a===null,onClick:()=>c(!0),children:`Review fixture change`}),s&&a!==null&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:`- ${l.source}\n+ ${a}`}),(0,Z.jsx)(`button`,{"data-testid":`source.fixture-apply`,type:`button`,className:wI,onClick:()=>{r({revision:e.rev,source:e.origin.authoredSource,edits:[{start:l.start,end:l.end,before:l.source,after:a}]}),o(null),c(!1)},children:`Apply fixture change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:()=>{o(null),c(!1)},children:`Cancel`})]})]})]})}function PI({selection:e}){let t=$(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(jI,{selection:e},t)}function FI(){let e=$(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(NI,{},e)}var II=[],LI=[],RI=[];function zI({label:e,title:t,children:n}){return(0,Z.jsxs)(`div`,{title:t,className:`mt-1.5 flex items-center justify-between gap-2 first:mt-0`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e}),n]})}function BI(){let e=$(e=>e.doc?.variables??LI);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Variables`}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[12.5px]`,children:[(0,Z.jsx)(mI,{name:e.name,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`text-placeholder ml-auto text-[11px]`,children:e.required?`required`:`optional`})]},e.name))}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2.5 text-[11.5px]`,children:`The canvas shows the values of the fixture selected in the toolbar.`})]})}function VI(){let e=$(e=>e.checks),t=$(e=>e.sourceEditable);return(0,Z.jsx)(`div`,{className:`py-3`,children:(0,Z.jsx)(xI,{checks:e,editable:t})})}function HI(){let{deviceWidth:e,entryFile:t,fixture:n,fixtures:r}=$(zO(e=>({deviceWidth:QN[e.previewDevice],entryFile:e.doc?.origin.file??null,fixture:e.doc?.channel===`email`?e.doc.fixture:null,fixtures:e.doc?.channel===`email`?e.doc.fixtures:II})));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Document`}),(0,Z.jsx)(zI,{label:`Width`,children:(0,Z.jsxs)(vI,{children:[e,` `,(0,Z.jsx)(`span`,{className:`text-placeholder text-[10.5px]`,children:`px`})]})}),t!==null&&(0,Z.jsx)(zI,{label:`Entry`,children:(0,Z.jsx)(vI,{children:t})}),n!==null&&(0,Z.jsx)(zI,{label:`Fixture`,title:`${r.length} declared`,children:(0,Z.jsx)(vI,{children:n})})]}),(0,Z.jsx)(FI,{},`${n}:${t}`),(0,Z.jsx)(BI,{}),(0,Z.jsx)(VI,{})]})}function UI({value:e,onChange:t,onCommit:n,placeholder:r,type:i=`text`,testId:a}){return(0,Z.jsx)(`input`,{type:i,value:e,placeholder:r,"data-testid":a,spellCheck:!1,onChange:e=>t(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:JP(`border-border bg-background text-foreground placeholder:text-placeholder h-7 max-w-none min-w-0 flex-1 rounded-[5px] border px-2.5 text-xs outline-none`,YP)})}function WI(){let e=$(e=>e.doc),t=$(e=>e.metadataError),{saveMetadata:n}=$(e=>e.actions),r=e?.metadata.fromDefault,[i,a]=(0,W.useState)(r?.name??``),[o,s]=(0,W.useState)(r?.email??``),[c,l]=(0,W.useState)((e?.metadata.replyToDefault??[]).join(`, `)),u=()=>{let e=o.trim();n({fromDefault:e.length===0?null:{email:e,name:i.trim()||void 0}})};return(0,Z.jsxs)(`div`,{className:`py-3`,children:[(0,Z.jsx)(hI,{children:`Defaults · per send`}),(0,Z.jsx)(zI,{label:`From name`,children:(0,Z.jsx)(UI,{value:i,onChange:a,onCommit:u,placeholder:`Sender name`})}),(0,Z.jsx)(zI,{label:`From email`,children:(0,Z.jsx)(UI,{type:`email`,value:o,onChange:s,onCommit:u,placeholder:`you@domain.com`,testId:`inspector.envelope.from-email`})}),(0,Z.jsx)(zI,{label:`Reply-To`,children:(0,Z.jsx)(UI,{type:`email`,value:c,onChange:l,onCommit:()=>{let e=c.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);n({replyToDefault:e.length===0?null:e})},placeholder:`Comma-separated`})}),t!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error mt-2 text-[11.5px]`,children:t})]})}function GI(){let e=$(e=>e.metadataEditable),t=$(e=>e.render);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-border-subtle text-muted-foreground border-b py-2.5 text-[11px] leading-relaxed`,children:`Subject and preview text come from the template code and the fixture on screen. From / Reply-To are template defaults, overridden per send.`}),(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Rendered`}),(0,Z.jsx)(zI,{label:`Subject`,children:(0,Z.jsx)(vI,{children:t?.subject??`No subject`})}),(0,Z.jsx)(zI,{label:`Preview`,children:(0,Z.jsx)(vI,{children:t?.preheader??`No preview text`})})]}),e?(0,Z.jsx)(WI,{}):(0,Z.jsx)(`p`,{className:`text-muted-foreground py-3 text-xs`,children:`This host does not edit sender defaults.`})]})}function KI({selection:e}){let t=$(e=>e.render?.selections??RI),{select:n}=$(e=>e.actions),r=e.origins[0],i=e.origins.slice(1),a=Yc(t,e),o=Xc(t,e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Element`}),(0,Z.jsx)(zI,{label:`Tag`,children:(0,Z.jsx)(vI,{testId:`inspector.element.tag`,children:e.tag})}),(0,Z.jsx)(zI,{label:`Source`,title:e.authored?`This element was written in the template.`:`A compiler primitive produced this element; the authoring below is the call that asked for it.`,children:(0,Z.jsx)(vI,{testId:`inspector.element.provenance`,children:e.authored?`Authored`:`Generated`})}),(0,Z.jsx)(zI,{label:`Instance`,children:(0,Z.jsx)(vI,{testId:`inspector.element.instance`,children:e.instancePath})})]}),(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Authoring`}),r===void 0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:`The renderer produced this element with no authoring on the stack, so nothing in the template points at it.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(zI,{label:`Written at`,children:(0,Z.jsx)(vI,{testId:`inspector.authoring.origin`,children:xN(r)})}),(0,Z.jsx)(`p`,{"data-testid":`inspector.authoring.occurrence`,className:`text-muted-foreground mt-2 text-[11.5px]`,children:e.occurrences>1?`This authoring renders ${e.occurrences} elements here; this is number ${e.occurrence}.`:`This authoring renders one element here.`}),o.length>a.length&&(0,Z.jsxs)(`p`,{"data-testid":`inspector.authoring.definition-scope`,className:`text-muted-foreground mt-1 text-[11.5px]`,children:[o.length,` elements across the whole render come from it, through more than one call site.`]})]})]}),(0,Z.jsx)(PI,{selection:e},`${e.instancePath}:${e.start}:${e.end}`),i.length>0&&(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Call sites`}),(0,Z.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:i.map((e,t)=>(0,Z.jsx)(`li`,{"data-testid":`inspector.call-site.${t}`,className:`text-foreground font-mono text-[11.5px] break-all`,children:xN(e)},`${xN(e)}:${t}`))}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-[11.5px]`,children:`Innermost call first.`})]}),a.length>1&&(0,Z.jsxs)(`div`,{className:`py-3`,children:[(0,Z.jsx)(hI,{children:`Iterations`}),(0,Z.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:a.map((t,r)=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`inspector.iteration.${t.instancePath}`,onClick:()=>n(t.instancePath),className:JP(`hover:bg-muted w-full rounded px-1.5 py-1 text-left font-mono text-[11.5px]`,t.instancePath===e.instancePath&&`bg-sel-soft text-accent-email`),children:[r+1,`. `,t.instancePath]})},t.instancePath))})]})]})}function qI({embedded:e=!1}={}){let t=dF(),{outline:n,selection:r,rightCollapsed:i,rightWidth:a,layoutMode:o}=$(zO(e=>({outline:e.outline,selection:e.selection,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode}))),{select:s,selectDocument:c,breadcrumbOf:l,toggleRight:u}=$(e=>e.actions),d=r.kind===`element`?n?.index.get(r.instancePath)??null:null,f=r.kind===`envelope`?`envelope`:d===null?`document`:`element`,p=d===null?[]:l(d.instancePath),m=!e&&(o===`compact`||o===`narrow`);return(0,Z.jsx)(`aside`,{"aria-label":`Inspector`,"data-testid":`inspector`,"aria-hidden":!e&&i?!0:void 0,inert:!e&&i?!0:void 0,"data-editor-rail":`right`,style:{width:e?`100%`:i?0:a,maxWidth:m?`calc(100% - 48px)`:void 0},className:JP(`flex h-full shrink-0 flex-col overflow-hidden bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,!e&&`border-l border-border`,m&&`absolute inset-y-0 right-0 z-40 shadow-[var(--shadow-floating)]`,!e&&i&&`border-l-0`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:e?`100%`:a,maxWidth:`100%`},children:[(0,Z.jsx)(`div`,{className:`border-border bg-background/95 sticky top-0 z-10 border-b backdrop-blur-md`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden text-xs`,children:f===`document`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Document`}):f===`envelope`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Envelope`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:c,"data-testid":`inspector.document`,className:`hover:bg-muted hover:text-foreground shrink-0 rounded px-1`,children:`Email`}),p.map((e,t)=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder`,children:`/`}),t===p.length-1?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:e.label}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(e.instancePath),className:`hover:bg-muted hover:text-foreground max-w-[72px] truncate rounded px-1`,children:e.label})]},e.instancePath))]})}),d!==null&&(0,Z.jsx)(`span`,{"data-testid":`inspector.selection-badge`,className:`bg-muted text-muted-foreground shrink-0 rounded-md px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase`,children:d.authored?SN(d):`${d.tag} · generated`}),!e&&(0,Z.jsxs)(ET,{children:[(0,Z.jsx)(PT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse inspector`,"data-testid":`inspector.collapse`,onClick:u,className:`text-muted-foreground hover:bg-muted hover:text-foreground shrink-0 rounded-md p-1.5`}),children:(0,Z.jsx)(UP,{className:`size-[15px]`})}),(0,Z.jsx)(RT,{container:t,children:(0,Z.jsx)(sE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(cE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse inspector`})})})]})]})}),(0,Z.jsxs)(yA,{"data-samva-scroll-area":`inspector`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(jA,{className:`size-full`,children:(0,Z.jsxs)(`div`,{className:`samva-inspector-content pb-4`,children:[f===`document`&&(0,Z.jsx)(HI,{}),f===`envelope`&&(0,Z.jsx)(GI,{}),d!==null&&(0,Z.jsx)(KI,{selection:d})]})}),(0,Z.jsx)(LA,{orientation:`vertical`,className:`absolute top-0 right-0 bottom-0 flex w-2.5 touch-none p-0.5 select-none`,children:(0,Z.jsx)(RA,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}var JI={body:OP,div:jP,table:MP,tbody:MP,tr:MP,td:KP,th:KP,h1:NP,h2:NP,h3:NP,h4:NP,h5:NP,h6:NP,p:zP,span:zP,a:xP,button:xP,img:PP,hr:EP,br:vP,ul:bP,ol:bP,li:bP},YI=e=>JI[e.toLowerCase()]??jP;function XI({node:e,depth:t}){let{selectedPath:n,expandedLayers:r}=$(zO(e=>({selectedPath:e.selection.kind===`element`?e.selection.instancePath:null,expandedLayers:e.expandedLayers}))),{select:i,toggleLayerExpand:a,setHovered:o}=$(e=>e.actions),s=e.children.length>0,c=r.has(e.instancePath),l=n===e.instancePath,{selection:u}=e;return(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`div`,{className:`group relative`,style:{paddingLeft:t*12},onMouseEnter:()=>o(e.instancePath),onMouseLeave:()=>o(null),children:(0,Z.jsxs)(`div`,{className:JP(`flex h-[30px] w-full items-center gap-1.5 rounded-[7px] pr-2 pl-1.5 text-left transition-colors`,l?`bg-sel-soft text-accent-email`:`text-foreground hover:bg-muted`),children:[s?(0,Z.jsx)(`button`,{type:`button`,"aria-expanded":c,"data-testid":`left-rail.layer.toggle`,"aria-label":`${c?`Collapse`:`Expand`} ${SN(u)}`,className:JP(`grid size-3.5 shrink-0 place-items-center text-muted-foreground transition-transform`,c&&`rotate-90`),onClick:t=>{t.stopPropagation(),a(e.instancePath)},children:(0,Z.jsx)(wP,{className:`size-[11px]`})}):(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`button`,{"data-layer-instance-path":e.instancePath,"data-testid":`layers.node.${e.instancePath}`,type:`button`,onClick:()=>i(e.instancePath),className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,W.createElement)(YI(u.tag),{className:JP(`size-[15px] shrink-0`,l?`text-accent-email`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px]`,children:SN(u)}),!u.authored&&(0,Z.jsx)(`span`,{className:`text-placeholder shrink-0 text-[10px]`,children:`generated`})]})]})}),s&&c&&(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.children.map(e=>(0,Z.jsx)(XI,{node:e,depth:t+1},e.instancePath))})]})}function ZI(){let e=$(e=>e.outline);return e===null?(0,Z.jsx)(`div`,{className:`text-placeholder px-3 py-8 text-center text-xs`,children:`There is no preview yet, so there are no layers to show.`}):(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.roots.map(e=>(0,Z.jsx)(XI,{node:e,depth:0},e.instancePath))})}function QI(){let e=dF(),{leftCollapsed:t,leftWidth:n,layoutMode:r}=$(zO(e=>({leftCollapsed:e.leftCollapsed,leftWidth:e.leftWidth,layoutMode:e.layoutMode}))),{toggleLeft:i}=$(e=>e.actions),a=r===`compact`||r===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Layers`,"aria-hidden":t||void 0,inert:t||void 0,"data-editor-rail":`left`,style:{width:t?0:n,maxWidth:a?`calc(100% - 48px)`:void 0},className:JP(`flex h-full shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,a&&`absolute inset-y-0 left-0 z-40 shadow-[var(--shadow-floating)]`,t&&`border-r-0`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:n,maxWidth:`100%`},children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex items-center gap-0.5 border-b px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-foreground text-[12.5px] font-medium`,children:`Layers`}),(0,Z.jsxs)(ET,{children:[(0,Z.jsx)(PT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse layers`,"data-testid":`left-rail.collapse`,onClick:i,className:`text-muted-foreground hover:bg-muted hover:text-foreground ml-auto rounded-md p-1.5`}),children:(0,Z.jsx)(VP,{className:`size-[15px]`})}),(0,Z.jsx)(RT,{container:e,children:(0,Z.jsx)(sE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(cE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse layers`})})})]})]}),(0,Z.jsxs)(yA,{"data-samva-scroll-area":`layers`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(jA,{className:`size-full`,children:(0,Z.jsx)(`div`,{className:`px-2 pt-2.5 pb-5`,children:(0,Z.jsx)(ZI,{})})}),(0,Z.jsx)(LA,{orientation:`vertical`,className:`absolute top-0 right-0 bottom-0 flex w-2.5 touch-none p-0.5 select-none`,children:(0,Z.jsx)(RA,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}function $I({embedded:e=!1}={}){let t=dF(),{checks:n,doc:r,readonlyReason:i,rightCollapsed:a,rightWidth:o}=$(zO(e=>({checks:e.checks,doc:e.doc,readonlyReason:e.readonlyReason,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth}))),{toggleRight:s}=$(e=>e.actions);return!e&&a?null:(0,Z.jsxs)(`aside`,{"data-editor-rail":`right`,style:{width:e?`100%`:o},className:e?`bg-background flex h-full shrink-0 flex-col overflow-hidden`:`border-border bg-background flex h-full shrink-0 flex-col overflow-hidden border-l`,children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex h-11 items-center border-b px-3`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Template details`}),!e&&(0,Z.jsxs)(ET,{children:[(0,Z.jsx)(PT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse inspector`,onClick:s,className:`text-muted-foreground hover:bg-muted hover:text-foreground ml-auto rounded-md p-1.5`}),children:(0,Z.jsx)(UP,{className:`size-[15px]`})}),(0,Z.jsx)(RT,{container:t,children:(0,Z.jsx)(sE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(cE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse inspector`})})})]})]}),(0,Z.jsxs)(`div`,{className:`samva-editor-scroll min-h-0 flex-1 overflow-y-auto p-4 text-[12.5px]`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Read-only`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:i}),r!==null&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-3 font-mono text-[11.5px] break-all`,children:r.origin.file}),(0,Z.jsx)(`div`,{className:`border-border-subtle mt-5 border-t pt-4`,children:(0,Z.jsx)(xI,{checks:n})})]})]})}var eL=JP(`flex flex-1 items-center justify-center gap-1.5 px-2 text-[12px]`,ZP),tL={layers:{label:`Layers`,Icon:FP},inspector:{label:`Inspector`,Icon:WP},review:{label:`Review`,Icon:AP}},nL=[`layers`,`inspector`,`review`];function rL({view:e,sourceEditable:t,review:n}){return e===`layers`?(0,Z.jsx)(`div`,{className:`samva-editor-scroll h-full overflow-y-auto px-2 pt-2.5 pb-5`,children:(0,Z.jsx)(ZI,{})}):e===`review`&&n!==null?(0,Z.jsx)(`div`,{className:`samva-editor-scroll h-full overflow-y-auto px-2 pt-2.5 pb-5`,children:n.content}):t?(0,Z.jsx)(qI,{embedded:!0}):(0,Z.jsx)($I,{embedded:!0})}function iL({focused:e=!1}){let t=$(e=>e.sourceEditable),n=$(e=>e.rightWidth),r=$(e=>e.designView),i=$(e=>e.actions.setDesignView),a=rF(`rail.review`)??null,o=r===`review`&&a===null?`layers`:r,s=(0,W.useId)(),c=`${s}-panel`;return(0,Z.jsxs)(`aside`,{"aria-label":`Design`,"data-testid":`design-rail`,"data-editor-rail":`right`,style:e?void 0:{width:n},className:JP(`bg-background flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,e?`w-full flex-1`:`shrink-0 border-l border-border`),children:[(0,Z.jsx)(`div`,{className:`border-border-subtle flex min-h-11 shrink-0 items-center border-b px-2 py-1.5`,children:(0,Z.jsx)($O,{role:`tablist`,"aria-label":`Design view`,value:[o],onValueChange:e=>{let t=e[0];(t===`layers`||t===`inspector`)&&i(t),t===`review`&&a!==null&&i(`review`)},className:`bg-muted flex flex-1 gap-0.5 rounded-lg p-0.5`,children:nL.filter(e=>e!==`review`||a!==null).map(e=>{let{Icon:t,label:n}=tL[e];return(0,Z.jsxs)(KO,{id:`${s}-tab-${e}`,type:`button`,role:`tab`,"aria-selected":o===e,"aria-controls":c,"aria-pressed":void 0,value:e,"data-testid":`design.tab.${e}`,className:eL,children:[(0,Z.jsx)(t,{className:`size-[14px]`}),n,e===`review`&&a?.badge]},e)})})}),(0,Z.jsx)(`div`,{role:`tabpanel`,id:c,"aria-labelledby":`${s}-tab-${o}`,className:`min-h-0 flex-1`,children:(0,Z.jsx)(rL,{view:o,sourceEditable:t,review:a})})]})}function aL({side:e}){let t=$(e=>e.leftWidth),n=$(e=>e.assistantWidth),r=$(e=>e.rightWidth),{setAssistantWidth:i,setLeftWidth:a,setRightWidth:o}=$(e=>e.actions),s=(0,W.useRef)(!1);return(0,W.useEffect)(()=>{let t=t=>{s.current&&(e===`assistant`?i(t.clientX):e===`assistant-end`?i(window.innerWidth-t.clientX):e===`left`?a(t.clientX):o(window.innerWidth-t.clientX))},n=()=>{s.current&&(s.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return window.addEventListener(`mousemove`,t),window.addEventListener(`mouseup`,n),()=>{window.removeEventListener(`mousemove`,t),window.removeEventListener(`mouseup`,n)}},[e,i,a,o]),(0,Z.jsx)(`div`,{"data-editor-resize":e,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":e===`assistant`||e===`assistant-end`?n:e===`left`?t:r,"aria-label":e===`assistant`||e===`assistant-end`?`Resize Assistant`:e===`left`?`Resize layers panel`:`Resize inspector`,"data-testid":e===`assistant`||e===`assistant-end`?`agent-column.resize`:e===`left`?`left-rail.resize`:`inspector.resize`,tabIndex:0,onMouseDown:e=>{e.preventDefault(),s.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},onKeyDown:s=>{let c=s.shiftKey?24:8;(s.key===`ArrowLeft`||s.key===`ArrowRight`)&&(s.preventDefault(),e===`assistant`?(s.key===`ArrowLeft`&&i(n-c),s.key===`ArrowRight`&&i(n+c)):e===`assistant-end`?(s.key===`ArrowLeft`&&i(n+c),s.key===`ArrowRight`&&i(n-c)):e===`left`?(s.key===`ArrowLeft`&&a(t-c),s.key===`ArrowRight`&&a(t+c)):(s.key===`ArrowLeft`&&o(r+c),s.key===`ArrowRight`&&o(r-c)))},className:JP(`group relative z-10 w-2 shrink-0 cursor-col-resize`,`before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border before:transition-colors`,`hover:before:w-0.5 hover:before:bg-accent-email active:before:bg-accent-email`,`after:absolute after:top-1/2 after:left-1/2 after:h-10 after:w-1 after:-translate-x-1/2 after:-translate-y-1/2 after:rounded-full after:bg-muted-foreground/35 after:opacity-60 after:transition-opacity`,`hover:after:opacity-100 hover:after:bg-accent-email`)})}var oL={assistant:{label:`Assistant`,tip:`Show the assistant`,Icon:GP},preview:{label:`Preview`,tip:`Show the preview`,Icon:kP},design:{label:`Design`,tip:`Show designs, layers, and inspector`,Icon:FP}};function sL(){let e=$(e=>e.sourceEditable),t=$(e=>e.leftCollapsed),n=$(e=>e.rightCollapsed),r=$(e=>e.layoutMode),i=rF(`rail.assistant`)!==void 0,a=rF(`rail.review`),o=$(e=>e.workspaceView),s=$(e=>e.focusedPane),c=$(e=>e.actions.setFocusedPane),l=bN(),u=e=>l.setState({workspaceView:e}),d=(0,W.useId)(),f=i&&r===`compact`,p=i&&r===`narrow`,m=f||p,h=f?[`assistant`,`preview`,`design`]:[`assistant`,`preview`],g=o===`source`?`preview`:h.includes(s)?s:`assistant`;return i?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(_F,{value:o,onChange:e=>{u(e),m&&c(`preview`)},idBase:d,panelId:`${d}-view-panel`}),m&&(0,Z.jsx)($O,{role:`tablist`,value:[g],onValueChange:e=>{let t=e[0];h.some(e=>e===t)&&(c(t),t!==`preview`&&o===`source`&&u(`visual`))},"aria-label":`Editor pane`,className:`border-border bg-background flex h-11 shrink-0 items-center gap-1 border-b p-1.5`,children:h.map(e=>{let{Icon:t,label:n,tip:r}=oL[e];return(0,Z.jsxs)(KO,{id:`${d}-tab-${e}`,type:`button`,role:`tab`,"aria-selected":g===e,"aria-controls":`${d}-pane-${e}`,"aria-pressed":void 0,value:e,title:r,"data-testid":`agent-workspace.tab.${e}`,className:JP(ZP,`h-8 flex-1 px-2.5 text-[12px]`),children:[(0,Z.jsx)(t,{className:`size-3.5 shrink-0`}),n,e===`design`&&a?.badge]},e)})}),(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,"data-agent-workspace-layout":m?`focused`:`split`,children:[(0,Z.jsx)(`div`,{id:`${d}-pane-assistant`,role:m?`tabpanel`:void 0,"aria-labelledby":m?`${d}-tab-assistant`:void 0,hidden:m&&g!==`assistant`,className:JP(!m&&`contents`,m&&g===`assistant`&&`flex h-full min-h-0 min-w-0 flex-1`),children:(0,Z.jsx)(cF,{hidden:m&&g!==`assistant`})}),!m&&(0,Z.jsx)(aL,{side:`assistant`}),(0,Z.jsx)(`div`,{id:`${d}-pane-preview`,role:m?`tabpanel`:void 0,"aria-labelledby":m?`${d}-tab-preview`:void 0,hidden:m&&g!==`preview`,className:JP(`min-h-0 min-w-0 flex-1`,(!m||g===`preview`)&&`flex`),children:(0,Z.jsx)(`div`,{id:`${d}-view-panel`,role:`tabpanel`,"aria-labelledby":hF(d,o),className:`flex min-h-0 min-w-0 flex-1`,children:o===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsx)(yI,{pointing:!0})})}),!m&&(0,Z.jsx)(aL,{side:`right`}),(0,Z.jsx)(`div`,{id:`${d}-pane-design`,role:f?`tabpanel`:void 0,"aria-labelledby":f?`${d}-tab-design`:void 0,hidden:m&&g!==`design`,className:JP(!m&&`contents`,m&&g===`design`&&`flex h-full min-h-0 min-w-0 flex-1`),children:p?null:(0,Z.jsx)(iL,{focused:m})})]})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(MI,{}),(0,Z.jsx)(_F,{value:o,onChange:u,children:o===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(QI,{}),!t&&(0,Z.jsx)(aL,{side:`left`}),(0,Z.jsx)(yI,{}),!n&&(0,Z.jsx)(aL,{side:`right`}),e?(0,Z.jsx)(qI,{}):(0,Z.jsx)($I,{})]})})]})}var cL=RegExp(`\\s${Gc}="[^"]*"`,`g`),lL=e=>e.replace(cL,``),uL=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t===``?`email`:t},dL=(e,t)=>{let n=new Blob([lL(e)],{type:`text/html;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${uL(t)}.html`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)},fL=`image/png,image/jpeg,image/gif,image/webp,.woff2`,pL=1048576,mL=(e,t)=>{let n=e?.lastIndexOf(`/`)??-1;return`${e===void 0||n<0?``:e.slice(0,n+1)}assets/${t}`},hL=e=>{let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(t):``},gL=e=>j(e,`_tag`)&&e._tag===`ProjectFileExists`,_L=e=>j(e,`reason`)&&typeof e.reason==`string`?e.reason:`The template project operation failed.`,vL=e=>e.isPublished?`Published`:e.isHead?`Current saved version`:`Saved version`;function yL({file:e,content:t,busy:n,onChange:r,onApply:i,onReplace:a}){let o=e.status===`conflicted`;return(0,Z.jsxs)(`div`,{className:`border-border space-y-3 rounded-lg border p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h4`,{className:`truncate font-mono text-xs font-semibold`,children:e.path}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e.status})]}),e.binary===!0?(0,Z.jsx)(`div`,{className:`space-y-3`,"data-testid":`lifecycle-sheet.binary-file`,children:e.status===`deleted`?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Removed from the draft. Save a version to keep this change.`}):(0,Z.jsxs)(Z.Fragment,{children:[(e.status===`added`||e.status===`modified`)&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Unsaved until you save a version.`}),(0,Z.jsx)(`button`,{type:`button`,disabled:n,"data-testid":`lifecycle-sheet.replace-file`,onClick:a,className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs disabled:opacity-50`,YP),children:`Replace file`})]})}):o?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Resolve this file below before editing its workspace source.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`textarea`,{"aria-label":`Project source for ${e.path}`,"data-testid":`lifecycle-sheet.file-source.${e.path}`,value:t,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1,className:`border-border bg-surface-inset text-foreground min-h-52 w-full resize-y rounded-md border p-3 font-mono text-xs outline-none disabled:opacity-60`}),(0,Z.jsx)(`button`,{type:`button`,disabled:n||t===e.content,"data-testid":`lifecycle-sheet.apply-file.${e.path}`,onClick:()=>i(t),className:JP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,YP),children:`Apply file`})]})]})}function bL({conflict:e,busy:t,onResolve:n}){let[r,i]=(0,W.useState)(e.draft??e.main??``);return(0,Z.jsxs)(`article`,{className:`border-status-warning/45 space-y-3 rounded-lg border p-4`,children:[(0,Z.jsx)(`h4`,{className:`font-mono text-xs font-semibold`,children:e.path}),(0,Z.jsxs)(`details`,{className:`border-border rounded-md border`,children:[(0,Z.jsx)(`summary`,{className:`hover:bg-muted cursor-pointer px-3 py-2 text-xs font-medium`,children:`Compare base, draft, and main`}),(0,Z.jsx)(`div`,{className:`divide-border border-border divide-y border-t`,children:[[`Base`,e.base],[`Draft`,e.draft],[`Latest saved version`,e.main]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`space-y-1 p-3`,children:[(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11px] font-medium`,children:e}),(0,Z.jsx)(`pre`,{className:`samva-editor-scroll max-h-32 overflow-auto font-mono text-xs whitespace-pre-wrap`,children:t??`File does not exist`})]},e))})]}),(0,Z.jsx)(`textarea`,{"aria-label":`Resolved source for ${e.path}`,"data-testid":`lifecycle-sheet.conflict-source.${e.path}`,value:r,onChange:e=>i(e.target.value),spellCheck:!1,className:`border-border bg-surface-inset text-foreground min-h-40 w-full resize-y rounded-md border p-3 font-mono text-xs outline-none`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`draft`),"data-testid":`lifecycle-sheet.keep-draft`,className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,YP),children:`Keep draft`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`main`),className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,YP),children:`Use saved version`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`lifecycle-sheet.resolve-edited.${e.path}`,onClick:()=>n({content:r}),className:JP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium`,YP),children:`Use edited source`})]})]})}function xL({open:e,onClose:t,onLockedAction:n}){return e?(0,Z.jsx)(SL,{onClose:t,onLockedAction:n}):null}function SL({onClose:e,onLockedAction:t}){let n=dF(),r=$(e=>e.doc),i=$(e=>e.lifecycleCapability),{beginLifecycle:a,endLifecycle:o,flushSaves:s,adoptLifecycleSnapshot:c}=$(e=>e.actions),l=r!==null&&i?.status===`ready`,[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)({}),[v,y]=(0,W.useState)(()=>l?`loading`:null),b=(0,W.useRef)(null),x=(0,W.useRef)(null),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(l);if(l!==O&&(k(l),l&&(y(`loading`),d(null),T(null),D(null),p(null),h(null),_({}),C(null))),(0,W.useEffect)(()=>{if(i?.status!==`ready`)return;let e=!1;return s().then(()=>i.api.inspect()).then(t=>{if(e)return;d(t);let n=r?.origin.kind===`tsx`?r.origin.file:void 0;h(e=>e!==null&&t.files.some(({path:t})=>t===e)?e:n!==void 0&&t.files.some(({path:e})=>e===n)?n:t.files[0]?.path??null)}).catch(t=>{e||T(_L(t))}).finally(()=>{e||y(null)}),()=>{e=!0}},[r,s,i]),i===void 0)return null;if(i.status===`locked`)return(0,Z.jsx)(rj,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsxs)(XA,{container:n,children:[(0,Z.jsx)(VA,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(ij,{className:`fixed inset-0 z-[111] grid place-items-center p-4`,children:(0,Z.jsxs)(YA,{className:`border-border bg-popover w-full max-w-lg rounded-xl border p-5 shadow-[var(--shadow-floating)]`,children:[(0,Z.jsx)(aj,{className:`text-base font-semibold`,children:`Publishing is unavailable`}),(0,Z.jsx)(UA,{className:`text-muted-foreground mt-2 text-sm`,"data-testid":`lifecycle-sheet.locked-reason`,children:i.upsell.reason}),(0,Z.jsx)(`a`,{"data-testid":`lifecycle-sheet.upsell-cta`,className:JP(`bg-primary text-primary-foreground mt-4 inline-flex rounded-md px-3 py-2 text-sm font-medium`,YP),href:i.upsell.cta.href,onClick:e=>{t!==void 0&&(e.preventDefault(),t())},children:i.upsell.cta.label}),(0,Z.jsx)(HA,{className:JP(`border-border hover:bg-muted mt-4 ml-2 inline-flex rounded-md border px-3 py-2 text-sm font-medium`,YP),children:`Close`})]})})]})});let A=u?.commits.find(({commit:e})=>e===f),j=u?.files.find(({path:e})=>e===m),M=j?.content??``,N=j===void 0?void 0:g[j.path],P=N?.baseContent===M?N.content:M,F=u?.files.some(e=>{let t=g[e.path],n=e.content??``;return t?.baseContent===n&&t.content!==n})??!1,I=u!==null&&!u.dirty&&u.conflicts.length===0&&!F,L=u?.commits.find(({commit:e})=>e===u.baseCommit),R=I&&u?.baseCommit===u.remoteHead,ee=async()=>d(await i.api.inspect()),z=()=>{u!==null&&R&&v===null&&a()&&(y(`publish`),T(null),i.api.publish({baseRev:u.rev,commit:u.baseCommit}).then(async()=>{await ee(),D(`Published the current saved version.`)}).catch(e=>T(_L(e))).finally(()=>{o(),y(null)}))},te=()=>{u!==null&&A!==void 0&&!A.isHead&&I&&v===null&&a()&&(y(`restore`),T(null),s().then(e=>i.api.restore({commit:A.commit,baseRev:e})).then(async e=>{c(e),await ee(),p(null),D(`Restored the saved version to the draft. Save a version to keep this restore.`)}).catch(e=>T(_L(e))).finally(()=>{o(),y(null)}))},ne=(e,t)=>{u!==null&&v===null&&a()&&(y(`resolve`),T(null),s().then(n=>i.api.resolveConflict({path:e.path,baseRev:n,resolution:t})).then(t=>{d(t),D(`Resolved ${e.path}.`)}).catch(e=>T(_L(e))).finally(()=>{o(),y(null)}))},re=(e,t)=>{u!==null&&v===null&&(y(`file`),T(null),i.api.updateFile({path:e.path,baseRev:u.rev,content:t}).then(t=>{d(t),_(t=>{let{[e.path]:n,...r}=t;return r}),D(`Updated ${e.path}.`)}).catch(e=>T(_L(e))).finally(()=>y(null)))},B=(e,t,n)=>{u!==null&&v===null&&(y(`file`),T(null),D(null),C(null),i.api.putAsset({path:e,baseRev:u.rev,bytes:t,replace:n}).then(t=>{d(t),h(e),D(`${n?`Replaced`:`Added`} ${e}. Save a version to keep this change.`)}).catch(n=>{gL(n)?C({path:e,bytes:t}):T(_L(n))}).finally(()=>y(null)))},ie=e=>{let t=b.current;t!==null&&(x.current=e===null?null:{replacePath:e},t.accept=e===null?fL:hL(e),t.value=``,t.click())},ae=e=>{let t=x.current;if(x.current=null,e===void 0||u===null)return;if(e.size>pL){D(null),T(`${e.name} is larger than 1 MB. Choose a smaller file.`);return}let n=r?.origin.kind===`tsx`?r.origin.file:void 0,i=t?.replacePath??mL(n,e.name);e.arrayBuffer().then(e=>{let n=new Uint8Array(e);if(t===null&&u.files.some(e=>e.path===i)){T(null),D(null),C({path:i,bytes:n});return}B(i,n,t!==null)}).catch(e=>T(_L(e)))};return(0,Z.jsx)(Hj,{open:!0,onOpenChange:t=>!t&&e(),swipeDirection:`right`,children:(0,Z.jsxs)(zj,{container:n,children:[(0,Z.jsx)(hj,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(OM,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(Rj,{className:`border-border bg-popover pointer-events-auto flex h-full w-full max-w-2xl flex-col border-l shadow-[var(--shadow-floating)]`,children:[(0,Z.jsxs)(`header`,{className:`border-border flex items-center justify-between border-b px-5 py-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(dM,{className:`text-base font-semibold`,children:`Publish and saved versions`}),(0,Z.jsx)(vj,{className:`text-muted-foreground mt-0.5 text-xs`,children:`Save keeps a named version. Restore brings an older version into your draft.`})]}),(0,Z.jsx)(gj,{"data-testid":`lifecycle-sheet.close`,className:JP(`hover:bg-muted rounded-md px-2 py-1 text-sm`,YP),children:`Close`})]}),(0,Z.jsxs)(`div`,{className:`samva-editor-scroll min-h-0 flex-1 space-y-6 overflow-y-auto p-5`,children:[v===`loading`&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading saved versions…`}),w!==null&&(0,Z.jsx)(`p`,{className:`text-status-error text-sm`,role:`alert`,children:w}),E!==null&&(0,Z.jsx)(`p`,{className:`text-status-success text-sm`,role:`status`,"data-testid":`lifecycle-sheet.notice`,children:E}),u!==null&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`border-border bg-muted/30 space-y-3 rounded-lg border p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Current saved version`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:L?.message??`Current saved version`})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:z,disabled:!R||v!==null,"data-testid":`lifecycle-sheet.confirm-publish`,className:JP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-sm font-medium disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:v===`publish`?`Publishing…`:`Publish saved version`})]}),!I&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,"data-testid":`lifecycle-sheet.cleanliness-warning`,children:u.conflicts.length>0?`Resolve workspace conflicts before Save or Publish.`:`The draft has unsaved changes. Save a version before publishing or restoring.`}),I&&u.baseCommit!==u.remoteHead&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`The saved version changed elsewhere. Refresh before publishing.`})]}),(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Project files`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,"data-testid":`lifecycle-sheet.add-file`,onClick:()=>ie(null),className:JP(`border-border hover:bg-muted rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Add file`}),(0,Z.jsx)(`input`,{ref:b,type:`file`,accept:fL,hidden:!0,"data-testid":`lifecycle-sheet.add-file-input`,onChange:e=>ae(e.target.files?.[0])})]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Add PNG, JPEG, GIF, or WebP images and WOFF2 fonts up to 1 MB.`}),S!==null&&(0,Z.jsxs)(`div`,{className:`border-status-warning/45 space-y-3 rounded-lg border p-3`,"data-testid":`lifecycle-sheet.replace-prompt`,children:[(0,Z.jsxs)(`p`,{className:`text-xs`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:S.path}),` already exists. Replace it with the file you chose?`]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,"data-testid":`lifecycle-sheet.confirm-replace`,onClick:()=>B(S.path,S.bytes,!0),className:JP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Replace file`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,onClick:()=>C(null),className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Cancel`})]})]}),(0,Z.jsx)(`div`,{className:`border-border divide-border divide-y rounded-lg border`,children:u.files.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`lifecycle-sheet.file.${e.path}`,onClick:()=>h(e.path),className:JP(`hover:bg-muted flex w-full items-center justify-between gap-4 px-3 py-2 text-left`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,m===e.path&&`bg-muted`),children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.path}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e.status})]},e.path))}),j!==void 0&&(0,Z.jsx)(yL,{file:j,content:P,busy:v!==null,onChange:e=>_(t=>{if(e===M){let{[j.path]:e,...n}=t;return n}return{...t,[j.path]:{baseContent:M,content:e}}}),onApply:e=>re(j,e),onReplace:()=>ie(j.path)},`${j.path}:${j.content??``}`)]}),u.conflicts.length>0&&(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Resolve conflicts`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:`Choose either side or edit the final file. Save remains blocked until every path is resolved.`})]}),u.conflicts.map(e=>(0,Z.jsx)(bL,{conflict:e,busy:v!==null,onResolve:t=>ne(e,t)},e.path))]}),(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Saved versions`}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:u.commits.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`lifecycle-sheet.commit.${e.commit}`,onClick:()=>p(e.commit),className:JP(`border-border hover:bg-muted flex w-full items-start justify-between gap-4 rounded-lg border p-3 text-left`,f===e.commit&&`ring-primary ring-2`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:[(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.message}),(0,Z.jsx)(`span`,{className:`text-muted-foreground mt-1 block text-xs`,children:e.committedAt.toLocaleString()})]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:vL(e)})]},e.commit))})]}),A!==void 0&&!A.isHead&&(0,Z.jsxs)(`section`,{className:`border-border space-y-3 rounded-lg border p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Restore saved version`}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:[`Bring “`,A.message,`” into the current draft. Save a version when you want to keep the restored draft.`]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:te,disabled:!I||v!==null,"data-testid":`lifecycle-sheet.restore`,className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-sm`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:v===`restore`?`Restoring…`:`Restore this version`})]})]})]})]})})]})})}function CL({container:e,children:t}){return(0,Z.jsx)(uF,{value:e,children:t})}var wL={desktop:600,mobile:375},TL=`Copy code`;function EL({open:e,onClose:t}){return e?(0,Z.jsx)(DL,{onClose:t}):null}function DL({onClose:e}){let t=dF(),{doc:n,render:r,checks:i,previewDevice:a}=$(zO(e=>({doc:e.doc,render:e.render,checks:e.checks,previewDevice:e.previewDevice}))),[o,s]=(0,W.useState)(`preview`),[c,l]=(0,W.useState)(a),[u,d]=(0,W.useState)(`light`),[f,p]=(0,W.useState)(n?.channel);n?.channel!==f&&(p(n?.channel),s(`preview`));let[m,h]=(0,W.useState)(a);if(a!==m&&(h(a),s(`preview`),l(a),d(`light`)),n===null)return null;let g=n.metadata.fromDefault,_=(e,t)=>({value:e,label:t,testId:`preview-overlay.view.${e}`}),v=n.channel===`email`?[_(`preview`,`Preview`),_(`html`,`HTML`),_(`text`,`Text`),_(`source`,`TSX`)]:n.channel===`sms`?[_(`preview`,`Preview`),_(`text`,`Text`),_(`source`,`TSX`)]:[_(`preview`,`Preview`),_(`payload`,`Payload`),_(`source`,`TSX`)],y=o===`source`?n.origin.authoredSource:o===`html`&&r!==null?r.html:o===`text`&&r!==null?r.text:o===`text`&&n.channel===`sms`&&n.render!==null?n.render.text:o===`payload`&&n.channel===`whatsapp`&&n.render!==null?JSON.stringify(n.render,null,2):``;return(0,Z.jsx)(rj,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsx)(XA,{container:t,children:(0,Z.jsxs)(YA,{className:`samva-editor-shell fixed inset-0 z-[100] flex flex-col bg-[var(--editor-canvas-bg)] outline-none`,children:[(0,Z.jsx)(aj,{className:`sr-only`,children:`Template preview`}),(0,Z.jsx)(UA,{className:`sr-only`,children:`Preview the rendered template and inspect its generated output.`}),(0,Z.jsxs)(`div`,{"data-testid":`preview-overlay.toolbar`,className:`border-border-subtle flex shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2.5 sm:gap-2.5 sm:px-4`,children:[(0,Z.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Preview`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground hidden text-xs sm:inline`,children:`rendered message, exactly what ships`}),(0,Z.jsx)(_I,{ariaLabel:`Preview format`,testId:`preview-overlay.format-group`,value:o,onChange:e=>s(e),options:v}),(0,Z.jsx)(`span`,{className:`hidden flex-1 sm:block`}),n.channel===`email`&&o===`preview`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_I,{ariaLabel:`Preview width`,testId:`preview-overlay.width-group`,value:c,onChange:e=>l(e),options:[{value:`desktop`,label:`Desktop`,testId:`preview-overlay.device.desktop`},{value:`mobile`,label:`Mobile`,testId:`preview-overlay.device.mobile`}]}),(0,Z.jsx)(_I,{ariaLabel:`Preview color scheme`,testId:`preview-overlay.color-scheme-group`,value:u,onChange:e=>d(e),options:[{value:`light`,label:`Light`,testId:`preview-overlay.scheme.light`},{value:`dark`,label:`Dark`,testId:`preview-overlay.scheme.dark`}]}),(0,Z.jsx)(SI,{checks:i})]}),(0,Z.jsxs)(HA,{"data-testid":`preview-overlay.close`,className:`border-border text-foreground hover:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 ml-auto inline-flex h-[30px] items-center gap-1.5 rounded-[7px] border px-2.5 outline-none focus-visible:ring-[3px]`,children:[`Close`,(0,Z.jsx)(`kbd`,{className:`text-muted-foreground text-[10px]`,children:`⎋`})]})]}),o===`preview`?n.channel===`email`?(0,Z.jsxs)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto px-6 pt-3 pb-12`,children:[(0,Z.jsxs)(`div`,{"data-testid":`preview-overlay.device-frame`,className:JP(`mx-auto mb-3.5 max-w-full truncate text-[12.5px] text-muted-foreground transition-[width] duration-180`,c===`mobile`?`w-[375px]`:`w-[600px]`),children:[g!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`b`,{className:`text-foreground font-semibold`,children:g.name??g.email}),g.name===void 0?null:(0,Z.jsxs)(Z.Fragment,{children:[` <`,g.email,`>`]}),` ·`,` `]}),(0,Z.jsx)(`b`,{className:`text-foreground font-semibold`,children:r?.subject??``}),r?.preheader!==void 0&&(0,Z.jsxs)(`span`,{className:`opacity-70`,children:[` — `,r.preheader]})]}),(0,Z.jsx)(`div`,{className:JP(`mx-auto h-[calc(100%-2rem)] max-w-full transition-[width] duration-180 ease-out`,c===`mobile`?`w-[375px]`:`w-[600px]`),children:r===null?(0,Z.jsx)(`pre`,{className:`border-status-error/40 bg-background text-status-error rounded-lg border p-4 font-mono text-xs whitespace-pre-wrap`,children:`The current draft did not build, so there is nothing to preview.`}):(0,Z.jsx)(tI,{html:r.html,width:wL[c],forceColorScheme:u})})]}):(0,Z.jsx)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto p-8`,children:(0,Z.jsx)(`div`,{className:`border-border bg-background mx-auto max-w-[460px] rounded-[28px] border p-5 shadow-[var(--shadow-lg)]`,children:n.channel===`sms`&&n.render!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{"data-testid":`preview-overlay.sms-body`,className:`bg-muted rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:n.render.text}),(0,Z.jsx)(CF,{text:n.render.text,className:`mt-4 text-center text-xs`})]}):n.channel===`whatsapp`&&n.render!==null?(0,Z.jsxs)(`div`,{className:`bg-surface-inset rounded-xl p-3.5`,children:[n.render.header!==void 0&&n.render.header.text!==``&&(0,Z.jsx)(`p`,{className:`mb-1 font-semibold`,children:n.render.header.text}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap`,children:n.render.body}),n.render.footer!==void 0&&n.render.footer!==``&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:n.render.footer}),n.render.buttons.map((e,t)=>(0,Z.jsx)(`div`,{className:`border-border-subtle text-accent-email mt-2 border-t pt-2 text-center text-xs`,children:e.type===`copy-code`?TL:e.text},`${e.type}-${t}`))]}):(0,Z.jsx)(`pre`,{className:`text-status-error whitespace-pre-wrap`,children:`The current draft did not build, so there is nothing to preview.`})})}):(0,Z.jsx)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto p-6`,children:(0,Z.jsx)(`pre`,{className:`border-border bg-background text-foreground mx-auto min-h-full max-w-[1100px] rounded-lg border p-5 font-mono text-[12px] leading-5 whitespace-pre-wrap`,children:y})})]})})})}function OL({saveVersionStatus:e,saveVersionState:t,onSaveVersion:n,saveVersionBusy:r,saveVersionBlocked:i,guestHeadline:a}){let o=dF(),{doc:s,checks:c,sizeKb:l,deviceWidth:u,layoutMode:d}=$(zO(e=>({doc:e.doc,checks:e.checks,sizeKb:e.sizeKb,deviceWidth:QN[e.previewDevice],layoutMode:e.layoutMode}))),{selectDocument:f}=$(e=>e.actions),p=$(e=>e.sourceEditable),m=$(e=>e.pendingAuthoredSource),h=$(zO(e=>({storageError:e.storageError,conflict:e.conflict}))),[g,_]=(0,W.useState)(!1),{errorCount:v,warnCount:y}=JN(c),b=d===`compact`||d===`narrow`,x=c.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)).length,S=`No known risks found`;x>0&&(S=`No known risks · ${x} need verification`),y>0&&(S=`${y} warning${y>1?`s`:``}`),v>0&&(S=`${v} check${v>1?`s`:``} failing`),c.length===0&&(S=`No checks yet`);let C=t===`error`||h.storageError!==null||h.conflict?`Couldn't save version`:m!==null||r===!0?`Saving…`:void 0;return(0,Z.jsxs)(`footer`,{className:`border-border bg-background text-muted-foreground z-30 flex min-h-8 items-center gap-4 border-t px-3.5 py-1 text-[11.5px]`,children:[(0,Z.jsxs)(eN,{open:g,onOpenChange:_,children:[(0,Z.jsxs)(rN,{"data-testid":`statusbar.checks-trigger`,"aria-label":d===`narrow`?S:void 0,onClick:()=>f(),className:JP(`inline-flex shrink-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 transition-colors hover:bg-muted hover:text-foreground`,a===void 0&&(d===`narrow`?`w-6`:`w-[clamp(96px,18vw,240px)]`),g&&`bg-muted text-foreground`),children:[(0,Z.jsx)(`span`,{className:JP(`size-[7px] shrink-0 rounded-full`,v>0?`bg-status-error`:y>0?`bg-status-warning`:`bg-muted-foreground`)}),a===void 0&&d!==`narrow`?(0,Z.jsx)(`span`,{className:`truncate`,children:S}):null]}),(0,Z.jsx)(oN,{container:o,children:(0,Z.jsx)(lN,{side:`top`,align:`start`,sideOffset:8,collisionPadding:12,className:`z-[80] outline-none`,children:(0,Z.jsx)(fN,{"data-testid":`statusbar.checks-popup`,className:`samva-editor-shell border-border bg-surface-elevated max-h-[min(560px,70vh)] w-[360px] origin-[var(--transform-origin)] overflow-y-auto rounded-xl border p-3.5 shadow-[var(--shadow-xl)] transition-[transform,scale,opacity] data-[ending-style]:scale-95 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0`,children:(0,Z.jsx)(xI,{checks:c,editable:p})})})})]}),a===void 0?!b&&(0,Z.jsx)(`span`,{className:`w-[52px] shrink-0`,children:s===null?`Loading…`:`Draft`}):(0,Z.jsx)(`span`,{"data-testid":`statusbar.guest`,className:`min-w-0 truncate`,children:C??a}),a===void 0?(0,Z.jsx)(`span`,{"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,className:JP(`truncate`,d===`narrow`?`min-w-0 flex-1`:`w-[150px] shrink-0`),children:e??`Autosaved just now`}):(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,children:C??e??a}),n!==void 0&&(0,Z.jsx)(`button`,{type:`button`,onClick:n,disabled:r===!0||i===!0,"data-testid":`topbar.save-version`,"aria-label":`Save the current draft as a version`,title:`Save this draft as a version (⌘/Ctrl+S)`,className:`hover:bg-muted hover:text-foreground w-[82px] shrink-0 rounded-md px-1.5 py-0.5 text-left transition-colors`,children:r===!0?`Saving…`:e===`Couldn’t save version`?`Retry`:`Save version`}),(0,Z.jsx)(`span`,{className:`flex-1`}),!b&&(0,Z.jsxs)(`span`,{className:`w-10 shrink-0 text-right`,children:[l,` KB`]}),d!==`narrow`&&(0,Z.jsx)(`span`,{className:`w-[42px] shrink-0 text-right`,children:s?.channel===`email`?`${u}px`:s?.channel.toUpperCase()??``})]})}var kL=`theme.css`,AL=`starter.css`,jL=`samva:brand`,ML=`@import "./${AL}";`,NL=`@import "${jL}";`,PL=/@import(?![\w-])/iy,FL=(e,t)=>{let n=e[t],r=t+1;for(;r<e.length;){let t=e[r];if(t===`\\`)r+=2;else if(t===n||t===`
30
- `)return r+1;else r+=1}return e.length},IL=(e,t)=>{let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2},LL=e=>{let t=``,n=0;for(;n<e.length;)if(e.startsWith(`/*`,n))n=IL(e,n),t+=` `;else if(e[n]===`"`||e[n]===`'`){let r=FL(e,n);t+=e.slice(n,r),n=r}else t+=e[n],n+=1;return t},RL=e=>{let t=e[0];if(!(t!==`"`&&t!==`'`||e.length<2||e.at(-1)!==t))return e.slice(1,-1)},zL=e=>{let t=LL(e).trim(),n=/^url\(\s*(.*?)\s*\)$/is.exec(t);if(n!==null){let e=n[1]??``;return RL(e)??(/^[^\s"'()]+$/.test(e)?e:void 0)}return RL(t)},BL=e=>{let t=[],n=0,r=0;for(;r<e.length;){let i=e[r];if(i===`/`&&e[r+1]===`*`){r=IL(e,r);continue}if(i===`"`||i===`'`){r=FL(e,r);continue}if(i===`{`)n+=1;else if(i===`}`)n=Math.max(0,n-1);else if(i===`@`&&n===0&&(PL.lastIndex=r,PL.test(e))){let n=PL.lastIndex,i=n;for(;i<e.length&&e[i]!==`;`;)e.startsWith(`/*`,i)?i=IL(e,i):e[i]===`"`||e[i]===`'`?i=FL(e,i):i+=1;let a=Math.min(i+1,e.length);t.push({target:zL(e.slice(n,i)),end:a}),r=a;continue}r+=1}return t},VL=e=>{if(e===jL)return{slug:null};let t=`${jL}/`;if(e===void 0||!e.startsWith(t))return;let n=e.slice(t.length);return n.length===0?void 0:{slug:n}},HL=e=>{let t=e?.replace(/[?#].*$/,``);return t===`./starter.css`||t===`/starter.css`},UL=e=>{for(let{target:t}of BL(e)){let e=VL(t);if(e!==void 0)return e}return null},WL=e=>{let t=e.theme??``;if(UL(t)!==null)return t;let n=BL(t).find(({target:e})=>HL(e));if(n!==void 0)return`${t.slice(0,n.end)}\n${NL}${t.slice(n.end)}`;let r=[...e.starter?[ML]:[],NL].join(`
25
+ `),cooked:i===null?null:i.slice(1,c)},o.tail=s,this.next();let u=this.finishNode(o,`TemplateElement`);return this.resetEndLocation(u,wu(this.state.lastTokEndLoc,c)),u}parseTemplate(e){let t=this.startNode(),n=this.parseTemplateElement(e),r=[n],i=[];for(;!n.tail;)i.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),r.push(n=this.parseTemplateElement(e));return t.expressions=i,t.quasis=r,this.finishNode(t,`TemplateLiteral`)}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(e,t,n){let r=!1,i=!0,a=this.startNode();for(a.properties=[],this.next();!this.match(e);){if(i)i=!1;else if(this.expect(8),this.match(e)){this.addTrailingCommaExtraToNode(a);break}let o;t?o=this.parseBindingProperty():(o=this.parsePropertyDefinition(n),r=this.checkProto(o,r,n)),a.properties.push(o)}this.next();let o=t?`ObjectPattern`:`ObjectExpression`;return this.finishNode(a,o)}addTrailingCommaExtraToNode(e){this.addExtra(e,`trailingComma`,this.state.lastTokStartLoc.index),this.addExtra(e,`trailingCommaLoc`,this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(e){return!e.computed&&e.key.type===`Identifier`&&(this.isLiteralPropertyName()||this.match(0)||this.match(51))}parsePropertyDefinition(e){let t=[];if(this.match(22))for(this.hasPlugin(`decorators`)&&this.raise(G.UnsupportedPropertyDecorator,this.state.startLoc);this.match(22);)t.push(this.parseDecorator());let n=this.startNode(),r=!1,i=!1,a;if(this.match(17))return t.length&&this.unexpected(),this.parseSpread();t.length&&(n.decorators=t),n.method=!1,e&&(a=this.state.startLoc);let o=this.eat(51);this.parsePropertyNamePrefixOperator(n);let s=this.state.containsEsc;if(this.parsePropertyName(n,e),!o&&!s&&this.maybeAsyncOrAccessorProp(n)){let{key:e}=n,t=e.name;t===`async`&&!this.hasPrecedingLineBreak()&&(r=!0,this.resetPreviousNodeTrailingComments(e),o=this.eat(51),this.parsePropertyName(n)),(t===`get`||t===`set`)&&(i=!0,this.resetPreviousNodeTrailingComments(e),n.kind=t,this.match(51)&&(o=!0,this.raise(G.AccessorIsGenerator,this.state.curPosition(),{kind:t}),this.next()),this.parsePropertyName(n))}return this.parseObjPropValue(n,a,o,r,!1,i,e)}getGetterSetterExpectedParamCount(e){return e.kind===`get`?0:1}getObjectOrClassMethodParams(e){return e.params}checkGetterSetterParams(e){let t=this.getGetterSetterExpectedParamCount(e),n=this.getObjectOrClassMethodParams(e);n.length!==t&&this.raise(e.kind===`get`?G.BadGetterArity:G.BadSetterArity,e),e.kind===`set`&&n[n.length-1]?.type===`RestElement`&&this.raise(G.BadSetterRestParameter,e)}parseObjectMethod(e,t,n,r,i){if(i){let n=this.parseMethod(e,t,!1,!1,!1,`ObjectMethod`);return this.checkGetterSetterParams(n),n}if(n||t||this.match(6))return r&&this.unexpected(),e.kind=`method`,e.method=!0,this.parseMethod(e,t,n,!1,!1,`ObjectMethod`)}parseObjectProperty(e,t,n,r){if(e.shorthand=!1,this.eat(10))return e.value=n?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowInOrVoidPattern(4,r),this.finishObjectProperty(e);if(!e.computed&&e.key.type===`Identifier`){if(this.checkReservedWord(e.key.name,e.key.start,!0,!1),n)e.value=this.parseMaybeDefault(t,this.cloneIdentifier(e.key));else if(this.match(25)){let n=this.state.startLoc;r==null?this.raise(G.InvalidCoverInitializedName,n):r.shorthandAssignLoc===null&&(r.shorthandAssignLoc=n),e.value=this.parseMaybeDefault(t,this.cloneIdentifier(e.key))}else e.value=this.cloneIdentifier(e.key);return e.shorthand=!0,this.finishObjectProperty(e)}}finishObjectProperty(e){return this.finishNode(e,`ObjectProperty`)}parseObjPropValue(e,t,n,r,i,a,o){let s=this.parseObjectMethod(e,n,r,i,a)||this.parseObjectProperty(e,t,i,o);return s||this.unexpected(),s}parsePropertyName(e,t){if(this.eat(0))e.computed=!0,e.key=this.parseMaybeAssignAllowIn(),this.expect(1);else{let{type:n,value:r}=this.state,i;if(ld(n))i=this.parseIdentifier(!0);else switch(n){case 131:i=this.parseNumericLiteral(r);break;case 130:i=this.parseStringLiteral(r);break;case 132:i=this.parseBigIntLiteral(r);break;case 134:{let e=this.state.startLoc;t==null?this.raise(G.UnexpectedPrivateField,e):t.privateKeyLoc===null&&(t.privateKeyLoc=e),i=this.parsePrivateName();break}default:throw this.unexpected()}e.key=i,n!==134&&(e.computed=!1)}}initFunction(e,t){e.id=null,e.generator=!1,e.async=t}parseMethod(e,t,n,r,i,a,o=!1){this.initFunction(e,n),e.generator=t,this.scope.enter(530|(o?576:0)|(i?32:0)),this.prodParam.enter(Zf(n,e.generator)),this.parseFunctionParams(e,r);let s=this.parseFunctionBodyAndFinish(e,a,!0);return this.prodParam.exit(),this.scope.exit(),s}parseArrayLike(e,t){let n=this.startNode();return this.next(),n.elements=this.parseExprList(e,!0,t,n),this.finishNode(n,`ArrayExpression`)}parseArrowExpression(e,t,n,r){this.scope.enter(518);let i=Zf(n,!1);return this.match(2)||(i|=this.prodParam.currentFlags()&24),this.prodParam.enter(i),this.initFunction(e,n),t&&this.setArrowFunctionParameters(e,t,r),this.parseFunctionBody(e,!0),this.prodParam.exit(),this.scope.exit(),this.finishNode(e,`ArrowFunctionExpression`)}setArrowFunctionParameters(e,t,n){this.toAssignableList(t,n,!1),e.params=t}parseFunctionBodyAndFinish(e,t,n=!1){return this.parseFunctionBody(e,!1,n),this.finishNode(e,t)}parseFunctionBody(e,t,n=!1){let r=t&&!this.match(2);if(this.expressionScope.enter(Yf()),r)e.body=this.parseMaybeAssign(),this.checkParams(e,!1,t,!1);else{let r=this.state.strict,i=this.state.labels;this.state.labels=[],this.prodParam.enter(this.prodParam.currentFlags()|4),e.body=this.parseBlock(!0,!1,i=>{let a=!this.isSimpleParamList(e.params);i&&a&&this.raise(G.IllegalLanguageModeDirective,(e.kind===`method`||e.kind===`constructor`)&&e.key?this.optionFlags&256?e.key.loc.end:e.key:e);let o=!r&&this.state.strict;this.checkParams(e,!this.state.strict&&!t&&!n&&!a,t,o),this.state.strict&&e.id&&this.checkIdentifier(e.id,65,o)}),this.prodParam.exit(),this.state.labels=i}this.expressionScope.exit()}isSimpleParameter(e){return e.type===`Identifier`}isSimpleParamList(e){for(let t=0,n=e.length;t<n;t++)if(!this.isSimpleParameter(e[t]))return!1;return!0}checkParams(e,t,n,r=!0){let i=!t&&new Set,a={type:`FormalParameters`};for(let t of e.params)this.checkLVal(t,a,5,i,r)}parseExprList(e,t,n,r){let i=[],a=!0;for(;!this.eat(e);){if(a)a=!1;else if(this.expect(8),this.match(e)){r&&this.addTrailingCommaExtraToNode(r),this.next();break}i.push(this.parseExprListItem(e,t,n))}return i}parseExprListItem(e,t,n,r){let i;if(this.match(8))t||this.raise(G.UnexpectedToken,this.state.curPosition(),{unexpected:`,`}),i=null;else if(this.match(17)){let e=this.state.startLoc;i=this.parseParenItem(this.parseSpread(n),e)}else if(this.match(13)){this.expectPlugin(`partialApplication`),r||this.raise(G.UnexpectedArgumentPlaceholder,this.state.startLoc);let e=this.startNode();this.next(),i=this.finishNode(e,`ArgumentPlaceholder`)}else i=this.parseMaybeAssignAllowInOrVoidPattern(e,n,!0);return i}parseIdentifier(e){let t=this.startNode(),n=this.parseIdentifierName(e);return this.createIdentifier(t,n)}createIdentifier(e,t){return e.name=t,this.optionFlags&256&&(e.loc.identifierName=t),this.finishNode(e,`Identifier`)}createIdentifierAt(e,t,n){return e.name=t,this.optionFlags&256&&(e.loc.identifierName=t),this.finishNodeAt(e,`Identifier`,n)}parseIdentifierName(e){let t,{start:n,type:r}=this.state;ld(r)?t=this.state.value:this.unexpected();let i=cd(r);return e?i&&this.replaceToken(128):this.checkReservedWord(t,this.sourceToOffsetPos(n),i,!1),this.next(),t}checkReservedWord(e,t,n,r){if(!(e.length>10)&&qd(e)){if(n&&Wd(e)){this.raise(G.UnexpectedKeyword,t,{keyword:e});return}if((this.state.strict?r?Ud:Vd:Bd)(e,this.inModule)){this.raise(G.UnexpectedReservedWord,t,{reservedWord:e});return}if(e===`yield`){if(this.prodParam.hasYield){this.raise(G.YieldBindingIdentifier,t);return}}else if(e===`await`){if(this.prodParam.hasAwait){this.raise(G.AwaitBindingIdentifier,t);return}if(this.scope.inStaticBlock){this.raise(G.AwaitBindingIdentifierInStaticBlock,t);return}this.expressionScope.recordAsyncArrowParametersError(t)}else if(e===`arguments`&&this.scope.inClassAndNotInNonArrowFunction){this.raise(G.ArgumentsInClass,t);return}}}recordAwaitIfAllowed(){let e=this.prodParam.hasAwait;return e&&!this.scope.inFunction&&(this.state.hasTopLevelAwait=!0),e}parseAwait(e,t){let n=e.index;this.setLoc(e);let r=this.startNodeAt(e);return this.expressionScope.recordParameterInitializerError(G.AwaitExpressionFormalParameter,n),this.eat(51)&&this.raise(G.ObsoleteAwaitStar,e),!this.scope.inFunction&&!(this.optionFlags&1)&&(this.isAmbiguousPrefixOrIdentifier()?this.ambiguousScriptDifferentAst=!0:this.sawUnambiguousESM=!0),t||(r.argument=this.parseMaybeUnary(null,!0)),this.finishNode(r,`AwaitExpression`)}isAmbiguousPrefixOrIdentifier(){if(this.hasPrecedingLineBreak())return!0;let{type:e}=this.state;return e===49||e===6||e===0||Td(e)||e===98&&!this.state.containsEsc||e===133||e===52||this.hasPlugin(`v8intrinsic`)&&e===50}parseYield(e){this.setLoc(e);let t=this.startNodeAt(e);this.expressionScope.recordParameterInitializerError(G.YieldInParameter,e.index);let n=!1,r=null;if(!this.hasPrecedingLineBreak())switch(n=this.eat(51),this.state.type){case 9:case 135:case 4:case 7:case 1:case 5:case 10:case 8:if(!n)break;default:r=this.parseMaybeAssign()}return t.delegate=n,t.argument=r,this.finishNode(t,`YieldExpression`)}parseImportCall(e){this.next();let t=this.parseCallExpressionArguments();if(t.length===0||t.length>2)this.raise(G.ImportCallArity,e,e);else for(let n of t)n.type===`SpreadElement`&&this.raise(G.ImportCallSpreadArgument,n,e);return e.source=t[0],e.options=t[1]??null,this.finishNode(e,`ImportExpression`)}withTopicBindingContext(e){let t=this.state.inHackPipelineBody;this.state.inHackPipelineBody=!0;let n=this.state.seenTopicReference;this.state.seenTopicReference=!1;try{return e()}finally{this.state.inHackPipelineBody=t,this.state.seenTopicReference=n}}allowInAnd(e){let t=this.prodParam.currentFlags();if(24&~t){this.prodParam.enter(t|24);try{return e()}finally{this.prodParam.exit()}}return e()}disallowInAnd(e){let t=this.prodParam.currentFlags(),n=8&t,r=16&~t;if(n||r){this.prodParam.enter(t&-9|16);try{return e()}finally{this.prodParam.exit()}}return e()}registerTopicReference(){this.state.seenTopicReference=!0}topicReferenceIsAllowedInCurrentContext(){return this.state.inHackPipelineBody}topicReferenceWasUsedInCurrentContext(){return this.state.seenTopicReference}parseFSharpPipelineBody(e){let t=this.state.startLoc;this.prodParam.enter(this.prodParam.currentFlags()&-17);let n;if(this.isContextual(92)&&this.recordAwaitIfAllowed()){this.next(),n=this.parseAwait(t,!0);let e=this.state.type;_d(e)&&e!==35&&(this.prodParam.hasIn||e!==54)&&this.raise(G.PipelineUnparenthesized,t)}else this.state.canStartArrow=!0,n=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),t,e);return this.prodParam.exit(),n}parseModuleExpression(){this.expectPlugin(`moduleBlocks`);let e=this.startNode();this.next(),this.match(2)||this.unexpected(null,2);let t=this.startNodeAt(this.state.endLoc);this.next();let n=this.initializeScopes(!0);this.enterInitialScopes();try{e.body=this.parseProgram(t,4,`module`)}finally{n()}return this.finishNode(e,`ModuleExpression`)}parseVoidPattern(e){this.expectPlugin(`discardBinding`);let t=this.startNode();return e!=null&&(e.voidPatternLoc=this.state.startLoc),this.next(),this.finishNode(t,`VoidPattern`)}parseMaybeAssignAllowInOrVoidPattern(e,t,n){if(t!=null&&this.match(84)){let n=this.lookaheadCharCode();if(n===44||n===(e===1?93:e===4?125:41)||n===61)return this.parseMaybeDefault(this.state.startLoc,this.parseVoidPattern(t))}return this.parseMaybeAssignAllowIn(t,n)}parsePropertyNamePrefixOperator(e){}},op={kind:1},sp={kind:2},cp=/[\uD800-\uDFFF]/u,lp=/in(?:stanceof)?/y;function up(e){for(let t=0;t<e.length;t++){let n=e[t],{type:r}=n;typeof r==`number`&&(n.type=Ed(r))}return e}var dp=class extends ap{parseTopLevel(e,t){return e.program=this.parseProgram(t,135,this.options.sourceType===`module`?`module`:`script`),e.comments=this.comments,this.optionFlags&512&&(e.tokens=up(this.tokens)),this.finishNode(e,`File`)}parseProgram(e,t,n){if(e.sourceType=n,e.interpreter=this.parseInterpreterDirective(),this.parseBlockBody(e,!0,!0,t),this.inModule){if(!(this.optionFlags&64)&&this.scope.undefinedExports.size>0)for(let[e,t]of Array.from(this.scope.undefinedExports))this.raise(G.ModuleExportUndefined,t,{localName:e});this.addExtra(e,`topLevelAwait`,this.state.hasTopLevelAwait)}let r;return r=t===135?this.finishNode(e,`Program`):this.finishNodeAt(e,`Program`,wu(this.state.startLoc,-1)),r}stmtToDirective(e){let t=this.castNodeTo(e,`Directive`),n=this.castNodeTo(e.expression,`DirectiveLiteral`),r=n.value,i=this.input.slice(this.offsetToSourcePos(n.start),this.offsetToSourcePos(n.end)),a=n.value=i.slice(1,-1);return this.addExtra(n,`raw`,i),this.addExtra(n,`rawValue`,a),this.addExtra(n,`expressionValue`,r),t.value=n,delete e.expression,t}parseInterpreterDirective(){if(!this.match(24))return null;let e=this.startNode();return e.value=this.state.value,this.next(),this.finishNode(e,`InterpreterDirective`)}isLet(){return this.isContextual(96)?this.hasFollowingBindingAtom():!1}isUsing(){return this.isContextual(103)?this.nextTokenIsIdentifierOnSameLine():!1}isForUsing(){if(!this.isContextual(103))return!1;let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);if(this.isUnparsedContextual(e,`of`)){let t=this.lookaheadCharCodeSince(e+2);if(t!==61&&t!==58&&t!==59)return!1}return!!(this.chStartsBindingIdentifier(t,e)||this.isUnparsedContextual(e,`void`))}nextTokenIsIdentifierOnSameLine(){let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);return this.chStartsBindingIdentifier(t,e)}isAwaitUsing(){if(!this.isContextual(92))return!1;let e=this.nextTokenInLineStart();if(this.isUnparsedContextual(e,`using`)){e=this.nextTokenInLineStartSince(e+5);let t=this.codePointAtPos(e);if(this.chStartsBindingIdentifier(t,e))return!0}return!1}chStartsBindingIdentifier(e,t){if(Pd(e)){if(lp.lastIndex=t,lp.test(this.input)){let e=this.codePointAtPos(lp.lastIndex);if(!Fd(e)&&e!==92)return!1}return!0}return e===92}chStartsBindingPattern(e){return e===91||e===123}hasFollowingBindingAtom(){let e=this.nextTokenStart(),t=this.codePointAtPos(e);return this.chStartsBindingPattern(t)||this.chStartsBindingIdentifier(t,e)}hasInLineFollowingBindingIdentifierOrBrace(){let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);return t===123||this.chStartsBindingIdentifier(t,e)}allowsUsing(){return(this.scope.inModule||!this.scope.inTopLevel)&&!this.scope.inBareCaseStatement}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(e=!1){let t=0;return this.options.annexB&&!this.state.strict&&(t|=4,e&&(t|=8)),this.parseStatementLike(t)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(e){let t=null;return this.match(22)&&(t=this.parseDecorators(!0)),this.parseStatementContent(e,t)}parseStatementContent(e,t){let n=this.state.type,r=this.startNode(),i=!!(e&2),a=!!(e&4),o=e&1;switch(n){case 56:return this.parseBreakContinueStatement(r,!0);case 59:return this.parseBreakContinueStatement(r,!1);case 60:return this.parseDebuggerStatement(r);case 86:return this.parseDoWhileStatement(r);case 87:return this.parseForStatement(r);case 64:if(this.lookaheadCharCode()===46)break;return a||this.raise(this.state.strict?G.StrictFunction:this.options.annexB?G.SloppyFunctionAnnexB:G.SloppyFunction,this.state.startLoc),this.parseFunctionStatement(r,!1,!i&&a);case 76:return i||this.unexpected(),this.parseClass(this.maybeTakeDecorators(t,r),!0);case 65:return this.parseIfStatement(r);case 66:return this.parseReturnStatement(r);case 67:return this.parseSwitchStatement(r);case 68:return this.parseThrowStatement(r);case 69:return this.parseTryStatement(r);case 92:if(this.isAwaitUsing())return this.allowsUsing()?i?this.recordAwaitIfAllowed()||this.raise(G.AwaitUsingNotInAsyncContext,r):this.raise(G.UnexpectedLexicalDeclaration,r):this.raise(G.UnexpectedUsingDeclaration,r),this.next(),this.parseVarStatement(r,`await using`);break;case 103:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifierOrBrace())break;return this.allowsUsing()?i||this.raise(G.UnexpectedLexicalDeclaration,this.state.startLoc):this.raise(G.UnexpectedUsingDeclaration,this.state.startLoc),this.parseVarStatement(r,`using`);case 96:{if(this.state.containsEsc)break;let e=this.nextTokenStart(),t=this.codePointAtPos(e);if(t!==91&&(!i&&this.hasFollowingLineBreak()||!this.chStartsBindingIdentifier(t,e)&&t!==123))break}case 71:i||this.raise(G.UnexpectedLexicalDeclaration,this.state.startLoc);case 70:{let e=this.state.value;return this.parseVarStatement(r,e)}case 88:return this.parseWhileStatement(r);case 72:return this.parseWithStatement(r);case 2:return this.parseBlock();case 9:return this.parseEmptyStatement(r);case 79:{let e=this.lookaheadCharCode();if(e===40||e===46)break}case 78:{!(this.optionFlags&8)&&!o&&this.raise(G.UnexpectedImportExport,this.state.startLoc),this.next();let e;return e=n===79?this.parseImport(r):this.parseExport(r,t),this.assertModuleNodeAllowed(e),e}default:if(this.isAsyncFunction())return i||this.raise(G.AsyncFunctionInSingleStatementContext,this.state.startLoc),this.next(),this.parseFunctionStatement(r,!0,!i&&a)}let s=this.state.value,c=this.parseExpression();return sd(n)&&c.type===`Identifier`&&this.eat(10)?this.parseLabeledStatement(r,s,c,e):this.parseExpressionStatement(r,c)}assertModuleNodeAllowed(e){!(this.optionFlags&8)&&!this.inModule&&this.raise(G.ImportOutsideModule,e)}maybeTakeDecorators(e,t,n){return e&&(t.decorators?.length?(this.raise(G.DecoratorsBeforeAfterExport,t.decorators[0]),t.decorators.unshift(...e)):t.decorators=e,this.resetStartLocationFromNode(t,e[0]),n&&this.resetStartLocationFromNode(n,t)),t}canHaveLeadingDecorator(){return this.match(76)}parseDecorators(e){let t=[];do t.push(this.parseDecorator());while(this.match(22));if(this.match(78))e||this.unexpected();else if(!this.canHaveLeadingDecorator())throw this.raise(G.UnexpectedLeadingDecorator,this.state.startLoc);return t}parseDecorator(){this.expectOnePlugin([`decorators`,`decorators-legacy`]);let e=this.startNode();if(this.next(),this.hasPlugin(`decorators`)){let t=this.state.startLoc,n;if(this.match(6)){let t=this.state.startLoc;this.next(),n=this.parseExpression(),this.expect(7),n=this.wrapParenthesis(t,n);let r=this.state.startLoc;e.expression=this.parseMaybeDecoratorArguments(n,t),e.expression!==n&&this.raise(G.DecoratorArgumentsOutsideParentheses,r)}else{for(n=this.parseIdentifier(!1);this.eat(12);){let e=this.startNodeAt(t);e.object=n,this.match(134)?(this.classScope.usePrivateName(this.state.value,this.state.startLoc),e.property=this.parsePrivateName()):e.property=this.parseIdentifier(!0),e.computed=!1,n=this.finishNode(e,`MemberExpression`)}e.expression=this.parseMaybeDecoratorArguments(n,t)}}else this.state.canStartArrow=!1,e.expression=this.parseExprSubscripts();return this.finishNode(e,`Decorator`)}parseMaybeDecoratorArguments(e,t){if(this.eat(6)){let n=this.startNodeAt(t);return n.callee=e,n.arguments=this.parseCallExpressionArguments(),this.toReferencedList(n.arguments),this.finishNode(n,`CallExpression`)}return e}parseBreakContinueStatement(e,t){return this.next(),this.isLineTerminator()?e.label=null:(e.label=this.parseIdentifier(),this.semicolon()),this.verifyBreakContinue(e,t),this.finishNode(e,t?`BreakStatement`:`ContinueStatement`)}verifyBreakContinue(e,t){let n=0;for(;n<this.state.labels.length;++n){let r=this.state.labels[n];if((e.label==null||r.name===e.label.name)&&(r.kind!=null&&(t||r.kind===1)||e.label&&t))break}if(n===this.state.labels.length){let n=t?`BreakStatement`:`ContinueStatement`;this.raise(G.IllegalBreakContinue,e,{type:n})}}parseDebuggerStatement(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)}parseHeaderExpression(){this.expect(6);let e=this.parseExpression();return this.expect(7),e}parseDoWhileStatement(e){return this.next(),this.state.labels.push(op),e.body=this.parseStatement(),this.state.labels.pop(),this.expect(88),e.test=this.parseHeaderExpression(),this.eat(9),this.finishNode(e,`DoWhileStatement`)}parseForStatement(e){this.next(),this.state.labels.push(op);let t=null;if(this.isContextual(92)&&this.recordAwaitIfAllowed()&&(t=this.state.startLoc,this.next()),this.scope.enter(0),this.expect(6),this.match(9))return t!==null&&this.unexpected(t),this.parseFor(e,null);let n=this.isContextual(96);{let r=this.isAwaitUsing(),i=r||this.isForUsing(),a=n&&this.hasFollowingBindingAtom()||i;if(this.match(70)||this.match(71)||a){let n=this.startNode(),a;r?(a=`await using`,this.recordAwaitIfAllowed()||this.raise(G.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):a=this.state.value,this.next(),this.parseVar(n,!0,a);let o=this.finishNode(n,`VariableDeclaration`),s=this.match(54);return s&&i&&this.raise(G.ForInUsing,o),(s||this.isContextual(98))&&o.declarations.length===1?this.parseForX(e,o,t):(t!==null&&this.unexpected(t),this.parseFor(e,o))}}let r=this.isContextual(91),i=new $f,a=this.parseExpression(!0,i),o=this.isContextual(98);if(o&&(n&&this.raise(G.ForOfLet,a),t===null&&r&&a.type===`Identifier`&&this.raise(G.ForOfAsync,a)),o||this.match(54)){this.checkDestructuringPrivate(i),this.toAssignable(a,!0);let n=o?`ForOfStatement`:`ForInStatement`;return this.checkLVal(a,{type:n}),this.parseForX(e,a,t)}return this.checkExpressionErrors(i,!0),t!==null&&this.unexpected(t),this.parseFor(e,a)}parseFunctionStatement(e,t,n){return this.next(),this.parseFunction(e,1|(n?2:0)|(t?8:0))}parseIfStatement(e){return this.next(),e.test=this.parseHeaderExpression(),e.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),e.alternate=this.eat(62)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(e,`IfStatement`)}parseReturnStatement(e){return this.prodParam.hasReturn||this.raise(G.IllegalReturn,this.state.startLoc),this.next(),this.isLineTerminator()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)}parseSwitchStatement(e){this.next(),e.discriminant=this.parseHeaderExpression();let t=e.cases=[];this.expect(2),this.state.labels.push(sp),this.scope.enter(256);let n;for(let e;!this.match(4);)if(this.match(57)||this.match(61)){let r=this.match(57);n&&this.finishNode(n,`SwitchCase`),t.push(n=this.startNode()),n.consequent=[],this.next(),r?n.test=this.parseExpression():(e&&this.raise(G.MultipleDefaultsInSwitch,this.state.lastTokStartLoc),e=!0,n.test=null),this.expect(10)}else n?n.consequent.push(this.parseStatementListItem()):this.unexpected();return this.scope.exit(),n&&this.finishNode(n,`SwitchCase`),this.next(),this.state.labels.pop(),this.finishNode(e,`SwitchStatement`)}parseThrowStatement(e){return this.next(),this.hasPrecedingLineBreak()&&this.raise(G.NewlineAfterThrow,this.state.lastTokEndLoc),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)}parseCatchClauseParam(){let e=this.parseBindingAtom();return this.scope.enter(this.options.annexB&&e.type===`Identifier`?8:0),this.checkLVal(e,{type:`CatchClause`},9),e}parseTryStatement(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.match(58)){let t=this.startNode();this.next(),this.match(6)?(this.expect(6),t.param=this.parseCatchClauseParam(),this.expect(7)):(t.param=null,this.scope.enter(0)),t.body=this.parseBlock(!1,!1),this.scope.exit(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(63)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(G.NoCatchOrFinally,e),this.finishNode(e,`TryStatement`)}parseVarStatement(e,t,n=!1){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)}parseWhileStatement(e){return this.next(),e.test=this.parseHeaderExpression(),this.state.labels.push(op),e.body=this.parseStatement(),this.state.labels.pop(),this.finishNode(e,`WhileStatement`)}parseWithStatement(e){return this.state.strict&&this.raise(G.StrictWith,this.state.startLoc),this.next(),e.object=this.parseHeaderExpression(),e.body=this.parseStatement(),this.finishNode(e,`WithStatement`)}parseEmptyStatement(e){return this.next(),this.finishNode(e,`EmptyStatement`)}parseLabeledStatement(e,t,n,r){for(let e of this.state.labels)e.name===t&&this.raise(G.LabelRedeclaration,n,{labelName:t});let i=hd(this.state.type)?1:this.match(67)?2:null;for(let t=this.state.labels.length-1;t>=0;t--){let n=this.state.labels[t];if(n.statementStart===e.start)n.statementStart=this.sourceToOffsetPos(this.state.start),n.kind=i;else break}return this.state.labels.push({name:t,kind:i,statementStart:this.sourceToOffsetPos(this.state.start)}),e.body=r&8?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)}parseExpressionStatement(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)}parseBlock(e=!1,t=!0,n){let r=this.startNode();return e&&this.state.strictErrors.clear(),this.expect(2),t&&this.scope.enter(0),this.parseBlockBody(r,e,!1,4,n),t&&this.scope.exit(),this.finishNode(r,`BlockStatement`)}isValidDirective(e){return e.type===`ExpressionStatement`&&e.expression.type===`StringLiteral`&&!e.expression.extra.parenthesized}parseBlockBody(e,t,n,r,i){let a=e.body=[],o=e.directives=[];this.parseBlockOrModuleBlockBody(a,t?o:void 0,n,r,i)}parseBlockOrModuleBlockBody(e,t,n,r,i){let a=this.state.strict,o=!1,s=!1;for(;!this.match(r);){let r=n?this.parseModuleItem():this.parseStatementListItem();if(t&&!s){if(this.isValidDirective(r)){let e=this.stmtToDirective(r);t.push(e),!o&&e.value.value===`use strict`&&(o=!0,this.setStrict(!0));continue}s=!0,this.state.strictErrors.clear()}e.push(r)}i?.call(this,o),a||this.setStrict(!1),this.next()}parseFor(e,t){return e.init=t,this.semicolon(!1),e.test=this.match(9)?null:this.parseExpression(),this.semicolon(!1),e.update=this.match(7)?null:this.parseExpression(),this.expect(7),e.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(e,`ForStatement`)}parseForX(e,t,n){let r=this.match(54);return this.next(),r?n!==null&&this.unexpected(n):e.await=n!==null,t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!r||!this.options.annexB||this.state.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(G.ForInOfLoopInitializer,t,{type:r?`ForInStatement`:`ForOfStatement`}),t.type===`AssignmentPattern`&&this.raise(G.InvalidLhs,t,{ancestor:{type:`ForStatement`}}),e.left=t,e.right=r?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(7),e.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(e,r?`ForInStatement`:`ForOfStatement`)}parseVar(e,t,n,r=!1){let i=e.declarations=[];for(e.kind=n;;){let e=this.startNode();if(this.parseVarId(e,n),e.init=this.eat(25)?t?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn():null,e.init===null&&!r&&(e.id.type!==`Identifier`&&!(t&&(this.match(54)||this.isContextual(98)))?this.raise(G.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:`destructuring`}):(n===`const`||n===`using`||n===`await using`)&&!(this.match(54)||this.isContextual(98))&&this.raise(G.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:n})),i.push(this.finishNode(e,`VariableDeclarator`)),!this.eat(8))break}return e}parseVarId(e,t){let n=this.parseBindingAtom();t===`using`||t===`await using`?(n.type===`ArrayPattern`||n.type===`ObjectPattern`)&&this.raise(G.UsingDeclarationHasBindingPattern,n):n.type===`VoidPattern`&&this.raise(G.UnexpectedVoidPattern,n),this.checkLVal(n,{type:`VariableDeclarator`},t===`var`?5:8201),e.id=n}parseAsyncFunctionExpression(e){return this.parseFunction(e,8)}parseFunction(e,t=0){let n=t&2,r=!!(t&1),i=r&&!(t&4),a=!!(t&8);return this.initFunction(e,a),this.match(51)&&(n&&this.raise(G.GeneratorInSingleStatementContext,this.state.startLoc),this.next(),e.generator=!0),r&&(e.id=this.parseFunctionId(i)),this.scope.enter(514),this.prodParam.enter(Zf(a,e.generator)),r||(e.id=this.parseFunctionId()),this.parseFunctionParams(e,!1),this.parseFunctionBodyAndFinish(e,r?`FunctionDeclaration`:`FunctionExpression`),this.prodParam.exit(),this.scope.exit(),r&&!n&&this.registerFunctionStatementId(e),e}parseFunctionId(e){return e||sd(this.state.type)?this.parseIdentifier():null}parseFunctionParams(e,t){this.expect(6),this.expressionScope.enter(Kf()),e.params=this.parseBindingList(7,41,2|(t?4:0)),this.expressionScope.exit()}registerFunctionStatementId(e){e.id&&this.scope.declareName(e.id.name,!this.options.annexB||this.state.strict||e.generator||e.async?this.scope.treatFunctionsAsVar?5:8201:17,e.id.start)}parseClass(e,t,n){this.next();let r=this.state.strict;return this.state.strict=!0,this.parseClassId(e,t,n),this.parseClassSuper(e),e.body=this.parseClassBody(!!e.superClass,r),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)}isClassProperty(){return this.match(25)||this.match(9)||this.match(4)}isClassMethod(){return this.match(6)}nameIsConstructor(e){return e.type===`Identifier`&&e.name===`constructor`||e.type===`StringLiteral`&&e.value===`constructor`}isNonstaticConstructor(e){return!e.computed&&!e.static&&this.nameIsConstructor(e.key)}parseClassBody(e,t){this.classScope.enter();let n={hadConstructor:!1,hadSuperClass:e},r=[],i=this.startNode();for(i.body=[],this.expect(2);!this.match(4);){if(this.eat(9)){if(r.length>0)throw this.raise(G.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(22)){r.push(this.parseDecorator());continue}let e=this.startNode();r.length&&(e.decorators=r,this.resetStartLocationFromNode(e,r[0]),r=[]),this.parseClassMember(i,e,n)}if(this.state.strict=t,this.next(),r.length)throw this.raise(G.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(i,`ClassBody`)}parseClassMemberFromModifier(e,t){let n=this.parseIdentifier(!0);if(this.isClassMethod()){let r=t;return r.kind=`method`,r.computed=!1,r.key=n,r.static=!1,this.pushClassMethod(e,r,!1,!1,!1,!1),!0}if(this.isClassProperty()){let r=t;return r.computed=!1,r.key=n,r.static=!1,e.body.push(this.parseClassProperty(r)),!0}return this.resetPreviousNodeTrailingComments(n),!1}parseClassMember(e,t,n){let r=this.isContextual(102);if(r){if(this.parseClassMemberFromModifier(e,t))return;if(this.eat(2)){this.parseClassStaticBlock(e,t);return}}this.parseClassMemberWithIsStatic(e,t,n,r)}parseClassMemberWithIsStatic(e,t,n,r){let i=t,a=t,o=t,s=t,c=t,l=i,u=i;if(t.static=r,this.parsePropertyNamePrefixOperator(t),this.eat(51)){l.kind=`method`;let t=this.match(134);if(this.parseClassElementName(l),this.parsePostMemberNameModifiers(l),t){this.pushClassPrivateMethod(e,a,!0,!1);return}this.isNonstaticConstructor(i)&&this.raise(G.ConstructorIsGenerator,i.key),this.pushClassMethod(e,i,!0,!1,!1,!1);return}let d=!this.state.containsEsc&&sd(this.state.type),f=this.parseClassElementName(t),p=d?f.name:null,m=this.isPrivateName(f),h=this.state.startLoc;if(this.parsePostMemberNameModifiers(u),this.isClassMethod()){if(l.kind=`method`,m){this.pushClassPrivateMethod(e,a,!1,!1);return}let r=this.isNonstaticConstructor(i),o=!1;r&&(i.kind=`constructor`,i.decorators&&i.decorators.length>0&&this.raise(G.DecoratorConstructor,t),n.hadConstructor&&!this.hasPlugin(`typescript`)&&this.raise(G.DuplicateConstructor,f),r&&this.hasPlugin(`typescript`)&&t.override&&this.raise(G.OverrideOnConstructor,f),n.hadConstructor=!0,o=n.hadSuperClass),this.pushClassMethod(e,i,!1,!1,r,o)}else if(this.isClassProperty())m?this.pushClassPrivateProperty(e,s):this.pushClassProperty(e,o);else if(p===`async`&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(f);let t=this.eat(51);u.optional&&this.unexpected(h),l.kind=`method`;let n=this.match(134);this.parseClassElementName(l),this.parsePostMemberNameModifiers(u),n?this.pushClassPrivateMethod(e,a,t,!0):(this.isNonstaticConstructor(i)&&this.raise(G.ConstructorIsAsync,i.key),this.pushClassMethod(e,i,t,!0,!1,!1))}else if((p===`get`||p===`set`)&&!(this.match(51)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(f),l.kind=p;let t=this.match(134);this.parseClassElementName(i),t?this.pushClassPrivateMethod(e,a,!1,!1):(this.isNonstaticConstructor(i)&&this.raise(G.ConstructorIsAccessor,i.key),this.pushClassMethod(e,i,!1,!1,!1,!1)),this.checkGetterSetterParams(i)}else if(p===`accessor`&&!this.isLineTerminator()){this.expectPlugin(`decoratorAutoAccessors`),this.resetPreviousNodeTrailingComments(f);let t=this.match(134);this.parseClassElementName(o),this.pushClassAccessorProperty(e,c,t)}else this.isLineTerminator()?m?this.pushClassPrivateProperty(e,s):this.pushClassProperty(e,o):this.unexpected()}parseClassElementName(e){let{type:t,value:n}=this.state;if((t===128||t===130)&&e.static&&n===`prototype`&&this.raise(G.StaticPrototype,this.state.startLoc),t===134){n===`constructor`&&this.raise(G.ConstructorClassPrivateField,this.state.startLoc);let t=this.parsePrivateName();return e.key=t,t}return this.parsePropertyName(e),e.key}parseClassStaticBlock(e,t){this.scope.enter(720);let n=this.state.labels;this.state.labels=[],this.prodParam.enter(0);let r=t.body=[];this.parseBlockOrModuleBlockBody(r,void 0,!1,4),this.prodParam.exit(),this.scope.exit(),this.state.labels=n,e.body.push(this.finishNode(t,`StaticBlock`)),t.decorators?.length&&this.raise(G.DecoratorStaticBlock,t)}pushClassProperty(e,t){!t.computed&&this.nameIsConstructor(t.key)&&this.raise(G.ConstructorClassField,t.key),e.body.push(this.parseClassProperty(t))}pushClassPrivateProperty(e,t){let n=this.parseClassPrivateProperty(t);e.body.push(n),this.classScope.declarePrivateName(this.getPrivateNameSV(n.key),0,n.key.start)}pushClassAccessorProperty(e,t,n){!n&&!t.computed&&this.nameIsConstructor(t.key)&&this.raise(G.ConstructorClassField,t.key);let r=this.parseClassAccessorProperty(t);e.body.push(r),n&&this.classScope.declarePrivateName(this.getPrivateNameSV(r.key),0,r.key.start)}pushClassMethod(e,t,n,r,i,a){e.body.push(this.parseMethod(t,n,r,i,a,`ClassMethod`,!0))}pushClassPrivateMethod(e,t,n,r){let i=this.parseMethod(t,n,r,!1,!1,`ClassPrivateMethod`,!0);e.body.push(i);let a=i.kind===`get`?i.static?6:2:i.kind===`set`?i.static?5:1:0;this.declareClassPrivateMethodInScope(i,a)}declareClassPrivateMethodInScope(e,t){this.classScope.declarePrivateName(this.getPrivateNameSV(e.key),t,e.key.start)}parsePostMemberNameModifiers(e){}parseClassPrivateProperty(e){return this.parseInitializer(e),this.semicolon(),this.finishNode(e,`ClassPrivateProperty`)}parseClassProperty(e){return this.parseInitializer(e),this.semicolon(),this.finishNode(e,`ClassProperty`)}parseClassAccessorProperty(e){return this.parseInitializer(e),this.semicolon(),this.finishNode(e,`ClassAccessorProperty`)}parseInitializer(e){this.scope.enter(592),this.expressionScope.enter(Yf()),this.prodParam.enter(0),e.value=this.eat(25)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(e,t,n,r=8331){if(sd(this.state.type))e.id=this.parseIdentifier(),t&&this.declareNameFromIdentifier(e.id,r);else if(n||!t)e.id=null;else throw this.raise(G.MissingClassName,this.state.startLoc)}parseClassSuper(e){this.eat(77)?(this.state.canStartArrow=!1,e.superClass=this.parseExprSubscripts()):e.superClass=null}parseExport(e,t){let n=this.parseMaybeImportPhase(e,!0),r=this.maybeParseExportDefaultSpecifier(e,n),i=!r||this.eat(8),a=i&&this.eatExportStar(e),o=a&&this.maybeParseExportNamespaceSpecifier(e),s=i&&(!o||this.eat(8)),c=r||a;if(a&&!o){if(r&&this.unexpected(),t)throw this.raise(G.UnsupportedDecoratorExport,e);return this.parseExportFrom(e,!0),this.sawUnambiguousESM=!0,this.finishNode(e,`ExportAllDeclaration`)}let l=this.maybeParseExportNamedSpecifiers(e);r&&i&&!a&&!l&&this.unexpected(null,2),o&&s&&this.unexpected(null,94);let u;if(c||l){if(u=!1,t)throw this.raise(G.UnsupportedDecoratorExport,e);this.parseExportFrom(e,c)}else u=this.maybeParseExportDeclaration(e);if(c||l||u){let n=e;if(this.checkNamedExport(n,!!n.source),n.declaration?.type===`ClassDeclaration`)this.maybeTakeDecorators(t,n.declaration,n);else if(t)throw this.raise(G.UnsupportedDecoratorExport,e);return this.sawUnambiguousESM=!0,this.finishNode(n,`ExportNamedDeclaration`)}if(this.eat(61)){let n=e,r=this.parseExportDefaultExpression();if(n.declaration=r,r.type===`ClassDeclaration`)this.maybeTakeDecorators(t,r,n);else if(t)throw this.raise(G.UnsupportedDecoratorExport,e);return this.checkDuplicateExports(e,`default`),this.hasPlugin(`exportDefaultFrom`)&&r.type===`Identifier`&&r.name===`from`&&r.end-r.start===4&&!r.extra?.parenthesized&&this.raise(G.ExportDefaultFromAsIdentifier,r),this.sawUnambiguousESM=!0,this.finishNode(n,`ExportDefaultDeclaration`)}throw this.unexpected(null,2)}eatExportStar(e){return this.eat(51)}maybeParseExportDefaultSpecifier(e,t){if(t||this.isExportDefaultSpecifier()){this.expectPlugin(`exportDefaultFrom`,t?.start);let n=t||this.parseIdentifier(!0),r=this.startNodeAtNode(n);return r.exported=n,e.specifiers=[this.finishNode(r,`ExportDefaultSpecifier`)],!0}return!1}maybeParseExportNamespaceSpecifier(e){if(this.isContextual(89)){e.specifiers??=[];let t=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),t.exported=this.parseModuleExportName(),e.specifiers.push(this.finishNode(t,`ExportNamespaceSpecifier`)),!0}return!1}maybeParseExportNamedSpecifiers(e){if(this.match(2)){let t=e;t.specifiers||=[];let n=t.exportKind===`type`;return t.specifiers.push(...this.parseExportSpecifiers(n)),t.source=null,t.attributes=[],t.declaration=null,!0}return!1}maybeParseExportDeclaration(e){return this.shouldParseExportDeclaration()?(e.specifiers=[],e.source=null,e.attributes=[],e.declaration=this.parseExportDeclaration(e),!0):!1}isAsyncFunction(){if(!this.isContextual(91))return!1;let e=this.nextTokenInLineStart();return this.isUnparsedContextual(e,`function`)}parseExportDefaultExpression(){let e=this.startNode();if(this.match(64))return this.next(),this.parseFunction(e,5);if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(e,13);if(this.match(76))return this.parseClass(e,!0,!0);if(this.match(22))return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(71)||this.match(70)||this.isLet()||this.isUsing()||this.isAwaitUsing())throw this.raise(G.UnsupportedDefaultExport,this.state.startLoc);let t=this.parseMaybeAssignAllowIn();return this.semicolon(),t}parseExportDeclaration(e){return this.match(76)?this.parseClass(this.startNode(),!0,!1):this.parseStatementListItem()}isExportDefaultSpecifier(){let{type:e}=this.state;if(sd(e)){if(e===91&&!this.state.containsEsc||e===96)return!1;if((e===126||e===125)&&!this.state.containsEsc){let e=this.nextTokenStart(),t=this.input.charCodeAt(e);if(t===123||this.chStartsBindingIdentifier(t,e)&&!this.input.startsWith(`from`,e))return this.expectOnePlugin([`flow`,`typescript`]),!1}}else if(!this.match(61))return!1;let t=this.nextTokenStart(),n=this.isUnparsedContextual(t,`from`);if(this.input.charCodeAt(t)===44||sd(this.state.type)&&n)return!0;if(this.match(61)&&n){let e=this.input.charCodeAt(this.nextTokenStartSince(t+4));return e===34||e===39}return!1}parseExportFrom(e,t){this.eatContextual(94)?(e.source=this.parseImportSource(),this.maybeParseImportAttributes(e)):t&&this.unexpected(),this.semicolon()}shouldParseExportDeclaration(){let{type:e}=this.state;return e===22&&(this.expectOnePlugin([`decorators`,`decorators-legacy`]),this.hasPlugin(`decorators`))?!0:this.isUsing()||this.isAwaitUsing()?(this.raise(G.UsingDeclarationExport,this.state.startLoc),!0):e===70||e===71||e===64||e===76||this.isLet()||this.isAsyncFunction()}checkNamedExport(e,t){if(e.specifiers?.length)for(let n of e.specifiers){let{exported:e}=n,r=e.type===`Identifier`?e.name:e.value;if(this.checkDuplicateExports(n,r),!t&&n.type===`ExportSpecifier`){let{local:e}=n;e.type===`Identifier`?(this.checkReservedWord(e.name,e.start,!0,!1),this.scope.checkLocalExport(e)):this.raise(G.ExportBindingIsString,n,{localName:e.value,exportName:r})}}else if(e.declaration){let t=e.declaration;if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let{id:n}=t;if(!n)throw Error(`Assertion failure`);this.checkDuplicateExports(e,n.name)}else if(t.type===`VariableDeclaration`)for(let e of t.declarations)this.checkDeclaration(e.id)}}checkDeclaration(e){if(e.type===`Identifier`)this.checkDuplicateExports(e,e.name);else if(e.type===`ObjectPattern`)for(let t of e.properties)this.checkDeclaration(t);else if(e.type===`ArrayPattern`)for(let t of e.elements)t&&this.checkDeclaration(t);else e.type===`ObjectProperty`?this.checkDeclaration(e.value):e.type===`RestElement`?this.checkDeclaration(e.argument):e.type===`AssignmentPattern`&&this.checkDeclaration(e.left)}checkDuplicateExports(e,t){this.exportedIdentifiers.has(t)&&(t==="default"?this.raise(G.DuplicateDefaultExport,e):this.raise(G.DuplicateExport,e,{exportName:t})),this.exportedIdentifiers.add(t)}parseExportSpecifiers(e){let t=[],n=!0;for(this.expect(2);!this.eat(4);){if(n)n=!1;else if(this.expect(8),this.eat(4))break;let r=this.isContextual(126),i=this.match(130),a=this.startNode();a.local=this.parseModuleExportName(),t.push(this.parseExportSpecifier(a,i,e,r))}return t}parseExportSpecifier(e,t,n,r){return this.eatContextual(89)?e.exported=this.parseModuleExportName():t?e.exported=this.cloneStringLiteral(e.local):e.exported||=this.cloneIdentifier(e.local),this.finishNode(e,`ExportSpecifier`)}parseModuleExportName(){if(this.match(130)){let e=this.parseStringLiteral(this.state.value),t=cp.exec(e.value);return t&&this.raise(G.ModuleExportNameHasLoneSurrogate,e,{surrogateCharCode:t[0].charCodeAt(0)}),e}return this.parseIdentifier(!0)}checkImportPhase(e){let{specifiers:t}=e,n=t.length===1?t[0].type:null;e.phase===`source`?n!==`ImportDefaultSpecifier`&&this.raise(G.SourcePhaseImportRequiresDefault,t[0]):e.phase===`defer`&&n!==`ImportNamespaceSpecifier`&&this.raise(G.DeferImportRequiresNamespace,t[0])}isPotentialImportPhase(e){return e?!1:this.isContextual(101)||this.isContextual(93)}applyImportPhase(e,t,n,r){t||(n===`source`?(this.expectPlugin(`sourcePhaseImports`,r),e.phase=`source`):n===`defer`?(this.expectPlugin(`deferredImportEvaluation`,r),e.phase=`defer`):this.hasPlugin(`sourcePhaseImports`)&&(e.phase=null))}parseMaybeImportPhase(e,t){if(!this.isPotentialImportPhase(t))return this.applyImportPhase(e,t,null),null;let n=this.startNode(),r=this.parseIdentifierName(!0),{type:i}=this.state;return(ld(i)?i!==94||this.lookaheadCharCode()===102:i!==8)?(this.applyImportPhase(e,t,r,n.start),null):(this.applyImportPhase(e,t,null),this.createIdentifier(n,r))}isPrecedingIdImportPhase(e){let{type:t}=this.state;return sd(t)?t!==94||this.lookaheadCharCode()===102:t!==8}parseImport(e){return this.match(130)?this.parseImportSourceAndAttributes(e):this.parseImportSpecifiersAndAfter(e,this.parseMaybeImportPhase(e,!1))}parseImportSpecifiersAndAfter(e,t){e.specifiers=[];let n=!this.maybeParseDefaultImportSpecifier(e,t)||this.eat(8),r=n&&this.maybeParseStarImportSpecifier(e);return n&&!r&&this.parseNamedImportSpecifiers(e),this.expectContextual(94),this.parseImportSourceAndAttributes(e)}parseImportSourceAndAttributes(e){return e.specifiers??=[],e.source=this.parseImportSource(),this.maybeParseImportAttributes(e),this.checkImportPhase(e),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(e,`ImportDeclaration`)}parseImportSource(){return this.match(130)||this.unexpected(),this.parseExprAtom()}parseImportSpecifierLocal(e,t,n){t.local=this.parseIdentifier(),e.specifiers.push(this.finishImportSpecifier(t,n))}finishImportSpecifier(e,t,n=8201){return this.checkLVal(e.local,{type:t},n),this.finishNode(e,t)}parseImportAttributes(){this.expect(2);let e=[],t=new Set;do{if(this.match(4))break;let n=this.startNode(),r=this.state.value;if(t.has(r)&&this.raise(G.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:r}),t.add(r),n.key=this.match(130)?this.parseStringLiteral(r):this.parseIdentifier(!0),this.expect(10),!this.match(130))throw this.raise(G.ModuleAttributeInvalidValue,this.state.startLoc);n.value=this.parseStringLiteral(this.state.value),e.push(this.finishNode(n,`ImportAttribute`))}while(this.eat(8));return this.expect(4),e}maybeParseImportAttributes(e){let t;if(this.match(72)){if(this.hasPrecedingLineBreak()&&this.lookaheadCharCode()===40)return;this.next(),t=this.parseImportAttributes()}else t=[];e.attributes=t}maybeParseDefaultImportSpecifier(e,t){if(t){let n=this.startNodeAtNode(t);return n.local=t,e.specifiers.push(this.finishImportSpecifier(n,`ImportDefaultSpecifier`)),!0}return ld(this.state.type)?(this.parseImportSpecifierLocal(e,this.startNode(),`ImportDefaultSpecifier`),!0):!1}maybeParseStarImportSpecifier(e){if(this.match(51)){let t=this.startNode();return this.next(),this.expectContextual(89),this.parseImportSpecifierLocal(e,t,`ImportNamespaceSpecifier`),!0}return!1}parseNamedImportSpecifiers(e){let t=!0;for(this.expect(2);!this.eat(4);){if(t)t=!1;else{if(this.eat(10))throw this.raise(G.DestructureNamedImport,this.state.startLoc);if(this.expect(8),this.eat(4))break}let n=this.startNode(),r=this.match(130),i=this.isContextual(126);n.imported=this.parseModuleExportName();let a=this.parseImportSpecifier(n,r,e.importKind===`type`||e.importKind===`typeof`,i,void 0);e.specifiers.push(a)}}parseImportSpecifier(e,t,n,r,i){if(this.eatContextual(89))e.local=this.parseIdentifier();else{let{imported:n}=e;if(t)throw this.raise(G.ImportBindingIsString,e,{importName:n.value});this.checkReservedWord(n.name,e.start,!0,!0),e.local||=this.cloneIdentifier(n)}return this.finishImportSpecifier(e,`ImportSpecifier`,i)}isThisParam(e){return e.type===`Identifier`&&e.name===`this`}},fp=/in(?:stanceof)?|as|satisfies/y;function pp(e){if(e==null)throw Error(`Unexpected ${e} value.`);return e}function mp(e){if(!e)throw Error(`Assert fail`)}var q=Lu`typescript`({AbstractMethodHasImplementation:({methodName:e})=>`Method '${e}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:e})=>`Property '${e}' cannot have an initializer because it is marked abstract.`,AccessorCannotBeOptional:`An 'accessor' property cannot be declared optional.`,AccessorCannotDeclareThisParameter:`'get' and 'set' accessors cannot declare 'this' parameters.`,AccessorCannotHaveTypeParameters:`An accessor cannot have type parameters.`,ClassMethodHasDeclare:`Class methods cannot have the 'declare' modifier.`,ClassMethodHasReadonly:`Class methods cannot have the 'readonly' modifier.`,ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference:`A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.`,ConstructorHasTypeParameters:`Type parameters cannot appear on a constructor declaration.`,DeclaratorDefiniteAssertionRequiresTypeAnnotation:`Declarations with definite assignment assertions must also have type annotations.`,DeclaratorDefiniteAssertionWithInitializer:`Declarations with initializers cannot also have definite assignment assertions.`,DeclareAccessor:({kind:e})=>`'declare' is not allowed in ${e}ters.`,DeclareClassFieldHasInitializer:`Initializers are not allowed in ambient contexts.`,DeclareFunctionHasImplementation:`An implementation cannot be declared in ambient contexts.`,DecoratorAbstractMethod:({kind:e})=>`Decorators can't be used with ${e.startsWith(`a`)?`an`:`a`} ${e}.`,DuplicateAccessibilityModifier:({modifier:e})=>`Accessibility modifier already seen: '${e}'.`,DuplicateModifier:({modifier:e})=>`Duplicate modifier: '${e}'.`,EmptyHeritageClauseType:({token:e})=>`'${e}' list cannot be empty.`,EmptyNamespaceName:`Namespace must be given a name.`,EmptyTypeArguments:`Type argument list cannot be empty.`,EmptyTypeParameters:`Type parameter list cannot be empty.`,ExpectedAmbientAfterExportDeclare:`'export declare' must be followed by an ambient declaration.`,ExportAssignmentInTSNamespace:`An export assignment cannot be used in a namespace.`,ExportInTSNamespace:`Export declarations are not permitted in a namespace.`,ImportAliasHasImportType:`An import alias can not use 'import type'.`,ImportInTSNamespace:`Import declarations in a namespace cannot reference a module.`,IncompatibleModifiers:({modifiers:e})=>`'${e[0]}' modifier cannot be used with '${e[1]}' modifier.`,IndexSignatureHasAbstract:`Index signatures cannot have the 'abstract' modifier.`,IndexSignatureHasAccessibility:({modifier:e})=>`Index signatures cannot have an accessibility modifier ('${e}').`,IndexSignatureHasDeclare:`Index signatures cannot have the 'declare' modifier.`,IndexSignatureHasOverride:`'override' modifier cannot appear on an index signature.`,IndexSignatureHasStatic:`Index signatures cannot have the 'static' modifier.`,InitializerNotAllowedInAmbientContext:`Initializers are not allowed in ambient contexts.`,InlineModuleDeclarationMustUseString:"`module ... {}` declarations must have a string name. Use `namespace ... {}` instead.",InvalidHeritageClauseType:({token:e})=>`'${e}' list can only include identifiers or qualified-names with optional type arguments.`,InvalidModifierOnAwaitUsingDeclaration:e=>`'${e}' modifier cannot appear on an await using declaration.`,InvalidModifierOnTypeMember:({modifier:e})=>`'${e}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:e})=>`'${e}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:e})=>`'${e}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifierOnUsingDeclaration:e=>`'${e}' modifier cannot appear on a using declaration.`,InvalidModifiersOrder:({orderedModifiers:e})=>`'${e[0]}' modifier must precede '${e[1]}' modifier.`,InvalidNamespaceName:e=>`Namespace name cannot be '${e}'.`,InvalidPropertyAccessAfterInstantiationExpression:`Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.`,InvalidTupleMemberLabel:`Tuple members must be labeled with a simple identifier.`,MissingInterfaceName:`'interface' declarations must be followed by an identifier.`,NamespaceExportInTSNamespace:`Global module exports may only appear at top level.`,NonAbstractClassHasAbstractMethod:`Abstract methods can only appear within an abstract class.`,NonClassMethodPropertyHasAbstractModifier:`'abstract' modifier can only appear on a class, method, or property declaration.`,OptionalTypeBeforeRequired:`A required element cannot follow an optional element.`,OverrideNotInSubClass:`This member cannot have an 'override' modifier because its containing class does not extend another class.`,PatternIsOptional:`A binding pattern parameter cannot be optional in an implementation signature.`,PrivateElementHasAbstract:`Private elements cannot have the 'abstract' modifier.`,PrivateElementHasAccessibility:({modifier:e})=>`Private elements cannot have an accessibility modifier ('${e}').`,ReadonlyForMethodSignature:`'readonly' modifier can only appear on a property declaration or index signature.`,ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccessorCannotHaveOptionalParameter:`A 'set' accessor cannot have an optional parameter.`,SetAccessorCannotHaveRestParameter:`A 'set' accessor cannot have rest parameter.`,SetAccessorCannotHaveReturnType:`A 'set' accessor cannot have a return type annotation.`,SingleTypeParameterWithoutTrailingComma:({typeParameterName:e})=>`Single type parameter ${e} should have a trailing comma. Example usage: <${e},>.`,StaticBlockCannotHaveModifier:`Static class blocks cannot have any modifier.`,TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:`A type-only import can specify a default import or named bindings, but not both.`,TypeModifierIsUsedInTypeExports:`The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.`,TypeModifierIsUsedInTypeImports:`The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.`,UnexpectedParameterInitializer:`A parameter initializer is only allowed in a function or constructor implementation.`,UnexpectedParameterModifier:`A parameter property is only allowed in a constructor implementation.`,UnexpectedReadonly:`'readonly' type modifier is only permitted on array and tuple literal types.`,UnexpectedTypeAnnotation:`Did not expect a type annotation here.`,UnexpectedTypeCastInParameter:`Unexpected type cast in parameter position.`,UnexpectedTypeDeclaration:e=>`'${e}' declarations can only be declared inside a block.`,UnsupportedImportTypeArgument:`Argument in a type import must be a string literal.`,UnsupportedParameterPropertyKind:`A parameter property may not be declared using a binding pattern.`,UnsupportedSignatureParameterKind:({type:e})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${e}.`,UsingDeclarationInAmbientContext:e=>`'${e}' declarations are not allowed in ambient contexts.`});function hp(e){switch(e){case`any`:return`TSAnyKeyword`;case`boolean`:return`TSBooleanKeyword`;case`bigint`:return`TSBigIntKeyword`;case`never`:return`TSNeverKeyword`;case`number`:return`TSNumberKeyword`;case`object`:return`TSObjectKeyword`;case`string`:return`TSStringKeyword`;case`symbol`:return`TSSymbolKeyword`;case`undefined`:return`TSUndefinedKeyword`;case`unknown`:return`TSUnknownKeyword`;default:return}}function gp(e){return e===`private`||e===`public`||e===`protected`}function _p(e){return e===`in`||e===`out`}function vp(e){if(e.extra?.parenthesized)return!1;switch(e.type){case`Identifier`:return!0;case`MemberExpression`:return!e.computed&&vp(e.object);case`TSInstantiationExpression`:return vp(e.expression);default:return!1}}var yp=kp([`declare`,`private`,`public`,`protected`,`override`,`abstract`,`readonly`,`static`],[`in`,`out`]),bp=kp([`readonly`],[`declare`,`abstract`,`private`,`protected`,`public`,`static`,`override`]),xp=kp([`public`,`private`,`protected`,`override`,`readonly`]),Sp=kp([`private`,`public`,`protected`]),Cp=e=>class extends e{getScopeHandler(){return yf}tsIsIdentifier(){return sd(this.state.type)}tsTokenCanFollowModifier(){return this.match(0)||this.match(2)||this.match(51)||this.match(17)||this.match(134)||this.isLiteralPropertyName()}tsNextTokenOnSameLineAndCanFollowModifier(){return this.next(),!this.hasPrecedingLineBreak()&&this.tsTokenCanFollowModifier()}tsNextTokenCanFollowModifier(){return this.match(102)?(this.next(),this.tsTokenCanFollowModifier()):this.tsNextTokenOnSameLineAndCanFollowModifier()}tsParseModifier(e,t,n){if(!sd(this.state.type)&&this.state.type!==54&&this.state.type!==71)return;let r=this.state.value;if(e.has(r)){if(n&&this.match(102)||t&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return r}}tsParseModifiers(e,t=q.InvalidModifierOnTypeMember,n,r=!1){let i=(e,t,r,i)=>{t===r&&n[i]&&this.raise(q.InvalidModifiersOrder,e,{orderedModifiers:[r,i]})},a=(e,t,r,i)=>{(n[r]&&t===i||n[i]&&t===r)&&this.raise(q.IncompatibleModifiers,e,{modifiers:[r,i]})};for(;;){let{startLoc:o}=this.state,s=this.tsParseModifier(e,r,n.static);if(!s)break;gp(s)?n.accessibility?this.raise(q.DuplicateAccessibilityModifier,o,{modifier:s}):(i(o,s,s,`override`),i(o,s,s,`static`),i(o,s,s,`readonly`),n.accessibility=s):_p(s)?(n[s]&&this.raise(q.DuplicateModifier,o,{modifier:s}),n[s]=!0,i(o,s,`in`,`out`)):(Object.hasOwn(n,s)?this.raise(q.DuplicateModifier,o,{modifier:s}):(i(o,s,`static`,`readonly`),i(o,s,`static`,`override`),i(o,s,`override`,`readonly`),i(o,s,`abstract`,`override`),a(o,s,`declare`,`override`),a(o,s,`static`,`abstract`)),n[s]=!0),e.get(s)||this.raise(t,o,{modifier:s})}}tsIsListTerminator(e){switch(e){case`EnumMembers`:case`TypeMembers`:return this.match(4);case`HeritageClauseElement`:return this.match(2);case`TupleElementTypes`:return this.match(1);case`TypeParametersOrArguments`:return this.match(44)}}tsParseList(e,t){let n=[];for(;!this.tsIsListTerminator(e);)n.push(t());return n}tsParseDelimitedList(e,t,n){return pp(this.tsParseDelimitedListWorker(e,t,!0,n))}tsParseDelimitedListWorker(e,t,n,r){let i=[],a=-1;for(;!this.tsIsListTerminator(e);){a=-1;let r=t();if(r==null)return;if(i.push(r),this.eat(8)){a=this.state.lastTokStartLoc.index;continue}if(this.tsIsListTerminator(e))break;n&&this.expect(8);return}return r&&(r.value=a),i}tsParseBracketedList(e,t,n,r,i){r||(n?this.expect(0):this.expect(43));let a=this.tsParseDelimitedList(e,t,i);return n?this.expect(1):this.expect(44),a}tsParseImportType(){let e=this.startNode();return this.expect(79),this.expect(6),this.match(130)?e.source=this.parseStringLiteral(this.state.value):(this.raise(q.UnsupportedImportTypeArgument,this.state.startLoc),e.source=this.tsParseNonConditionalType()),e.options=this.eat(8)?this.tsParseImportTypeOptions():null,this.expect(7),this.eat(12)&&(e.qualifier=this.tsParseEntityName(3)),this.match(43)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,`TSImportType`)}tsParseImportTypeOptions(){let e=this.startNode();this.expect(2);let t=this.startNode();return this.isContextual(72)?(t.method=!1,t.key=this.parseIdentifier(!0),t.computed=!1,t.shorthand=!1):this.unexpected(null,72),this.expect(10),t.value=this.tsParseImportTypeWithPropertyValue(),e.properties=[this.finishObjectProperty(t)],this.eat(8),this.expect(4),this.finishNode(e,`ObjectExpression`)}tsParseImportTypeWithPropertyValue(){let e=this.startNode(),t=[];for(this.expect(2);!this.match(4);){let e=this.state.type;sd(e)||e===130?t.push(super.parsePropertyDefinition(null)):this.unexpected(),this.eat(8)}return e.properties=t,this.next(),this.finishNode(e,`ObjectExpression`)}tsParseEntityName(e){let t;if(e&1&&this.match(74)){if(e&2)t=this.parseIdentifier(!0);else{let e=this.startNode();this.next(),t=this.finishNode(e,`ThisExpression`)}}else t=this.parseIdentifier(!!(e&1));for(;this.eat(12);){let n=this.startNodeAtNode(t);n.left=t,n.right=this.parseIdentifier(!!(e&1)),t=this.finishNode(n,`TSQualifiedName`)}return t}tsParseTypeReference(){let e=this.startNode();return e.typeName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(43)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,`TSTypeReference`)}tsParseThisTypePredicate(e){this.next();let t=this.startNodeAtNode(e);return t.parameterName=e,t.typeAnnotation=this.tsParseTypeAnnotation(!1),t.asserts=!1,this.finishNode(t,`TSTypePredicate`)}tsParseThisTypeNode(){let e=this.startNode();return this.next(),this.finishNode(e,`TSThisType`)}tsParseTypeQuery(){let e=this.startNode();return this.expect(83),e.exprName=this.match(79)?this.tsParseImportType():this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(43)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,`TSTypeQuery`)}tsParseInOutModifiers=this.tsParseModifiers.bind(this,kp([`in`,`out`],[`const`,`public`,`private`,`protected`,`readonly`,`declare`,`abstract`,`override`]),q.InvalidModifierOnTypeParameter);tsParseConstModifier=this.tsParseModifiers.bind(this,kp([`const`],[`in`,`out`]),q.InvalidModifierOnTypeParameterPositions);tsParseInOutConstModifiers=this.tsParseModifiers.bind(this,kp([`in`,`out`,`const`],[`public`,`private`,`protected`,`readonly`,`declare`,`abstract`,`override`]),q.InvalidModifierOnTypeParameter);tsParseTypeParameter(e){let t=this.startNode();return e(t),t.name=this.tsParseTypeParameterName(),t.constraint=this.tsEatThenParseType(77),t.default=this.tsEatThenParseType(25),this.finishNode(t,`TSTypeParameter`)}tsTryParseTypeParameters(e){if(this.match(43))return this.tsParseTypeParameters(e)}tsParseTypeParameters(e){let t=this.startNode();this.match(43)||this.match(138)?this.next():this.unexpected();let n={value:-1};return t.params=this.tsParseBracketedList(`TypeParametersOrArguments`,this.tsParseTypeParameter.bind(this,e),!1,!0,n),t.params.length===0&&this.raise(q.EmptyTypeParameters,t),n.value!==-1&&this.addExtra(t,`trailingComma`,n.value),this.finishNode(t,`TSTypeParameterDeclaration`)}tsFillSignature(e,t){let n=e===15;t.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),this.expect(6),t.params=this.tsParseBindingListForSignature(),(n||this.match(e))&&(t.returnType=this.tsParseTypeOrTypePredicateAnnotation(e))}tsParseBindingListForSignature(){let e=super.parseBindingList(7,41,2);for(let t of e){let{type:e}=t;(e===`AssignmentPattern`||e===`TSParameterProperty`)&&this.raise(q.UnsupportedSignatureParameterKind,t,{type:e})}return e}tsParseTypeMemberSemicolon(){!this.eat(8)&&!this.isLineTerminator()&&this.expect(9)}tsParseSignatureMember(e,t){return this.tsFillSignature(10,t),this.tsParseTypeMemberSemicolon(),this.finishNode(t,e)}tsIsUnambiguouslyIndexSignature(){return this.next(),sd(this.state.type)?(this.next(),this.match(10)):!1}tsTryParseIndexSignature(e){if(!(this.match(0)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))))return;this.expect(0);let t=this.parseIdentifier();t.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(t),this.expect(1),e.parameters=[t];let n=this.tsTryParseTypeAnnotation();return n&&(e.typeAnnotation=n),this.tsParseTypeMemberSemicolon(),this.finishNode(e,`TSIndexSignature`)}tsParsePropertyOrMethodSignature(e,t){if(this.eat(13)&&(e.optional=!0),this.match(6)||this.match(43)){t&&this.raise(q.ReadonlyForMethodSignature,e);let n=e;if(n.kind&&this.match(43)&&this.raise(q.AccessorCannotHaveTypeParameters,this.state.curPosition()),this.tsFillSignature(10,n),this.tsParseTypeMemberSemicolon(),n.kind===`get`)n.params.length>0&&(this.raise(G.BadGetterArity,this.state.curPosition()),this.isThisParam(n.params[0])&&this.raise(q.AccessorCannotDeclareThisParameter,this.state.curPosition()));else if(n.kind===`set`){if(n.params.length!==1)this.raise(G.BadSetterArity,this.state.curPosition());else{let e=n.params[0];this.isThisParam(e)&&this.raise(q.AccessorCannotDeclareThisParameter,this.state.curPosition()),e.type===`Identifier`&&e.optional&&this.raise(q.SetAccessorCannotHaveOptionalParameter,this.state.curPosition()),e.type===`RestElement`&&this.raise(q.SetAccessorCannotHaveRestParameter,this.state.curPosition())}n.returnType&&this.raise(q.SetAccessorCannotHaveReturnType,n.returnType)}else n.kind=`method`;return this.finishNode(n,`TSMethodSignature`)}{let n=e;t&&(n.readonly=!0);let r=this.tsTryParseTypeAnnotation();return r&&(n.typeAnnotation=r),this.tsParseTypeMemberSemicolon(),this.finishNode(n,`TSPropertySignature`)}}tsParseTypeMember(){let e=this.startNode();if(this.match(6)||this.match(43))return this.tsParseSignatureMember(`TSCallSignatureDeclaration`,e);if(this.match(73)){let t=this.startNode();return this.next(),this.match(6)||this.match(43)?this.tsParseSignatureMember(`TSConstructSignatureDeclaration`,e):(e.key=this.createIdentifier(t,`new`),this.tsParsePropertyOrMethodSignature(e,!1))}return this.tsParseModifiers(bp,void 0,e),this.tsTryParseIndexSignature(e)||(super.parsePropertyName(e),!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.tsTokenCanFollowModifier()&&(e.kind=e.key.name,super.parsePropertyName(e),!this.match(6)&&!this.match(43)&&this.unexpected(null,6)),this.tsParsePropertyOrMethodSignature(e,!!e.readonly))}tsParseTypeLiteral(){let e=this.startNode();return e.members=this.tsParseObjectTypeMembers(),this.finishNode(e,`TSTypeLiteral`)}tsParseObjectTypeMembers(){this.expect(2);let e=this.tsParseList(`TypeMembers`,this.tsParseTypeMember.bind(this));return this.expect(4),e}tsIsStartOfMappedType(){return this.next(),this.eat(49)?this.isContextual(118):(this.isContextual(118)&&this.next(),!this.match(0)||(this.next(),!this.tsIsIdentifier())?!1:(this.next(),this.match(54)))}tsParseMappedType(){let e=this.startNode();return this.expect(2),this.match(49)?(e.readonly=this.state.value,this.next(),this.expectContextual(118)):this.eatContextual(118)&&(e.readonly=!0),this.expect(0),e.key=this.tsParseTypeParameterName(),e.constraint=this.tsExpectThenParseType(54),e.nameType=this.eatContextual(89)?this.tsParseType():null,this.expect(1),this.match(49)?(e.optional=this.state.value,this.next(),this.expect(13)):this.eat(13)&&(e.optional=!0),e.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(4),this.finishNode(e,`TSMappedType`)}tsParseTupleType(){let e=this.startNode();e.elementTypes=this.tsParseBracketedList(`TupleElementTypes`,this.tsParseTupleElementType.bind(this),!0,!1);let t=!1;return e.elementTypes.forEach(e=>{let{type:n}=e;t&&n!==`TSRestType`&&n!==`TSOptionalType`&&!(n===`TSNamedTupleMember`&&e.optional)&&this.raise(q.OptionalTypeBeforeRequired,e),t||=n===`TSNamedTupleMember`&&e.optional||n===`TSOptionalType`}),this.finishNode(e,`TSTupleType`)}tsParseTupleElementType(){let e=this.state.startLoc,t=this.eat(17),{startLoc:n}=this.state,r,i,a,o,s=ld(this.state.type)?this.lookaheadCharCode():null;if(s===58)r=!0,a=!1,i=this.parseIdentifier(!0),this.expect(10),o=this.tsParseType();else if(s===63){a=!0;let e=this.state.value,t=this.tsParseNonArrayType();this.lookaheadCharCode()===58?(r=!0,i=this.createIdentifier(this.startNodeAt(n),e),this.expect(13),this.expect(10),o=this.tsParseType()):(r=!1,o=t,this.expect(13))}else o=this.tsParseType(),a=this.eat(13),r=this.eat(10);if(r){let e;i?(e=this.startNodeAt(n),e.optional=a,e.label=i,e.elementType=o,this.eat(13)&&(e.optional=!0,this.raise(q.TupleOptionalAfterType,this.state.lastTokStartLoc))):(e=this.startNodeAt(n),e.optional=a,this.raise(q.InvalidTupleMemberLabel,o),e.label=o,e.elementType=this.tsParseType()),o=this.finishNode(e,`TSNamedTupleMember`)}else if(a){let e=this.startNodeAt(n);e.typeAnnotation=o,o=this.finishNode(e,`TSOptionalType`)}if(t){let t=this.startNodeAt(e);t.typeAnnotation=o,o=this.finishNode(t,`TSRestType`)}return o}tsParseParenthesizedType(){let e=this.startNode();return this.expect(6),e.typeAnnotation=this.tsParseType(),this.expect(7),this.finishNode(e,`TSParenthesizedType`)}tsParseFunctionOrConstructorType(e,t){let n=this.startNode();return e===`TSConstructorType`&&(n.abstract=!!t,t&&this.next(),this.next()),this.tsInAllowConditionalTypesContext(()=>this.tsFillSignature(15,n)),this.finishNode(n,e)}tsParseLiteralTypeNode(){let e=this.startNode();switch(this.state.type){case 131:case 132:case 130:case 81:case 82:e.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode(e,`TSLiteralType`)}tsParseTemplateLiteralType(){let e=this.state.startLoc,t=this.parseTemplateElement(!1),n=[t];if(t.tail){let t=this.startNodeAt(e),r=this.startNodeAt(e);return r.expressions=[],r.quasis=n,t.literal=this.finishNode(r,`TemplateLiteral`),this.finishNode(t,`TSLiteralType`)}{let r=[];for(;!t.tail;)r.push(this.tsParseType()),this.readTemplateContinuation(),n.push(t=this.parseTemplateElement(!1));let i=this.startNodeAt(e);return i.types=r,i.quasis=n,this.finishNode(i,`TSTemplateLiteralType`)}}parseTemplateSubstitution(){return this.state.inType?this.tsParseType():super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){let e=this.tsParseThisTypeNode();return this.isContextual(112)&&!this.hasPrecedingLineBreak()?this.tsParseThisTypePredicate(e):e}tsParseNonArrayType(){switch(this.state.type){case 130:case 131:case 132:case 81:case 82:return this.tsParseLiteralTypeNode();case 49:if(this.state.value===`-`){let e=this.startNode(),t=this.lookahead();return t.type!==131&&t.type!==132&&this.unexpected(),e.literal=this.parseMaybeUnary(),this.finishNode(e,`TSLiteralType`)}break;case 74:return this.tsParseThisTypeOrThisTypePredicate();case 83:return this.tsParseTypeQuery();case 79:return this.tsParseImportType();case 2:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.tsParseTupleType();case 6:if(!(this.optionFlags&2048)){let e=this.state.startLoc;this.next();let t=this.tsParseType();return this.expect(7),this.addExtra(t,`parenthesized`,!0),this.addExtra(t,`parenStart`,e.index),t}return this.tsParseParenthesizedType();case 21:case 20:return this.tsParseTemplateLiteralType();default:{let{type:e}=this.state;if(sd(e)||e===84||e===80){let t=e===84?`TSVoidKeyword`:e===80?`TSNullKeyword`:hp(this.state.value);if(t!==void 0&&this.lookaheadCharCode()!==46){let e=this.startNode();return this.next(),this.finishNode(e,t)}return this.tsParseTypeReference()}}}throw this.unexpected()}tsParseArrayTypeOrHigher(){let{startLoc:e}=this.state,t=this.tsParseNonArrayType();for(;!this.hasPrecedingLineBreak()&&this.eat(0);)if(this.match(1)){let n=this.startNodeAt(e);n.elementType=t,this.expect(1),t=this.finishNode(n,`TSArrayType`)}else{let n=this.startNodeAt(e);n.objectType=t,n.indexType=this.tsParseType(),this.expect(1),t=this.finishNode(n,`TSIndexedAccessType`)}return t}tsParseTypeOperator(){let e=this.startNode(),t=this.state.value;return this.next(),e.operator=t,e.typeAnnotation=this.tsParseTypeOperatorOrHigher(),t===`readonly`&&this.tsCheckTypeAnnotationForReadOnly(e),this.finishNode(e,`TSTypeOperator`)}tsCheckTypeAnnotationForReadOnly(e){switch(e.typeAnnotation.type){case`TSTupleType`:case`TSArrayType`:return;default:this.raise(q.UnexpectedReadonly,e)}}tsParseInferType(){let e=this.startNode();this.expectContextual(111);let t=this.startNode();return t.name=this.tsParseTypeParameterName(),t.constraint=this.tsTryParse(()=>this.tsParseConstraintForInferType()),e.typeParameter=this.finishNode(t,`TSTypeParameter`),this.finishNode(e,`TSInferType`)}tsParseConstraintForInferType(){if(this.eat(77)){let e=this.tsInDisallowConditionalTypesContext(()=>this.tsParseType());if(this.state.inDisallowConditionalTypesContext||!this.match(13))return e}}tsParseTypeOperatorOrHigher(){return bd(this.state.type)&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(111)?this.tsParseInferType():this.tsInAllowConditionalTypesContext(()=>this.tsParseArrayTypeOrHigher())}tsParseUnionOrIntersectionType(e,t,n){let r=this.startNode(),i=this.eat(n),a=[];do a.push(t());while(this.eat(n));return a.length===1&&!i?a[0]:(r.types=a,this.finishNode(r,e))}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType(`TSIntersectionType`,this.tsParseTypeOperatorOrHigher.bind(this),41)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType(`TSUnionType`,this.tsParseIntersectionTypeOrHigher.bind(this),39)}tsIsStartOfFunctionType(){return this.match(43)?!0:this.match(6)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(sd(this.state.type)||this.match(74))return this.next(),!0;if(this.match(2)){let{errors:e}=this.state,t=e.length;try{return this.parseObjectLike(4,!0),e.length===t}catch{return!1}}if(this.match(0)){this.next();let{errors:e}=this.state,t=e.length;try{return super.parseBindingList(1,93,1),e.length===t}catch{return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){return this.next(),!!(this.match(7)||this.match(17)||this.tsSkipParameterStart()&&(this.match(10)||this.match(8)||this.match(13)||this.match(25)||this.match(7)&&(this.next(),this.match(15))))}tsParseTypeOrTypePredicateAnnotation(e){return this.tsInType(()=>{let t=this.startNode();this.expect(e);let n=this.startNode(),r=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(r&&this.match(74)){let e=this.tsParseThisTypeOrThisTypePredicate();return e.type===`TSThisType`?(n.parameterName=e,n.asserts=!0,n.typeAnnotation=null,e=this.finishNode(n,`TSTypePredicate`)):(this.resetStartLocationFromNode(e,n),e.asserts=!0),t.typeAnnotation=e,this.finishNode(t,`TSTypeAnnotation`)}let i=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!i)return r?(n.parameterName=this.parseIdentifier(),n.asserts=r,n.typeAnnotation=null,t.typeAnnotation=this.finishNode(n,`TSTypePredicate`),this.finishNode(t,`TSTypeAnnotation`)):this.tsParseTypeAnnotation(!1,t);let a=this.tsParseTypeAnnotation(!1);return n.parameterName=i,n.typeAnnotation=a,n.asserts=r,t.typeAnnotation=this.finishNode(n,`TSTypePredicate`),this.finishNode(t,`TSTypeAnnotation`)})}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(10))return this.tsParseTypeOrTypePredicateAnnotation(10)}tsTryParseTypeAnnotation(){if(this.match(10))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(10)}tsParseTypePredicatePrefix(){let e=this.parseIdentifier();if(this.isContextual(112)&&!this.hasPrecedingLineBreak())return this.next(),e}tsParseTypePredicateAsserts(){if(this.state.type!==105)return!1;let e=this.state.containsEsc;return this.next(),!sd(this.state.type)&&!this.match(74)?!1:(e&&this.raise(G.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:`asserts`}),!0)}tsParseTypeAnnotation(e=!0,t=this.startNode()){return this.tsInType(()=>{e&&this.expect(10),t.typeAnnotation=this.tsParseType()}),this.finishNode(t,`TSTypeAnnotation`)}tsParseType(){mp(this.state.inType);let e=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(77))return e;let t=this.startNodeAtNode(e);return t.checkType=e,t.extendsType=this.tsInDisallowConditionalTypesContext(()=>this.tsParseNonConditionalType()),this.expect(13),t.trueType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.expect(10),t.falseType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.finishNode(t,`TSConditionalType`)}isAbstractConstructorSignature(){return this.isContextual(120)&&this.isLookaheadContextual(`new`)}tsParseNonConditionalType(){return this.tsIsStartOfFunctionType()?this.tsParseFunctionOrConstructorType(`TSFunctionType`):this.match(73)?this.tsParseFunctionOrConstructorType(`TSConstructorType`):this.isAbstractConstructorSignature()?this.tsParseFunctionOrConstructorType(`TSConstructorType`,!0):this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){this.getPluginOption(`typescript`,`disallowAmbiguousJSXLike`)&&this.raise(q.ReservedTypeAssertion,this.state.startLoc);let e=this.startNode();return e.typeAnnotation=this.tsInType(()=>(this.next(),this.match(71)?this.tsParseTypeReference():this.tsParseType())),this.expect(44),e.expression=this.parseMaybeUnary(),this.finishNode(e,`TSTypeAssertion`)}tsParseHeritageClause(e){let t=this.state.startLoc,n=this.tsParseDelimitedList(`HeritageClauseElement`,()=>{let t=(this.state.canStartArrow=!1,super.parseExprSubscripts());vp(t)||this.raise(q.InvalidHeritageClauseType,t.start,{token:e});let n=e===`extends`?`TSInterfaceHeritage`:`TSClassImplements`;if(t.type===`TSInstantiationExpression`)return t.type=n,t;let r=this.startNodeAtNode(t);return r.expression=t,(this.match(43)||this.match(47))&&(r.typeArguments=this.tsParseTypeArgumentsInExpression()),this.finishNode(r,n)});return n.length||this.raise(q.EmptyHeritageClauseType,t,{token:e}),n}tsParseInterfaceDeclaration(e,t={}){if(this.hasFollowingLineBreak())return null;this.expectContextual(125),t.declare&&(e.declare=!0),sd(this.state.type)?(e.id=this.parseIdentifier(),this.checkIdentifier(e.id,130)):(e.id=null,this.raise(q.MissingInterfaceName,this.state.startLoc)),e.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(77)&&(e.extends=this.tsParseHeritageClause(`extends`));let n=this.startNode();return n.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),e.body=this.finishNode(n,`TSInterfaceBody`),this.finishNode(e,`TSInterfaceDeclaration`)}tsParseTypeAliasDeclaration(e){return e.id=this.parseIdentifier(),this.checkIdentifier(e.id,2),e.typeAnnotation=this.tsInType(()=>{if(e.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(25),this.isContextual(110)&&this.lookaheadCharCode()!==46){let e=this.startNode();return this.next(),this.finishNode(e,`TSIntrinsicKeyword`)}return this.tsParseType()}),this.semicolon(),this.finishNode(e,`TSTypeAliasDeclaration`)}tsInTopLevelContext(e){if(this.curContext()!==Od.brace){let t=this.state.context;this.state.context=[t[0]];try{return e()}finally{this.state.context=t}}else return e()}tsInType(e){let t=this.state.inType;this.state.inType=!0;try{return e()}finally{this.state.inType=t}}tsInDisallowConditionalTypesContext(e){let t=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return e()}finally{this.state.inDisallowConditionalTypesContext=t}}tsInAllowConditionalTypesContext(e){let t=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return e()}finally{this.state.inDisallowConditionalTypesContext=t}}tsEatThenParseType(e){if(this.match(e))return this.tsNextThenParseType()}tsExpectThenParseType(e){return this.tsInType(()=>(this.expect(e),this.tsParseType()))}tsNextThenParseType(){return this.tsInType(()=>(this.next(),this.tsParseType()))}tsParseEnumMember(){let e=this.startNode();return e.id=this.match(130)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(25)&&(e.initializer=super.parseMaybeAssignAllowIn()),this.finishNode(e,`TSEnumMember`)}tsParseEnumDeclaration(e,t={}){return t.const&&(e.const=!0),t.declare&&(e.declare=!0),this.expectContextual(122),e.id=this.parseIdentifier(),this.checkIdentifier(e.id,e.const?8971:8459),e.body=this.tsParseEnumBody(),this.finishNode(e,`TSEnumDeclaration`)}tsParseEnumBody(){let e=this.startNode();return this.expect(2),e.members=this.tsParseDelimitedList(`EnumMembers`,this.tsParseEnumMember.bind(this)),this.expect(4),this.finishNode(e,`TSEnumBody`)}tsParseModuleBlock(e){let t=this.startNode();return e||this.scope.enter(0),this.expect(2),super.parseBlockOrModuleBlockBody(t.body=[],void 0,!0,4),e||this.scope.exit(),this.finishNode(t,`TSModuleBlock`)}tsParseNamespaceDeclaration(e){return e.id=this.tsParseEntityName(0),e.id.type===`Identifier`&&this.checkIdentifier(e.id,1024),this.scope.enter(2048),this.prodParam.enter(0),e.body=this.tsParseModuleBlock(!1),this.prodParam.exit(),this.scope.exit(),this.finishNode(e,`TSModuleDeclaration`)}tsParseAmbientExternalModuleDeclaration(e){let t=this.isContextual(108);if(t)e.kind=`global`,e.id=this.parseIdentifier();else{e.kind=`module`;let{type:t,value:n}=this.state;t===130?e.id=super.parseStringLiteral(n):sd(t)?(this.raise(q.InlineModuleDeclarationMustUseString,this.state.startLoc),e.id=this.tsParseEntityName(0)):t===2?this.raise(q.EmptyNamespaceName,this.state.startLoc):(this.raise(q.InvalidNamespaceName,this.state.startLoc,n),e.id=super.parseExprAtom())}return this.match(2)?(t||this.scope.enter(1024),this.prodParam.enter(0),e.body=this.tsParseModuleBlock(t),this.prodParam.exit(),t||this.scope.exit()):this.semicolon(),this.finishNode(e,`TSModuleDeclaration`)}tsParseImportEqualsDeclaration(e,t){e.id=t||this.parseIdentifier(),this.checkIdentifier(e.id,4096),this.expect(25);let n=this.tsParseModuleReference();return e.importKind===`type`&&n.type!==`TSExternalModuleReference`&&this.raise(q.ImportAliasHasImportType,n),e.moduleReference=n,this.semicolon(),this.finishNode(e,`TSImportEqualsDeclaration`)}tsIsExternalModuleReference(){return this.isContextual(115)&&this.lookaheadCharCode()===40}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(0)}tsParseExternalModuleReference(){let e=this.startNode();return this.expectContextual(115),this.expect(6),this.match(130)||this.unexpected(),e.expression=super.parseExprAtom(),this.expect(7),this.sawUnambiguousESM=!0,this.finishNode(e,`TSExternalModuleReference`)}tsLookAhead(e){let t=this.state.clone(),n=e();return this.state=t,n}tsTryParseAndCatch(e){let t=this.tryParse(t=>e()||t());if(!t.aborted&&t.node)return t.error&&(this.state=t.failState),t.node}tsTryParse(e){let t=this.state.clone(),n=e();if(n!==void 0&&n!==!1)return n;this.state=t}tsTryParseDeclare(e){if(this.isLineTerminator())return;let t=this.state.type;return this.tsInAmbientContext(()=>{switch(t){case 64:return e.declare=!0,super.parseFunctionStatement(e,!1,!1);case 76:return e.declare=!0,this.parseClass(e,!0,!1);case 122:return this.tsParseEnumDeclaration(e,{declare:!0});case 108:return this.tsParseAmbientExternalModuleDeclaration(e);case 96:if(this.state.containsEsc)return;case 71:case 70:return!this.match(71)||!this.isLookaheadContextual(`enum`)?(e.declare=!0,this.parseVarStatement(e,this.state.value,!0)):(this.expect(71),this.tsParseEnumDeclaration(e,{const:!0,declare:!0}));case 103:if(this.isUsing())return this.raise(q.InvalidModifierOnUsingDeclaration,this.state.startLoc,`declare`),e.declare=!0,this.parseVarStatement(e,`using`,!0);break;case 92:if(this.isAwaitUsing())return this.raise(q.InvalidModifierOnAwaitUsingDeclaration,this.state.startLoc,`declare`),e.declare=!0,this.next(),this.parseVarStatement(e,`await using`,!0);break;case 125:{let t=this.tsParseInterfaceDeclaration(e,{declare:!0});if(t)return t}default:if(sd(t))return this.tsParseDeclaration(e,this.state.type,!0,null)}})}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.state.type,!0,null)}tsParseDeclaration(e,t,n,r){switch(t){case 120:if(this.tsCheckLineTerminator(n)&&(this.match(76)||sd(this.state.type)))return this.tsParseAbstractDeclaration(e,r);break;case 123:if(this.tsCheckLineTerminator(n))return this.tsParseAmbientExternalModuleDeclaration(e);break;case 124:if(this.tsCheckLineTerminator(n)&&sd(this.state.type))return e.kind=`namespace`,this.tsParseNamespaceDeclaration(e);break;case 126:if(this.tsCheckLineTerminator(n)&&sd(this.state.type))return this.tsParseTypeAliasDeclaration(e)}}tsCheckLineTerminator(e){return e?!this.hasFollowingLineBreak()&&(this.next(),!0):!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction(e){if(!this.match(43))return;let t=this.tsTryParseAndCatch(()=>{let t=this.startNodeAt(e);return t.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(t),t.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(15),t});if(t)return super.parseArrowExpression(t,null,!0)}tsParseTypeArgumentsInExpression(){if(this.reScan_lt()===43)return this.tsParseTypeArguments()}tsParseTypeArguments(){let e=this.startNode();return e.params=this.tsInType(()=>this.tsInTopLevelContext(()=>(this.expect(43),this.tsParseDelimitedList(`TypeParametersOrArguments`,this.tsParseType.bind(this))))),e.params.length===0?this.raise(q.EmptyTypeArguments,e):!this.state.inType&&this.curContext()===Od.brace&&this.reScan_lt_gt(),this.expect(44),this.finishNode(e,`TSTypeParameterInstantiation`)}tsIsDeclarationStart(){return xd(this.state.type)}isExportDefaultSpecifier(){return!this.tsIsDeclarationStart()&&super.isExportDefaultSpecifier()}parseBindingElement(e,t){let n=t.length?null:this.state.startLoc,r={};this.tsParseModifiers(xp,void 0,r);let i=r.accessibility,a=r.override,o=r.readonly;!(e&4)&&(i||o||a)&&this.raise(q.UnexpectedParameterModifier,n||t[0]);let s=this.state.startLoc,c=this.parseMaybeDefault(s);e&2&&this.parseFunctionParamType(c);let l=this.parseMaybeDefault(s,c);if(i||o||a){let e=n?this.startNodeAt(n):this.startNodeAtNode(t[0]);return t.length?e.decorators=t:this.setLoc(n),i&&(e.accessibility=i),o&&(e.readonly=o),a&&(e.override=a),l.type!==`Identifier`&&l.type!==`AssignmentPattern`&&this.raise(q.UnsupportedParameterPropertyKind,n||t[0]),e.parameter=l,this.finishNode(e,`TSParameterProperty`)}return t.length&&(c.decorators=t),l}isSimpleParameter(e){return e.type===`TSParameterProperty`&&super.isSimpleParameter(e.parameter)||super.isSimpleParameter(e)}tsDisallowOptionalPattern(e){for(let t of e.params)t.type!==`Identifier`&&t.optional&&!this.state.isAmbientContext&&this.raise(q.PatternIsOptional,t)}setArrowFunctionParameters(e,t,n){super.setArrowFunctionParameters(e,t,n),this.tsDisallowOptionalPattern(e)}parseFunctionBodyAndFinish(e,t,n=!1){this.match(10)&&(e.returnType=this.tsParseTypeOrTypePredicateAnnotation(10));let r=t===`FunctionDeclaration`?`TSDeclareFunction`:t===`ClassMethod`||t===`ClassPrivateMethod`?`TSDeclareMethod`:void 0;if(r&&!this.match(2)&&this.isLineTerminator()){if(r===`TSDeclareMethod`&&e.kind===`constructor`)for(let t of e.params)t.type===`TSParameterProperty`?this.raise(q.UnexpectedParameterModifier,t):t.type===`AssignmentPattern`&&this.raise(q.UnexpectedParameterInitializer,t);else for(let t of e.params)t.type===`AssignmentPattern`&&this.raise(q.UnexpectedParameterInitializer,t);return this.finishNode(e,r)}return r&&this.state.isAmbientContext&&(this.raise(q.DeclareFunctionHasImplementation,this.state.startLoc),r===`TSDeclareFunction`&&e.declare)?super.parseFunctionBodyAndFinish(e,r,n):(this.tsDisallowOptionalPattern(e),super.parseFunctionBodyAndFinish(e,t,n))}registerFunctionStatementId(e){!e.body&&e.id?this.checkIdentifier(e.id,1024):super.registerFunctionStatementId(e)}tsCheckForInvalidTypeCasts(e){e.forEach(e=>{e?.type===`TSTypeCastExpression`&&this.raise(q.UnexpectedTypeAnnotation,e.typeAnnotation)})}toReferencedList(e,t){return this.tsCheckForInvalidTypeCasts(e),e}parseArrayLike(e,t){let n=super.parseArrayLike(e,t);return n.type===`ArrayExpression`&&this.tsCheckForInvalidTypeCasts(n.elements),n}parseSubscript(e,t,n,r){if(!this.hasPrecedingLineBreak()&&this.match(31)){this.state.canStartJSXElement=!1,this.next();let n=this.startNodeAt(t);return n.expression=e,this.finishNode(n,`TSNonNullExpression`)}let i=!1;if(this.match(14)&&this.lookaheadCharCode()===60){if(n)return r.stop=!0,e;r.optionalChainMember=i=!0,this.next()}if(this.match(43)||this.match(47)){let a,o=this.tsTryParseAndCatch(()=>{if(!n&&this.atPossibleAsyncArrow(e)){let e=this.tsTryParseGenericAsyncArrowFunction(t);if(e)return r.stop=!0,e}let o=this.tsParseTypeArgumentsInExpression();if(!o)return;if(i&&!this.match(6)){a=this.state.curPosition();return}if(Td(this.state.type)){let n=super.parseTaggedTemplateExpression(e,t,r);return n.typeArguments=o,n}if(!n&&this.eat(6)){let n=this.startNodeAt(t);return n.callee=e,n.arguments=this.parseCallExpressionArguments(),this.tsCheckForInvalidTypeCasts(n.arguments),n.typeArguments=o,r.optionalChainMember&&(n.optional=i),this.finishCallExpression(n,r.optionalChainMember)}let s=this.state.type;if(s===44||s===48||s!==6&&s!==89&&s!==116&&fd(s)&&!this.hasPrecedingLineBreak())return;let c=this.startNodeAt(t);return c.expression=e,c.typeArguments=o,this.finishNode(c,`TSInstantiationExpression`)});if(a&&this.unexpected(a,6),o)return o.type===`TSInstantiationExpression`&&((this.match(12)||this.match(14)&&this.lookaheadCharCode()!==40)&&this.raise(q.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc),!this.match(12)&&!this.match(14)&&(o.expression=super.stopParseSubscript(e,r))),o}return super.parseSubscript(e,t,n,r)}parseNewCallee(e){super.parseNewCallee(e);let{callee:t}=e;t.type===`TSInstantiationExpression`&&!t.extra?.parenthesized&&(e.typeArguments=t.typeArguments,e.callee=t.expression)}parseExprOp(e,t,n){let r;if(Cd(54)>n&&!this.hasPrecedingLineBreak()&&(this.isContextual(89)||(r=this.isContextual(116)))){let i=this.startNodeAt(t);i.expression=e,i.typeAnnotation=this.tsInType(()=>(this.next(),this.match(71)?(r&&this.raise(G.UnexpectedKeyword,this.state.startLoc,{keyword:`const`}),this.tsParseTypeReference()):this.tsParseType()));let a=this.finishNode(i,r?`TSSatisfiesExpression`:`TSAsExpression`);return this.reScan_lt_gt(),this.parseExprOp(a,t,n)}return super.parseExprOp(e,t,n)}checkReservedWord(e,t,n,r){this.state.isAmbientContext||super.checkReservedWord(e,t,n,r)}checkDuplicateExports(){}isPotentialImportPhase(e){if(super.isPotentialImportPhase(e))return!0;if(this.isContextual(126)){let t=this.lookaheadCharCode();return e?t===123||t===42:t!==61}return!e&&this.isContextual(83)}applyImportPhase(e,t,n,r){super.applyImportPhase(e,t,n,r),t?e.exportKind=n===`type`?`type`:`value`:e.importKind=n===`type`||n===`typeof`?n:`value`}parseImport(e){if(this.match(130))return e.importKind=`value`,this.scope.inTSNamespace&&this.raise(q.ImportInTSNamespace,e),super.parseImport(e);let t;if(sd(this.state.type)&&this.lookaheadCharCode()===61){e.importKind=`value`;let t=this.tsParseImportEqualsDeclaration(e);return this.scope.inTSNamespace&&t.moduleReference.type===`TSExternalModuleReference`&&this.raise(q.ImportInTSNamespace,e),t}if(this.isContextual(126)){let n=this.parseMaybeImportPhase(e,!1);if(this.lookaheadCharCode()===61)return this.scope.inTSNamespace&&this.raise(q.ImportInTSNamespace,e),this.tsParseImportEqualsDeclaration(e,n);t=super.parseImportSpecifiersAndAfter(e,n)}else t=super.parseImport(e);return t.importKind===`type`&&t.specifiers.length>1&&t.specifiers[0].type===`ImportDefaultSpecifier`?this.raise(q.TypeImportCannotSpecifyDefaultAndNamed,t):this.scope.inTSNamespace&&this.raise(q.ImportInTSNamespace,t),t}parseExport(e,t){if(this.match(79)){let t=this.startNode();this.next();let n=null;this.isContextual(126)&&this.isPotentialImportPhase(!1)?n=this.parseMaybeImportPhase(t,!1):t.importKind=`value`;let r=this.tsParseImportEqualsDeclaration(t,n);return e.attributes=[],e.declaration=r,e.exportKind=`value`,e.source=null,e.specifiers=[],this.finishNode(e,`ExportNamedDeclaration`)}if(this.eat(25)){let t=e;return t.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.scope.inTSNamespace&&this.raise(q.ExportAssignmentInTSNamespace,t),this.finishNode(t,`TSExportAssignment`)}if(this.eatContextual(89)){let t=e;return this.expectContextual(124),t.id=this.parseIdentifier(),this.checkIdentifier(t.id,8201),this.semicolon(),this.scope.inTSNamespace&&this.raise(q.NamespaceExportInTSNamespace,t),this.finishNode(t,`TSNamespaceExportDeclaration`)}{let n=super.parseExport(e,t);return this.scope.inTSNamespace&&(n.type!==`ExportNamedDeclaration`||n.source||!n.declaration&&!this.state.isAmbientContext)&&this.raise(q.ExportInTSNamespace,n),n}}isAbstractClass(){return this.isContextual(120)&&this.isLookaheadContextual(`class`)}parseExportDefaultExpression(){if(this.isAbstractClass()){let e=this.startNode();return this.next(),e.abstract=!0,this.parseClass(e,!0,!0)}if(this.match(125)){let e=this.tsParseInterfaceDeclaration(this.startNode());if(e)return e}return super.parseExportDefaultExpression()}parseVarStatement(e,t,n=!1){let{isAmbientContext:r}=this.state,i=super.parseVarStatement(e,t,n||r);if(r&&!e.declare&&(t===`using`||t===`await using`))return this.raiseOverwrite(q.UsingDeclarationInAmbientContext,e,t),i;for(let e of i.declarations){let{id:n,init:i,definite:a}=e;a&&(i?this.raise(q.DeclaratorDefiniteAssertionWithInitializer,n):n.typeAnnotation||this.raise(q.DeclaratorDefiniteAssertionRequiresTypeAnnotation,n)),r&&i&&(t===`var`||t===`let`||n.typeAnnotation?this.raise(q.InitializerNotAllowedInAmbientContext,i):Tp(i,this.hasPlugin(`estree`))||this.raise(q.ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference,i))}return i}parseStatementContent(e,t){let n=!!(e&2);if(!this.state.containsEsc)switch(this.state.type){case 71:if(this.isLookaheadContextual(`enum`)){let e=this.startNode();return this.next(),this.tsParseEnumDeclaration(e,{const:!0})}break;case 120:case 121:if(this.nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine()){let e=this.state.type,n=this.startNode();this.next();let r=e===121?this.tsTryParseDeclare(n):this.tsParseAbstractDeclaration(n,t);return r?(e===121&&(r.declare=!0),r):(n.expression=this.createIdentifier(this.startNodeAtNode(n),e===121?`declare`:`abstract`),this.semicolon(!1),this.finishNode(n,`ExpressionStatement`))}break;case 122:return this.tsParseEnumDeclaration(this.startNode());case 108:if(this.lookaheadCharCode()===123){let e=this.startNode();return this.tsParseAmbientExternalModuleDeclaration(e)}break;case 125:{let e=this.tsParseInterfaceDeclaration(this.startNode());if(e)return n||this.raise(q.UnexpectedTypeDeclaration,e,`interface`),e;break}case 123:if(this.nextTokenIsStringLiteralOnSameLine()){let e=this.startNode();return this.next(),this.tsParseDeclaration(e,123,!1,t)}if(this.nextTokenIsIdentifierOnSameLine()){this.raise(q.InlineModuleDeclarationMustUseString,this.state.startLoc);let e=this.startNode();return this.next(),this.tsParseDeclaration(e,124,!1,t)}break;case 124:if(this.nextTokenIsIdentifierOnSameLine()){let e=this.startNode();return this.next(),this.tsParseDeclaration(e,124,!1,t)}break;case 126:if(this.nextTokenIsIdentifierOnSameLine()){let e=this.startNode();return n||this.raise(q.UnexpectedTypeDeclaration,e,`type`),this.next(),this.tsParseTypeAliasDeclaration(e)}}return super.parseStatementContent(e,t)}parseAccessModifier(){return this.tsParseModifier(Sp)}tsHasSomeModifiers(e,t){return t.some(t=>gp(t)?e.accessibility===t:!!e[t])}tsIsStartOfStaticBlocks(){return this.isContextual(102)&&this.lookaheadCharCode()===123}parseClassMember(e,t,n){this.tsParseModifiers(yp,q.InvalidModifierOnTypeParameterPositions,t,!0);let r=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(t,[`declare`,`private`,`public`,`protected`,`override`,`abstract`,`readonly`,`static`])&&this.raise(q.StaticBlockCannotHaveModifier,this.state.curPosition()),super.parseClassStaticBlock(e,t)):this.parseClassMemberWithIsStatic(e,t,n,!!t.static)};t.declare?this.tsInAmbientContext(r):r(),t.decorators&&t.decorators.length>0&&!this.hasPlugin(`decorators-legacy`)&&(t.type===`TSAbstractMethodDefinition`||t.type===`TSDeclareMethod`?this.raise(q.DecoratorAbstractMethod,t,{kind:`abstract method`}):(t.type===`ClassProperty`&&t.abstract||t.type===`ClassProperty`&&t.declare||t.type===`TSAbstractPropertyDefinition`||t.type===`PropertyDefinition`&&t.declare)&&this.raise(q.DecoratorAbstractMethod,t,{kind:t.declare?`declare field`:`abstract field`}))}parseClassMemberWithIsStatic(e,t,n,r){let i=this.tsTryParseIndexSignature(t);if(i){e.body.push(i),t.abstract&&this.raise(q.IndexSignatureHasAbstract,t),t.accessibility&&this.raise(q.IndexSignatureHasAccessibility,t,{modifier:t.accessibility}),t.declare&&this.raise(q.IndexSignatureHasDeclare,t),t.override&&this.raise(q.IndexSignatureHasOverride,t);return}!this.state.inAbstractClass&&t.abstract&&this.raise(q.NonAbstractClassHasAbstractMethod,t),t.override&&(n.hadSuperClass||this.raise(q.OverrideNotInSubClass,t)),super.parseClassMemberWithIsStatic(e,t,n,r)}parsePostMemberNameModifiers(e){this.eat(13)&&(e.optional=!0),e.readonly&&this.match(6)&&this.raise(q.ClassMethodHasReadonly,e),e.declare&&this.match(6)&&this.raise(q.ClassMethodHasDeclare,e)}shouldParseExportDeclaration(){return this.tsIsDeclarationStart()?!0:super.shouldParseExportDeclaration()}parseConditional(e,t,n){if(!this.match(13))return e;if(n!=null){let t=this.lookaheadCharCode();if(t===44||t===61||t===58||t===41)return this.setOptionalParametersError(n),e}this.next();let r=this.startNodeAt(t);r.test=e;let i=this.state.inConditionalConsequent;return this.state.inConditionalConsequent=!0,r.consequent=this.parseMaybeAssignAllowIn(),this.state.inConditionalConsequent=i,this.expect(10),r.alternate=this.parseMaybeAssign(),this.finishNode(r,`ConditionalExpression`)}parseParenItem(e,t){let n=super.parseParenItem(e,t);if(this.eat(13)&&(n.optional=!0,this.resetEndLocation(e)),this.match(10)){let n=this.startNodeAt(t);return n.expression=e,n.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(n,`TSTypeCastExpression`)}return e}parseExportDeclaration(e){if(!this.state.isAmbientContext&&this.isContextual(121))return this.tsInAmbientContext(()=>this.parseExportDeclaration(e));let t=this.state.startLoc,n=this.eatContextual(121);if(n&&(this.isContextual(121)||!this.shouldParseExportDeclaration()))throw this.raise(q.ExpectedAmbientAfterExportDeclare,this.state.startLoc);let r=sd(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration(e);return r?((r.type===`TSInterfaceDeclaration`||r.type===`TSTypeAliasDeclaration`||n)&&(e.exportKind=`type`),n&&r.type!==`TSImportEqualsDeclaration`&&(this.resetStartLocation(r,t),r.declare=!0),r):null}parseClassId(e,t,n,r){if((!t||n)&&this.isContextual(109)){e.id=null;return}super.parseClassId(e,t,n,e.declare?1024:8331);let i=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);i&&(e.typeParameters=i)}parseClassPropertyAnnotation(e){e.optional||(this.eat(31)?e.definite=!0:this.eat(13)&&(e.optional=!0));let t=this.tsTryParseTypeAnnotation();t&&(e.typeAnnotation=t),e.definite&&(this.match(25)?this.raise(q.DeclaratorDefiniteAssertionWithInitializer,e):t||this.raise(q.DeclaratorDefiniteAssertionRequiresTypeAnnotation,e))}parseClassProperty(e){if(this.parseClassPropertyAnnotation(e),this.state.isAmbientContext&&(!e.readonly||e.typeAnnotation)&&this.match(25)&&this.raise(q.DeclareClassFieldHasInitializer,this.state.startLoc),e.abstract&&this.match(25)){let{key:t}=e;this.raise(q.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:t.type===`Identifier`&&!e.computed?t.name:`[${this.input.slice(this.offsetToSourcePos(t.start),this.offsetToSourcePos(t.end))}]`})}return super.parseClassProperty(e)}parseClassPrivateProperty(e){return e.abstract&&this.raise(q.PrivateElementHasAbstract,e),e.accessibility&&this.raise(q.PrivateElementHasAccessibility,e,{modifier:e.accessibility}),this.parseClassPropertyAnnotation(e),super.parseClassPrivateProperty(e)}parseClassAccessorProperty(e){return this.parseClassPropertyAnnotation(e),e.optional&&this.raise(q.AccessorCannotBeOptional,e),super.parseClassAccessorProperty(e)}pushClassMethod(e,t,n,r,i,a){let o=this.tsTryParseTypeParameters(this.tsParseConstModifier);o&&i&&this.raise(q.ConstructorHasTypeParameters,o);let{declare:s=!1,kind:c}=t;s&&(c===`get`||c===`set`)&&this.raise(q.DeclareAccessor,t,{kind:c}),o&&(t.typeParameters=o),super.pushClassMethod(e,t,n,r,i,a)}pushClassPrivateMethod(e,t,n,r){let i=this.tsTryParseTypeParameters(this.tsParseConstModifier);i&&(t.typeParameters=i),super.pushClassPrivateMethod(e,t,n,r)}declareClassPrivateMethodInScope(e,t){e.type!==`TSDeclareMethod`&&(e.type!==`MethodDefinition`||e.value.body!=null)&&super.declareClassPrivateMethodInScope(e,t)}parseClassSuper(e){if(super.parseClassSuper(e),e.superClass){if(e.superClass.type===`TSInstantiationExpression`){let t=e.superClass,n=t.expression;this.takeSurroundingComments(n,n.start,n.end);let r=t.typeArguments;this.takeSurroundingComments(r,r.start,r.end),e.superClass=n,e.superTypeArguments=r}else(this.match(43)||this.match(47))&&(e.superTypeArguments=this.tsParseTypeArgumentsInExpression())}this.eatContextual(109)&&(e.implements=this.tsParseHeritageClause(`implements`))}parseObjPropValue(e,t,n,r,i,a,o){let s=this.tsTryParseTypeParameters(this.tsParseConstModifier);return s&&(e.typeParameters=s),super.parseObjPropValue(e,t,n,r,i,a,o)}parseFunctionParams(e,t){let n=this.tsTryParseTypeParameters(this.tsParseConstModifier);n&&(e.typeParameters=n),super.parseFunctionParams(e,t)}parseVarId(e,t){super.parseVarId(e,t),e.id.type===`Identifier`&&!this.hasPrecedingLineBreak()&&this.eat(31)&&(e.definite=!0);let n=this.tsTryParseTypeAnnotation();n&&(e.id.typeAnnotation=n,this.resetEndLocation(e.id))}parseAsyncArrowFromCallExpression(e,t){return this.match(10)&&(e.returnType=this.tsParseTypeAnnotation()),super.parseAsyncArrowFromCallExpression(e,t)}parseMaybeAssign(e,t){let n,r,i;if(this.hasPlugin(`jsx`)&&(this.match(138)||this.match(43))){if(n=this.state.clone(),r=this.tryParse(()=>super.parseMaybeAssign(e,t),n),!r.error)return r.node;let{context:i}=this.state,a=i[i.length-1];(a===Od.j_oTag||a===Od.j_expr)&&i.pop()}if(!r?.error&&!this.match(43))return super.parseMaybeAssign(e,t);(!n||n===this.state)&&(n=this.state.clone());let a,o=this.tryParse(n=>{a=this.tsParseTypeParameters(this.tsParseConstModifier);let r=super.parseMaybeAssign(e,t);if((r.type!==`ArrowFunctionExpression`||r.extra?.parenthesized)&&n(),a?.params.length!==0&&this.resetStartLocationFromNode(r,a),r.typeParameters=a,this.hasPlugin(`jsx`)&&r.typeParameters.params.length===1&&!r.typeParameters.extra?.trailingComma){let e=r.typeParameters.params[0];e.constraint||this.raise(q.SingleTypeParameterWithoutTrailingComma,this.optionFlags&256?wu(e.loc.end,1):e,{typeParameterName:e.name.name})}return r},n);if(!o.error&&!o.aborted)return a&&this.reportReservedArrowTypeParam(a),o.node;if(!r&&(mp(!this.hasPlugin(`jsx`)),i=this.tryParse(()=>super.parseMaybeAssign(e,t),n),!i.error))return i.node;if(r?.node)return this.state=r.failState,r.node;if(o.node)return this.state=o.failState,a&&this.reportReservedArrowTypeParam(a),o.node;if(i?.node)return this.state=i.failState,i.node;throw r?.error||o.error||i?.error}reportReservedArrowTypeParam(e){e.params.length===1&&!e.params[0].constraint&&!e.extra?.trailingComma&&this.getPluginOption(`typescript`,`disallowAmbiguousJSXLike`)&&this.raise(q.ReservedArrowTypeParam,e)}parseMaybeUnary(e,t){return!this.hasPlugin(`jsx`)&&this.match(43)?this.tsParseTypeAssertion():super.parseMaybeUnary(e,t)}parseArrow(e){if(this.match(10)){let t=this.tryParse(e=>{let t=this.tsParseTypeOrTypePredicateAnnotation(10);return(this.canInsertSemicolon()||!this.match(15))&&e(),t});if(t.aborted)return;t.thrown||(t.error&&(this.state=t.failState),e.returnType=t.node)}return super.parseArrow(e)}parseFunctionParamType(e){this.eat(13)&&(e.optional=!0);let t=this.tsTryParseTypeAnnotation();return t&&(e.typeAnnotation=t),this.resetEndLocation(e),e}isAssignable(e,t){switch(e.type){case`TSTypeCastExpression`:return this.isAssignable(e.expression,t);case`TSParameterProperty`:return!0;default:return super.isAssignable(e,t)}}toAssignable(e,t=!1){switch(e.type){case`ParenthesizedExpression`:this.toAssignableParenthesizedExpression(e,t);break;case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSNonNullExpression`:case`TSTypeAssertion`:t?this.expressionScope.recordArrowParameterBindingError(q.UnexpectedTypeCastInParameter,e):this.raise(q.UnexpectedTypeCastInParameter,e),this.toAssignable(e.expression,t);break;case`AssignmentExpression`:!t&&e.left.type===`TSTypeCastExpression`&&(e.left=this.typeCastToParameter(e.left));default:super.toAssignable(e,t)}}toAssignableParenthesizedExpression(e,t){switch(e.expression.type){case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSNonNullExpression`:case`TSTypeAssertion`:case`ParenthesizedExpression`:this.toAssignable(e.expression,t);break;default:super.toAssignable(e,t)}}checkToRestConversion(e,t){switch(e.type){case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSTypeAssertion`:case`TSNonNullExpression`:this.checkToRestConversion(e.expression,!1);break;default:super.checkToRestConversion(e,t)}}isValidLVal(e,t,n,r){switch(e){case`TSTypeCastExpression`:return!0;case`TSParameterProperty`:return`parameter`;case`TSNonNullExpression`:return`expression`;case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSTypeAssertion`:return(r!==64||!n)&&[`expression`,!0];default:return super.isValidLVal(e,t,n,r)}}parseBindingAtom(){return this.state.type===74?this.parseIdentifier(!0):super.parseBindingAtom()}parseMaybeDecoratorArguments(e,t){if(this.match(43)||this.match(47)){let n=this.tsParseTypeArgumentsInExpression();if(this.match(6)){let r=super.parseMaybeDecoratorArguments(e,t);return r.typeArguments=n,r}this.unexpected(null,6)}return super.parseMaybeDecoratorArguments(e,t)}checkCommaAfterRest(e){return this.state.isAmbientContext&&this.match(8)&&this.lookaheadCharCode()===e?(this.next(),!1):super.checkCommaAfterRest(e)}isClassMethod(){return this.match(43)||super.isClassMethod()}isClassProperty(){return this.match(31)||this.match(10)||super.isClassProperty()}parseMaybeDefault(e,t){let n=super.parseMaybeDefault(e,t);return n.type===`AssignmentPattern`&&n.typeAnnotation&&n.right.start<n.typeAnnotation.start&&this.raise(q.TypeAnnotationAfterAssign,n.typeAnnotation),n}getTokenFromCode(e){if(this.state.inType){if(e===62){this.finishOp(44,1);return}if(e===60){this.finishOp(43,1);return}}super.getTokenFromCode(e)}reScan_lt_gt(){let{type:e}=this.state;e===43?(--this.state.pos,this.readToken_lt()):e===44&&(--this.state.pos,this.readToken_gt())}reScan_lt(){let{type:e}=this.state;return e===47?(this.state.pos-=2,this.finishOp(43,1),43):e}toAssignableListItem(e,t,n){let r=e[t];r.type===`TSTypeCastExpression`&&(e[t]=this.typeCastToParameter(r)),super.toAssignableListItem(e,t,n)}typeCastToParameter(e){return e.expression.typeAnnotation=e.typeAnnotation,this.resetEndLocationFromNode(e.expression,e.typeAnnotation),e.expression}shouldParseArrow(e){return this.match(10)?e.every(e=>this.isAssignable(e,!0)):super.shouldParseArrow(e)}shouldParseAsyncArrow(){return this.match(10)?!this.state.inConditionalConsequent:super.shouldParseAsyncArrow()}parseParenAndDistinguishExpression(e){let t=this.state.inConditionalConsequent;this.state.inConditionalConsequent=!1;let n=super.parseParenAndDistinguishExpression(e);return this.state.inConditionalConsequent=t,n}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName(e){if(this.match(43)||this.match(47)){let t=this.tsTryParseAndCatch(()=>this.tsParseTypeArgumentsInExpression());t&&(e.typeArguments=t)}return super.jsxParseOpeningElementAfterName(e)}getGetterSetterExpectedParamCount(e){let t=super.getGetterSetterExpectedParamCount(e),n=this.getObjectOrClassMethodParams(e)[0];return n&&this.isThisParam(n)?t+1:t}parseCatchClauseParam(){let e=super.parseCatchClauseParam(),t=this.tsTryParseTypeAnnotation();return t&&(e.typeAnnotation=t,this.resetEndLocation(e)),e}tsInAmbientContext(e){let{isAmbientContext:t,strict:n}=this.state;this.state.isAmbientContext=!0,this.state.strict=!1;try{return e()}finally{this.state.isAmbientContext=t,this.state.strict=n}}parseClass(e,t,n){let r=this.state.inAbstractClass;this.state.inAbstractClass=!!e.abstract;try{return super.parseClass(e,t,n)}finally{this.state.inAbstractClass=r}}tsParseAbstractDeclaration(e,t){if(this.match(76))return e.abstract=!0,this.maybeTakeDecorators(t,this.parseClass(e,!0,!1));if(this.isContextual(125))return this.hasFollowingLineBreak()?null:(e.abstract=!0,this.raise(q.NonClassMethodPropertyHasAbstractModifier,e),this.tsParseInterfaceDeclaration(e));throw this.unexpected(null,76)}parseMethod(e,t,n,r,i,a,o){let s=super.parseMethod(e,t,n,r,i,a,o);if((s.abstract||s.type===`TSAbstractMethodDefinition`)&&(this.hasPlugin(`estree`)?s.value:s).body){let{key:e}=s;this.raise(q.AbstractMethodHasImplementation,s,{methodName:e.type===`Identifier`&&!s.computed?e.name:`[${this.input.slice(this.offsetToSourcePos(e.start),this.offsetToSourcePos(e.end))}]`})}return s}tsParseTypeParameterName(){return this.parseIdentifier()}shouldParseAsAmbientContext(){return!!this.getPluginOption(`typescript`,`dts`)}parse(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.parse()}getExpression(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.getExpression()}parseExportSpecifier(e,t,n,r){return!t&&r?(this.parseTypeOnlyExportSpecifier(e,n),this.finishNode(e,`ExportSpecifier`)):(e.exportKind=`value`,super.parseExportSpecifier(e,t,n,r))}parseImportSpecifier(e,t,n,r,i){return!t&&r?(this.parseTypeOnlyImportSpecifier(e,n),this.finishNode(e,`ImportSpecifier`)):(e.importKind=`value`,super.parseImportSpecifier(e,t,n,r,n?4098:4096))}parseTypeOnlyImportSpecifier(e,t){let n=e.imported,r=!1;if(this.isContextual(89)){let t=this.parseIdentifier();if(this.isContextual(89)){let i=this.parseIdentifier();ld(this.state.type)?(r=!0,n=t,e.local=this.parseIdentifier()):e.local=i}else ld(this.state.type)?e.local=this.parseIdentifier():(r=!0,n=t)}else ld(this.state.type)&&(r=!0,n=this.parseIdentifier(!0),this.isContextual(89)||this.checkReservedWord(n.name,n.start,!0,!0));r&&t&&this.raise(q.TypeModifierIsUsedInTypeImports,e.imported),e.imported=n,e.importKind=r?`type`:`value`,this.checkIdentifier(e.local??=this.eatContextual(89)?this.parseIdentifier():this.cloneIdentifier(e.imported),r?4098:4096)}parseTypeOnlyExportSpecifier(e,t){let n=e.local,r=!1;if(this.isContextual(89)){let t=this.parseIdentifier();if(this.isContextual(89)){let n=this.parseIdentifier();ld(this.state.type)?(r=!0,e.local=t,e.exported=this.parseModuleExportName()):e.exported=n}else ld(this.state.type)?e.exported=this.parseModuleExportName():(r=!0,e.local=t)}else ld(this.state.type)&&(r=!0,e.local=this.parseModuleExportName());r&&t&&this.raise(q.TypeModifierIsUsedInTypeExports,n),e.exportKind=r?`type`:`value`,e.exported??=this.eatContextual(89)?this.parseModuleExportName():this.cloneIdentifier(e.local)}fillOptionalPropertiesForTSESLint(e){switch(e.type){case`ImportDeclaration`:e.phase??=null;return;case`ExpressionStatement`:e.directive??=void 0;return;case`RestElement`:e.value=void 0;case`Identifier`:case`ArrayPattern`:case`AssignmentPattern`:case`ObjectPattern`:e.decorators??=[],e.optional??=!1,e.typeAnnotation??=void 0;return;case`TSParameterProperty`:e.accessibility??=void 0,e.decorators??=[],e.override??=!1,e.readonly??=!1,e.static??=!1;return;case`TSEmptyBodyFunctionExpression`:e.body=null;case`TSDeclareFunction`:case`FunctionDeclaration`:case`FunctionExpression`:case`ClassMethod`:case`ClassPrivateMethod`:e.declare??=!1,e.returnType??=void 0,e.typeParameters??=void 0;return;case`Property`:e.optional??=!1;return;case`TSMethodSignature`:case`TSPropertySignature`:e.optional??=!1;case`TSIndexSignature`:e.accessibility??=void 0,e.readonly??=!1,e.static??=!1;return;case`TSAbstractPropertyDefinition`:case`PropertyDefinition`:case`TSAbstractAccessorProperty`:case`AccessorProperty`:e.declare??=!1,e.definite??=!1,e.readonly??=!1,e.typeAnnotation??=void 0;case`TSAbstractMethodDefinition`:case`MethodDefinition`:e.accessibility??=void 0,e.decorators??=[],e.override??=!1,e.optional??=!1;return;case`ClassExpression`:e.id??=null;case`ClassDeclaration`:e.abstract??=!1,e.declare??=!1,e.decorators??=[],e.implements??=[],e.superTypeArguments??=void 0,e.typeParameters??=void 0;return;case`TSTypeAliasDeclaration`:case`VariableDeclaration`:e.declare??=!1;return;case`VariableDeclarator`:e.definite??=!1;return;case`TSEnumDeclaration`:e.const??=!1,e.declare??=!1;return;case`TSEnumMember`:e.computed??=!1;return;case`TSImportType`:e.qualifier??=null,e.options??=null,e.typeArguments??=null;return;case`TSInterfaceDeclaration`:e.declare??=!1,e.extends??=[];return;case`TSMappedType`:e.optional??=!1,e.readonly??=void 0;return;case`TSModuleDeclaration`:e.declare??=!1,e.global??=e.kind===`global`;return;case`TSTypeParameter`:e.const??=!1,e.in??=!1,e.out??=!1;return}}chStartsBindingIdentifierAndNotRelationalOperator(e,t){if(Pd(e)){if(fp.lastIndex=t,fp.test(this.input)){let e=this.codePointAtPos(fp.lastIndex);if(!Fd(e)&&e!==92)return!1}return!0}return e===92}nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine(){let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);return this.chStartsBindingIdentifierAndNotRelationalOperator(t,e)}nextTokenIsStringLiteralOnSameLine(){let e=this.nextTokenInLineStart(),t=this.codePointAtPos(e);return t===34||t===39}};function wp(e){if(e.type!==`MemberExpression`)return!1;let{computed:t,property:n}=e;return t&&n.type!==`StringLiteral`&&(n.type!==`TemplateLiteral`||n.expressions.length>0)?!1:Op(e.object)}function Tp(e,t){let{type:n}=e;if(e.extra?.parenthesized)return!1;if(t){if(n===`Literal`){let{value:t}=e;if(typeof t==`string`||typeof t==`boolean`)return!0}}else if(n===`StringLiteral`||n===`BooleanLiteral`)return!0;return!!(Ep(e,t)||Dp(e,t)||n===`TemplateLiteral`&&e.expressions.length===0||wp(e))}function Ep(e,t){return t?e.type===`Literal`&&(typeof e.value==`number`||`bigint`in e):e.type===`NumericLiteral`||e.type===`BigIntLiteral`}function Dp(e,t){if(e.type===`UnaryExpression`){let{operator:n,argument:r}=e;if(n===`-`&&Ep(r,t))return!0}return!1}function Op(e){return e.type===`Identifier`?!0:e.type!==`MemberExpression`||e.computed?!1:Op(e.object)}function kp(e,t=[]){let n=new Map;for(let t of e)n.set(t,!0);for(let e of t)n.set(e,!1);return n}var Ap=Lu`placeholders`({ClassNameIsRequired:`A class name is required.`,UnexpectedSpace:`Unexpected space in placeholder.`}),jp=e=>class extends e{parsePlaceholder(e){if(this.match(129)){let t=this.startNode();return this.next(),this.assertNoSpace(),t.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(129),this.finishPlaceholder(t,e)}}finishPlaceholder(e,t){let n=e;return(!n.expectedNode||!n.type)&&(n=this.finishNode(n,`Placeholder`)),n.expectedNode=t,n}getTokenFromCode(e){e===37&&this.input.charCodeAt(this.state.pos+1)===37?this.finishOp(129,2):super.getTokenFromCode(e)}parseExprAtom(e){return this.parsePlaceholder(`Expression`)||super.parseExprAtom(e)}parseIdentifier(e){return this.parsePlaceholder(`Identifier`)||super.parseIdentifier(e)}checkReservedWord(e,t,n,r){e!==void 0&&super.checkReservedWord(e,t,n,r)}cloneIdentifier(e){let t=super.cloneIdentifier(e);return t.type===`Placeholder`&&(t.expectedNode=e.expectedNode),t}cloneStringLiteral(e){return e.type===`Placeholder`?this.cloneIdentifier(e):super.cloneStringLiteral(e)}parseBindingAtom(){return this.parsePlaceholder(`Pattern`)||super.parseBindingAtom()}isValidLVal(e,t,n,r){return e===`Placeholder`||super.isValidLVal(e,t,n,r)}toAssignable(e,t){e&&e.type===`Placeholder`&&e.expectedNode===`Expression`?e.expectedNode=`Pattern`:super.toAssignable(e,t)}chStartsBindingIdentifier(e,t){if(super.chStartsBindingIdentifier(e,t))return!0;let n=this.nextTokenStart();return this.input.charCodeAt(n)===37&&this.input.charCodeAt(n+1)===37}verifyBreakContinue(e,t){e.label?.type!==`Placeholder`&&super.verifyBreakContinue(e,t)}parseExpressionStatement(e,t){if(t.type!==`Placeholder`||t.extra?.parenthesized)return super.parseExpressionStatement(e,t);if(this.match(10)){let n=e;return n.label=this.finishPlaceholder(t,`Identifier`),this.next(),n.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(n,`LabeledStatement`)}this.semicolon();let n=e;return n.name=t.name,this.finishPlaceholder(n,`Statement`)}parseBlock(e,t,n){return this.parsePlaceholder(`BlockStatement`)||super.parseBlock(e,t,n)}parseFunctionId(e){return this.parsePlaceholder(`Identifier`)||super.parseFunctionId(e)}parseClass(e,t,n){let r=t?`ClassDeclaration`:`ClassExpression`;this.next();let i=this.state.strict,a=this.parsePlaceholder(`Identifier`);if(a){if(this.match(77)||this.match(129)||this.match(2))e.id=a;else if(n||!t)return e.id=null,e.body=this.finishPlaceholder(a,`ClassBody`),this.finishNode(e,r);else throw this.raise(Ap.ClassNameIsRequired,this.state.startLoc)}else this.parseClassId(e,t,n);return super.parseClassSuper(e),e.body=this.parsePlaceholder(`ClassBody`)||super.parseClassBody(!!e.superClass,i),this.finishNode(e,r)}parseExport(e,t){let n=this.parsePlaceholder(`Identifier`);if(!n)return super.parseExport(e,t);let r=e;if(!this.isContextual(94)&&!this.match(8))return r.specifiers=[],r.source=null,r.declaration=this.finishPlaceholder(n,`Declaration`),this.finishNode(r,`ExportNamedDeclaration`);this.expectPlugin(`exportDefaultFrom`);let i=this.startNode();return i.exported=n,r.specifiers=[this.finishNode(i,`ExportDefaultSpecifier`)],super.parseExport(r,t)}isExportDefaultSpecifier(){if(this.match(61)){let e=this.nextTokenStart();if(this.isUnparsedContextual(e,`from`)&&this.input.startsWith(Sd(129),this.nextTokenStartSince(e+4)))return!0}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier(e,t){return e.specifiers?.length?!0:super.maybeParseExportDefaultSpecifier(e,t)}checkNamedExport(){}parseImport(e){let t=this.parsePlaceholder(`Identifier`);if(!t)return super.parseImport(e);if(e.specifiers=[],!this.isContextual(94)&&!this.match(8))return e.source=this.finishPlaceholder(t,`StringLiteral`),this.semicolon(),this.finishNode(e,`ImportDeclaration`);let n=this.startNodeAtNode(t);return n.local=t,e.specifiers.push(this.finishNode(n,`ImportDefaultSpecifier`)),this.eat(8)&&(this.maybeParseStarImportSpecifier(e)||this.parseNamedImportSpecifiers(e)),this.expectContextual(94),e.source=this.parseImportSource(),this.semicolon(),this.finishNode(e,`ImportDeclaration`)}parseImportSource(){return this.parsePlaceholder(`StringLiteral`)||super.parseImportSource()}assertNoSpace(){this.state.start>this.offsetToSourcePos(this.state.lastTokEndLoc.index)&&this.raise(Ap.UnexpectedSpace,this.state.lastTokEndLoc)}},Mp=e=>class extends e{parseV8Intrinsic(){if(this.match(50)){let e=this.state.startLoc,t=this.startNode();if(this.next(),sd(this.state.type)){let e=this.parseIdentifierName(),n=this.createIdentifier(t,e);if(this.castNodeTo(n,`V8IntrinsicIdentifier`),this.match(6))return n}this.unexpected(e)}}parseExprAtom(e){return this.parseV8Intrinsic()||super.parseExprAtom(e)}},Np=[`fsharp`,`hack`],Pp=[`^^`,`@@`,`^`,`%`,`#`];function Fp(e){if(e.has(`decorators`)&&e.has(`decorators-legacy`))throw Error(`Cannot use the decorators and decorators-legacy plugin together`);if(e.has(`flow`)&&e.has(`typescript`))throw Error(`Cannot combine flow and typescript plugins.`);if(e.has(`placeholders`)&&e.has(`v8intrinsic`))throw Error(`Cannot combine placeholders and v8intrinsic plugins.`);if(e.has(`pipelineOperator`)){let t=e.get(`pipelineOperator`).proposal;if(!Np.includes(t)){let e=Np.map(e=>`"${e}"`).join(`, `);throw Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${e}.`)}if(t===`hack`){if(e.has(`placeholders`))throw Error(`Cannot combine placeholders plugin and Hack-style pipes.`);if(e.has(`v8intrinsic`))throw Error(`Cannot combine v8intrinsic plugin and Hack-style pipes.`);let t=e.get(`pipelineOperator`).topicToken;if(!Pp.includes(t)){let e=Pp.map(e=>`"${e}"`).join(`, `);throw Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${e}.`)}}}if(e.has(`moduleAttributes`))throw Error("`moduleAttributes` has been removed in Babel 8, please migrate to import attributes instead.");if(e.has(`importAssertions`))throw Error("`importAssertions` has been removed in Babel 8, please use import attributes instead.");if(e.has(`deprecatedImportAssert`)?console.warn("`deprecatedImportAssert` has been removed in Babel 8, please use import attributes instead."):e.has(`importAttributes`)&&e.get(`importAttributes`).deprecatedAssertSyntax&&console.warn("The 'importAttributes' plugin has been removed in Babel 8. Please migrate any usage of `assert`-style attributes to `with`."),e.has(`recordAndTuple`))throw Error(`The 'recordAndTuple' plugin has been removed in Babel 8. Please remove it from your configuration.`);if(e.has(`asyncDoExpressions`)&&!e.has(`doExpressions`)){let e=Error(`'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.`);throw e.missingPlugins=`doExpressions`,e}if(e.has(`optionalChainingAssign`)&&e.get(`optionalChainingAssign`).version!==`2023-07`)throw Error(`The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.`);if(e.has(`discardBinding`)&&e.get(`discardBinding`).syntaxType!==`void`)throw Error(`The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.`);if(e.has(`decimal`))throw Error(`The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.`);if(e.has(`importReflection`))throw Error(`The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.`)}var Ip={estree:Vu,jsx:_f,flow:of,typescript:Cp,v8intrinsic:Mp,placeholders:jp},Lp=Object.keys(Ip),Rp=class extends dp{constructor(e,t,n){let r=zu(e);super(r,t),this.options=r,this.initializeScopes(),this.plugins=n,this.filename=r.sourceFilename,this.startIndex=r.startIndex;let i=0;r.allowAwaitOutsideFunction&&(i|=1),r.allowReturnOutsideFunction&&(i|=2),r.allowImportExportEverywhere&&(i|=8),r.allowSuperOutsideMethod&&(i|=16),r.allowUndeclaredExports&&(i|=64),r.allowNewTargetOutsideFunction&&(i|=4),r.allowYieldOutsideFunction&&(i|=32),r.ranges&&(i|=128),r.locations===!0&&(i|=256),r.tokens&&(i|=512),r.createImportExpressions&&(i|=1024),r.createParenthesizedExpressions&&(i|=2048),r.errorRecovery&&(i|=4096),r.attachComment&&(i|=8192),r.annexB&&(i|=16384),this.optionFlags=i}getScopeHandler(){return Yd}parse(){this.enterInitialScopes();let e=this.startNode(),t=this.startNode();this.nextToken(),e.errors=[];let n=this.parseTopLevel(e,t);return n.errors=this.state.errors,n.comments.length=this.state.commentsLen,n}};function zp(e,t){if(t?.sourceType===`unambiguous`){t={...t};try{t.sourceType=`module`;let n=Vp(t,e),r=n.parse();if(n.sawUnambiguousESM)return r;if(n.ambiguousScriptDifferentAst)try{return t.sourceType=`script`,Vp(t,e).parse()}catch{}else r.program.sourceType=`script`;return r}catch(n){try{return t.sourceType=`script`,Vp(t,e).parse()}catch{}throw n}}return Vp(t,e).parse()}function Bp(e){let t={};for(let n of Object.keys(e))t[n]=Ed(e[n]);return t}Bp(od);function Vp(e,t){let n=Rp,r=new Map;if(e?.plugins){for(let t of e.plugins){let e,n;typeof t==`string`?e=t:[e,n]=t,r.has(e)||r.set(e,n||{})}Fp(r),n=Up(r)}return new n(e,t,r)}var Hp=new Map;function Up(e){let t=[];for(let n of Lp)e.has(n)&&t.push(n);let n=t.join(`|`),r=Hp.get(n);if(!r){r=Rp;for(let e of t)r=Ip[e](r);Hp.set(n,r)}return r}var Wp=e=>e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``,Gp=(e,t)=>{let n=t.startsWith(`/`)||e===``?[]:e.split(`/`);for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(n.length===0)return;n.pop()}else n.push(e)}return n.length===0?void 0:n.join(`/`)},Kp=class{items=[];locate(e,t){let n=e.position(t.start);return{fileName:e.path,lineNumber:n.line,columnNumber:n.column}}add(e,t,n,r,i,a=`error`){this.report({code:n,severity:a,message:r,...i===void 0?{}:{fix:i},origins:[this.locate(e,t)]})}report(e){let t=Ss[e.code];this.items.push({...e,...t.upgrade===void 0?{}:{upgrade:t.upgrade}})}get blocking(){return this.items.some(e=>e.severity===`error`)}},qp=e=>{let t=0,n=e.flatMap(e=>{let n=t;return t+=e.rules.length+1,e.rules.map(e=>({...e,order:n+e.order}))}),r={},i=[],a=new Map,o=e.flatMap(e=>e.diagnostics);for(let t of e){Object.assign(r,t.variables),i.push(...t.headAtRules);for(let e of t.fontFaces)a.set(e.css,e)}return{rules:n,headAtRules:i,fontFaces:[...a.values()],variables:r,diagnostics:o}},Jp=e=>is(e)&&typeof e.type==`string`&&typeof e.start==`number`&&typeof e.end==`number`,J=(e,t)=>{let n=e[t];return Jp(n)?n:void 0},Yp=(e,t)=>{let n=e[t];return Array.isArray(n)?n.filter(Jp):[]},Y=(e,t)=>{let n=e[t];return typeof n==`string`?n:void 0},Xp=e=>{if(e!==void 0){if(e.type===`Identifier`)return Y(e,`name`);if(e.type===`StringLiteral`)return Y(e,`value`)}},Zp=e=>{let t=e;for(;;){if(t.type===`ParenthesizedExpression`||t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`||t.type===`TSTypeAssertion`||t.type===`TypeCastExpression`){let e=J(t,`expression`);if(e===void 0)return t;t=e;continue}return t}},Qp=class extends Error{path;line;column;constructor(e,t,n,r){super(t),this.name=`SourceSyntaxError`,this.path=e,this.line=n,this.column=r}},$p=(e,t)=>{let n=bs(t),r=e=>xs(n,e),i;try{i=zp(t,{plugins:[`typescript`,`jsx`],sourceType:`module`}).program}catch(t){let n=is(t)&&is(t.loc)?t.loc:void 0,r=typeof n?.line==`number`?n.line:1,i=typeof n?.column==`number`?n.column+1:1;throw new Qp(e,t instanceof Error?t.message.replace(/\s*\(\d+:\d+\)\s*$/,``):``,r,i)}if(!Jp(i))throw new Qp(e,`The file did not parse to a program.`,1,1);return{path:e,source:t,program:i,position:r}},em=(e,t)=>e===``?t:`${e}.${t}`,tm=e=>{switch(e.k){case`path`:return e.path===``?void 0:{bind:e.path};case`value`:return e.value;default:return}},nm=e=>e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`,rm=e=>typeof e!=`object`||!e||!(`el`in e||`each`in e||`raw`in e||`preheader`in e||`if`in e&&Array.isArray(e.then)),im=[`transactional`,`promotional`,`service_implicit`],am=[`marketing`,`utility`,`authentication`],om=[`text`,`image`,`video`,`document`],sm=[`category`],cm=[`language`,`category`],lm=e=>typeof e==`object`&&!!e&&`concat`in e,um=e=>{let t=[],n=[],r=``,i=e=>{if(e===null||typeof e==`boolean`)return;if(typeof e==`string`){r+=e;return}if(typeof e==`number`){r+=String(e);return}if(typeof e==`object`&&lm(e)){for(let t of e.concat)i(t);return}if(typeof e==`object`&&(`el`in e||`each`in e||`raw`in e))throw TypeError(`A WhatsApp text part holds text and values only.`);if(typeof e==`object`&&`if`in e&&Array.isArray(e.then))throw TypeError(`A WhatsApp text part cannot branch.`);let a=e,o=JSON.stringify(a),s=n.indexOf(o);s<0&&(s=n.length,n.push(o),t.push(a)),r+=`{{${s+1}}}`};for(let t of e)i(t);return{template:r,params:t}},dm=(e,t,n)=>{if(Math.abs(e.length-t.length)>n)return n+1;let r=Array.from({length:t.length+1},(e,t)=>t);for(let n=1;n<=e.length;n++){let i=[n];for(let a=1;a<=t.length;a++)i[a]=Math.min(i[a-1]+1,r[a]+1,r[a-1]+(e[n-1]===t[a-1]?0:1));r=i}return r[t.length]},fm=(e,t)=>{let n=e.toLowerCase(),r=t.find(e=>e.toLowerCase()===n);if(r!==void 0&&r!==e)return r;let i=Math.max(1,Math.min(3,Math.floor(e.length/3))),a,o=i+1;for(let e of t){let t=dm(n,e.toLowerCase(),i);t<o&&(a=e,o=t)}return a},pm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),mm=(e,t,n=0)=>{let r=t.$ref;if(typeof r!=`string`||n>16)return t;if(r===`#`)return e;let i=e;for(let e of r.replace(/^#\//,``).split(`/`)){if(!pm(i))return t;i=i[e.replace(/~1/g,`/`).replace(/~0/g,`~`)]}return pm(i)?mm(e,i,n+1):t},hm=(e,t)=>{let n=mm(e,t);return[n,...[n.anyOf,n.oneOf,n.allOf].flatMap(t=>Array.isArray(t)?t.filter(pm).flatMap(t=>hm(e,t)):[])]},gm=(e,t)=>{if(t===void 0)return`unknown`;let n=new Set;for(let r of hm(e,t)){let e=r.type;if(typeof e==`string`)n.add(e);else if(Array.isArray(e))for(let t of e)typeof t==`string`&&n.add(t);if(r.const!==void 0&&n.add(typeof r.const),Array.isArray(r.enum))for(let e of r.enum)n.add(typeof e)}if(n.delete(`null`),n.size!==1)return`unknown`;let[r]=n;switch(r){case`string`:return`string`;case`number`:case`integer`:return`number`;case`boolean`:return`boolean`;case`array`:return`array`;case`object`:return`object`;default:return`unknown`}},_m=(e,t,n)=>{let r=[],i=!0,a;for(let o of hm(e,t)){if(pm(o.properties)&&(i=!1,r.push(...Object.keys(o.properties)),Object.hasOwn(o.properties,n))){let e=o.properties[n],t=Array.isArray(o.required)&&o.required.includes(n);a={schema:pm(e)?e:void 0,required:a?.required===!0||t}}if(o.type===`object`&&!pm(o.properties)&&o.additionalProperties===!1&&(i=!1),(Array.isArray(o.items)||pm(o.items))&&/^\d+$/.test(n))return i=!1,{found:!0,schema:pm(o.items)?o.items:void 0,required:!0,names:r,open:!1};pm(o.additionalProperties)&&a===void 0&&(a={schema:o.additionalProperties,required:!1},i=!1)}return a===void 0?{found:!1,schema:void 0,required:!1,names:r,open:i}:{found:!0,schema:a.schema,required:a.required,names:r,open:!1}},vm=(e,t)=>t.size===0?e:{...e,guards:new Set([...e.guards,...t])},ym=e=>{let t=e.split(`.`);return t.map((e,n)=>t.slice(0,n+1).join(`.`))},bm=e=>typeof e==`object`&&e&&`bind`in e?e.bind:void 0,xm=(e,t)=>{let n=e=>e===void 0?new Set:new Set(ym(e));if(`present`in e)return t?n(e.present):new Set;if(`truthy`in e){let r=e.truthy,i=bm(r)??(typeof r==`object`&&r&&`length`in r?bm(r.length):void 0);return t?n(i):new Set}if(`not`in e)return xm(e.not,!t);if(`and`in e||`or`in e){let n=`and`in e?e.and:e.or,r=`and`in e?t:!t,i=n.map(e=>xm(e,t));if(r)return new Set(i.flatMap(e=>[...e]));let[a,...o]=i;return new Set([...a??[]].filter(e=>o.every(t=>t.has(e))))}let[r,i]=e.args,a=bm(r)??bm(i),o=bm(r)===void 0?r:i;if(a===void 0)return new Set;let s=o===null,c=typeof o!=`object`||!o||`concat`in o||`format`in o||`op`in o||`length`in o||`count`in o;return e.cmp===`eq`?!c||t===s?new Set:n(a):e.cmp===`ne`?!c||t!==s?new Set:n(a):t?n(a):new Set},Sm=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=`${e.code}\0${e.message}\0${e.src?.join(`,`)??``}`;i.has(t)||(i.add(t),r.push(e))},o=e=>e.startsWith(`$`)?e.slice(1):`input.${e}`,s=(t,n,r)=>{let i=t.split(`.`),a=i[0],o;if(a.startsWith(`$`)){if(!n.variables.has(a.slice(1)))return;o=n.variables.get(a.slice(1))}else{let i=_m(e,e,a);if(!i.found)return c(a,i,``,r,t);!i.required&&!n.guards.has(a)&&l(a,r),o=i.schema}for(let a=1;a<i.length;a++){if(o===void 0)return;let s=i[a],u=_m(e,o,s),d=i.slice(0,a).join(`.`);if(!u.found)return u.open?void 0:c(s,u,d,r,t);let f=i.slice(0,a+1).join(`.`);!u.required&&!n.guards.has(f)&&l(f,r),o=u.schema}return o},c=(e,t,n,r,i)=>{if(t.open)return;let s=fm(e,t.names),c=n===``?`input`:o(n);a({code:`unknown-field`,message:`\`${n===``?`input`:o(n)}.${e}\` is not in the schema${t.names.length===0?``:` (${c} has ${t.names.map(e=>`\`${e}\``).join(`, `)})`}.`,...s===void 0?{fix:`Add \`${e}\` to the schema, or bind a field it declares.`}:{fix:`Did you mean \`${n===``?`input`:o(n)}.${s}\`?`},src:r})},l=(e,t)=>{a({code:`unguarded-optional`,message:`\`${o(e)}\` is optional and is read outside a guard, so a send without it would render a blank.`,fix:`Guard it: {${o(e)} && …}, or make the field required in the schema.`,src:t})},u=(t,n,r)=>{if(typeof t==`string`)return`string`;if(typeof t==`number`)return`number`;if(typeof t==`boolean`)return`boolean`;if(t===null)return`unknown`;if(`bind`in t)return gm(e,s(t.bind,n,r));if(`lit`in t)return`unknown`;if(`concat`in t){for(let e of t.concat)u(e,n,r);return`string`}if(`format`in t)return f(t.format,t.args,n,r),`string`;if(`if`in t){p(t.if,n,r);let e=u(t.then,vm(n,xm(t.if,!0)),r);return u(t.else,vm(n,xm(t.if,!1)),r),e}if(`op`in t){for(let e of t.args)d(e,`number`,n,r,`arithmetic`);return`number`}if(`length`in t)return u(t.length,n,r),`number`;if(`count`in t){let i=bm(t.count),a;if(i===void 0)u(t.count,n,r);else{let t=s(i,n,r);if(t!==void 0)for(let n of hm(e,t))pm(n.items)&&(a=mm(e,n.items))}let o=new Map(n.variables).set(t.as.replace(/^\$/,``),a);return p(t.where,{...n,variables:o},r),`number`}return`unknown`},d=(e,t,n,r,i)=>{let s=u(e,n,r);if(s===`unknown`||s===t)return;let c=bm(e);a({code:`invalid-binding-type`,message:`${c===void 0?`This value`:`\`${o(c)}\``} is ${s===`array`?`an array`:`a ${s}`}, and ${i} needs ${t===`array`?`an array`:`a ${t}`}.`,fix:t===`number`?`Bind a number field, or send the number in the payload.`:`Bind a ${t} field.`,src:r})},f=(e,t,n,r)=>{let i={money:[`number`,`string`,`string`],number:[`number`,void 0,`string`],date:[`string`,`string`,`string`],time:[`string`,`string`,`string`],plural:[`number`,void 0,`string`],list:[`array`,`string`]};for(let[a,o]of t.entries()){let t=i[e]?.[a];t===void 0?u(o,n,r):d(o,t,n,r,`\`fmt.${e}\``)}},p=(e,t,n)=>{if(`present`in e){m(e.present,t,n);return}if(`truthy`in e){let r=e.truthy,i=bm(r);i===void 0?h(r,t,n):m(i,t,n);return}if(`not`in e){p(e.not,t,n);return}if(`and`in e){let r=t;for(let t of e.and)p(t,r,n),r=vm(r,xm(t,!0));return}if(`or`in e){let r=t;for(let t of e.or)p(t,r,n),r=vm(r,xm(t,!1));return}let r=e.cmp===`lt`||e.cmp===`gt`||e.cmp===`le`||e.cmp===`ge`,i=r&&e.args.every(e=>u(e,t,n)===`string`);for(let a of e.args){let e=bm(a);i||(e!==void 0&&!r?m(e,t,n):r?d(a,`number`,t,n,`a comparison`):h(a,t,n))}},m=(e,t,n)=>{s(e,{...t,guards:new Set([...t.guards,...ym(e)])},n)},h=(e,t,n)=>{if(typeof e==`object`&&e&&`length`in e){let r=bm(e.length);if(r!==void 0){m(r,t,n);return}}u(e,t,n)},g=(e,t,n,r)=>{let i=u(e,t,n);if(i===`array`||i===`object`){let t=bm(e);a({code:`invalid-binding-type`,message:`${t===void 0?`This value`:`\`${o(t)}\``} is ${i===`array`?`an array`:`an object`}, and ${r} takes a string or a number.`,fix:i===`array`?`Render the items with .map, or bind one of their fields.`:`Bind one of its fields.`,src:n})}},_=(e,t,n)=>{if(e===void 0||typeof e==`string`)return;if(Array.isArray(e)){for(let[,r]of e)g(r,t,n,`a style value`);return}let r=e;p(r.if,t,n),_(r.then,vm(t,xm(r.if,!0)),n),_(r.else,vm(t,xm(r.if,!1)),n)},v=(t,n,r)=>{for(let i of t){if(rm(i)){g(i,n,r,`text`);continue}if(`el`in i){for(let e of Object.values(i.attrs??{}))g(e,n,i.src,`an attribute`);_(i.style,n,i.src),v(i.children??[],n,i.src)}else if(`if`in i)p(i.if,n,i.src),v(i.then,vm(n,xm(i.if,!0)),i.src??r),v(i.else??[],vm(n,xm(i.if,!1)),i.src??r);else if(`each`in i){let t=bm(i.each),c;if(t!==void 0){c=s(t,n,i.src);let r=gm(e,c);r!==`array`&&r!==`unknown`&&a({code:`invalid-binding-type`,message:`\`${o(t)}\` is ${r===`object`?`an object`:`a ${r}`}, and a loop needs an array.`,fix:`Loop over an array field.`,src:i.src})}else u(i.each,n,i.src);let l;if(c!==void 0)for(let t of hm(e,c))pm(t.items)&&(l=mm(e,t.items));let d=i.as.replace(/^\$/,``);i.where!==void 0&&p(i.where,{...n,variables:new Map(n.variables).set(d,l)},i.src??r);let f=new Map(n.variables);f.set(d,i.chunk===void 0||l===void 0?l:{type:`array`,items:l}),i.index!==void 0&&f.set(i.index.replace(/^\$/,``),{type:`integer`});let m=i.where===void 0?n:vm(n,xm(i.where,!0));v(i.children,{...m,variables:f},i.src??r)}else if(`raw`in i)for(let e of i.raw)typeof e!=`string`&&g(`attr`in e?e.attr:e.text,n,i.src,`markup`)}},y={variables:new Map,guards:new Set};v(t,y);for(let e of n)g(e,y,void 0,`the subject or preheader`);return r},Cm=(e,t)=>{let n=e=>e.flatMap(e=>rm(e)?[e]:`if`in e?[...n(e.then),...n(e.else??[])]:`each`in e?n(e.children):[e]),r=e=>{for(let t of e)rm(t)||(`el`in t?i(t):`if`in t?(r(t.then),r(t.else??[])):`each`in t&&r(t.children))},i=e=>{let i=Wc(e.el),a=n(e.children??[]);if(i!==void 0){if(i.content===`void`&&a.length>0)t({code:`void-element-children`,message:`<${e.el}> cannot have children.`,src:e.src});else if(i.content===`text`||i.content===`raw`)for(let n of a)!rm(n)&&!(`raw`in n)&&t({code:`invalid-content`,message:`<${e.el}> accepts text only.`,src:e.src});else if(i.childElements!==void 0)for(let n of a)if(rm(n)){if(typeof n==`string`&&n.trim()===``)continue;t({code:`invalid-content`,message:`<${e.el}> cannot contain text directly; put it inside <${i.childElements[0]}>.`,src:e.src})}else`el`in n&&!i.childElements.includes(n.el)&&t({code:`invalid-content`,message:`<${e.el}> accepts only ${i.childElements.map(e=>`<${e}>`).join(`, `)}; found <${n.el}>.`,src:n.src??e.src});r(e.children??[])}};r(e)},wm=``,Tm=``,Em=/(\d+)/g,Dm=class{entries=[];value(e){return typeof e==`string`?e:(this.entries.push({value:e}),`${wm}${this.entries.length-1}${Tm}`)}nodes(e){return this.entries.push({nodes:e}),`${wm}${this.entries.length-1}${Tm}`}parse(e){let t=[],n=0;for(let r of e.matchAll(Em)){r.index>n&&t.push(e.slice(n,r.index));let i=this.entries[Number(r[1])];i!==void 0&&t.push(i),n=r.index+r[0].length}return n<e.length&&t.push(e.slice(n)),t}toValue(e){let t=this.parse(e);if(t.length===0)return``;let n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(`value`in e)n.push(e.value);else return;return n.length===1?n[0]:{concat:n}}},Om=(e,t)=>nm(t)?t:e.value(t),km=e=>e===void 0?{}:{src:e},Am=(e,t)=>{let n=[],r=!1,i,a=``,o=()=>{a!==``&&n.push(a),a=``};for(let s=0;s<t.length;s++){let c=t[s];if(c===wm){let i=t.indexOf(Tm,s),a=e.parse(t.slice(s,i+1))[0];if(i>s&&a!==void 0&&typeof a!=`string`&&`value`in a){o(),n.push(r?{attr:a.value}:{text:a.value}),s=i;continue}}!r&&c===`<`?r=!0:r&&i===void 0&&(c===`"`||c===`'`)?i=c:r&&i===c?i=void 0:r&&i===void 0&&c===`>`&&(r=!1),a+=c}return o(),n},jm=(e,t)=>{if(!is(t))return;let n=[];for(let[r,i]of Object.entries(t))if(i!=null){if(typeof i==`number`)n.push([r,i]);else if(typeof i==`string`){let t=e.toValue(i);t!==void 0&&n.push([r,t])}}return n},Mm=(e,t,n)=>{if(e===null)return[];switch(e.type){case`Text`:{let n=[];for(let r of t.parse(e.value))typeof r==`string`?n.push(r):`value`in r?n.push(r.value):n.push(...r.nodes);return n}case`Fragment`:return e.children.flatMap(e=>Mm(e,t,n));case`Raw`:return[{raw:Am(t,e.html),...e.text===``?{}:{text:e.text},...km(n)}];case`Element`:{let r={},i;for(let[n,a]of Object.entries(e.props)){if(n===`key`||a==null||a===!1)continue;if(n===`style`){i=jm(t,a);continue}let e=n===`className`?`class`:n;typeof a==`string`?r[e]=t.toValue(a)??a:(typeof a==`number`||a===!0)&&(r[e]=a)}let a=e.props[Ac]===!0;return[{el:e.tag,...Object.keys(r).length===0?{}:{attrs:r},...i===void 0||Array.isArray(i)&&i.length===0?{}:{style:i},...e.children.length===0?{}:{children:e.children.flatMap(e=>Mm(e,t,n))},...a?{reserved:!0}:{},...km(n)}]}}},Nm={Button:[`height`,`paddingX`,`borderRadius`,`borderWidth`,`fontSize`,`width`],Spacer:[`height`],Divider:[`thickness`],BrandLogo:[`width`]},Pm={Email:gl,Section:_l,Columns:bl,Column:xl,Button:Ol,Spacer:kl,Divider:Al,Image:jl,Link:Ml},Fm=(e,t,n,r)=>{switch(r.k){case`object`:{let n={};for(let[i,a]of r.fields)n[i]=Fm(e,t,i,a);return n}case`nodes`:e.lowerer.error(e.ctx,e.node,`dynamic-expression`,`<${e.name} ${n}> takes text, not markup.`);return;default:{let i=tm(r);if(i===void 0){e.lowerer.error(e.ctx,e.node,`dynamic-expression`,`<${e.name} ${n}> cannot be the input as a whole.`,`Bind one field.`);return}return Om(t,i)}}},Im=(e,t)=>{let n=t.length===1?t[0]:void 0;return n!==void 0&&rm(n)&&n!==null&&typeof n!=`boolean`?typeof n==`string`?n:e.value(n):t.map(t=>rm(t)?typeof t==`string`?t:e.value(t):e.nodes([t]))},Lm=(e,t)=>{if(e!==void 0)return vl(e);let n={length:t};return{concat:[{op:`/`,args:[{op:`-`,args:[100,{op:`%`,args:[100,n]}]},n]},`%`]}},Rm=(e,t)=>{let{lowerer:n,ctx:r,node:i}=e,a=t.get(`each`),o=a===void 0?void 0:tm(a);if(o===void 0){n.error(r,i,`invalid-columns-each`,`<Columns each> takes a list from the input.`,`Write each={input.items}.`);return}let s=t.get(`per`),c=s?.k===`value`?s.value:void 0;if(s!==void 0&&!(typeof c==`number`&&Number.isInteger(c)&&c>=1)){n.error(r,i,`invalid-columns-per`,`<Columns per> is a whole number of cells, one or more.`,`Write per={2}.`);return}let l=typeof c==`number`?c:void 0,u=Yp(i,`children`).filter(e=>e.type!==`JSXText`||(Y(e,`value`)??``).trim()!==``),d=u.length===1?u[0]:void 0,f=d?.type===`JSXExpressionContainer`?J(d,`expression`):void 0,p=f===void 0?void 0:Zp(f);if(p===void 0||!/Function/.test(p.type)){n.error(r,i,`invalid-columns-each`,`<Columns each> takes a function of one item as its only child.`,`Write {(item) => <Column>…</Column>}.`);return}let m=l===void 0?void 0:n.freshName(r,`row`),h={...r,loops:m===void 0?r.loops:[...r.loops,m],columnWidth:Lm(l,o)},g=n.eachOver(h,i,m===void 0?o:{bind:`$${m}`},p);if(g!==void 0)return{cells:g,wrap:e=>m===void 0||l===void 0?e:[{each:o,as:m,chunk:l,children:e,src:n.src(r.module,i)}]}},zm=e=>{let{lowerer:t,ctx:n,node:r,binding:i}=e,a=i.specifier;if(i.kind===`markup`&&(a===`@samva/markup/sms`||a===`@samva/markup/whatsapp`)){let i=e.channel?.(e);return i===void 0?(t.error(n,r,`wrong-channel`,`<${e.name}> belongs in the ${a.split(`/`).pop()} body of a template.`,"Write it in the `sms` or `whatsapp` function of defineTemplate."),[]):i}let o=i.imported,s=i.kind===`markup`&&a===`@samva/markup/email`,c=i.kind===`brand`;if(!(s||c))return t.error(n,r,`unknown-component`,`<${e.name}> is not a component the profile can read.`,`Import components from @samva/markup/email, ${e.brandPlugin.specifier}, or the project.`),[];let l;if(s)l=Pm[o];else{if(e.brand===void 0)return t.error(n,r,`brand-unavailable`,`<${e.name}> comes from ${i.specifier}, and this build has no brand to resolve it.`,`Compile with a brand, or remove the brand components.`),[];let a=bu(e.brand,e.brandPlugin);l=o===`BrandLogo`?a.BrandLogo:o===`BrandFooter`?a.BrandFooter:void 0}if(l===void 0||!Object.hasOwn(Pm,o)&&s)return t.error(n,r,`unknown-component`,`\`${o}\` is not an email component.`,`Use one of ${Object.keys(Pm).join(`, `)}, BrandLogo or BrandFooter.`),[];let u=t.attributeBindings(n,e.attributes);if(u===void 0)return[];let d=u,f=e=>e,p,m={...n,columnWidth:void 0};if(o===`Columns`&&u.has(`each`)){let t=Rm(e,u);if(t===void 0)return[];d=new Map([...u].filter(([e])=>e!==`each`&&e!==`per`)),p=[t.cells],f=t.wrap}else p=t.jsxChildren(m,r);let h=new Dm,g={};for(let[t,n]of d)g[t]=Fm(e,h,t,n);for(let i of Nm[o]??[]){let a=g[i];if(typeof a==`string`&&!/^-?\d+(\.\d+)?$/.test(a)&&a!==void 0)return t.error(n,r,`dynamic-numeric-prop`,`<${e.name} ${i}> sizes the layout at compile time, so it must be a number literal.`,`Write ${i}={44}.`),[]}if(o===`Column`&&g.width===void 0&&n.columnWidth!==void 0&&(g.width=Om(h,n.columnWidth)),p.length>0&&(g.children=Im(h,p)),o===`Button`&&typeof g.children==`string`&&g.children!==``&&g.width===void 0&&g.height!==void 0&&h.toValue(g.children)!==g.children)return t.error(n,r,`button-dynamic-label`,`Classic Outlook draws the button from a fixed box, and a label read at render time cannot size it.`,`Give the button a width: <Button width={200} …>.`),[];gs();let _=l(g),v=t.findings.locate(n.module.parsed,r);for(let e of gs())t.findings.items.push({...e,origins:[v]});return _!==null&&(!is(_)||typeof _.type!=`string`)?[]:f([...Mm(_,h,t.src(n.module,r))])},Bm=(e,t,n)=>({ok:!1,node:t,module:e,reason:n}),Vm=e=>{if(e.type===`ObjectProperty`&&e.computed!==!0){let t=J(e,`key`);if(t===void 0)return;if(t.type===`Identifier`)return Y(t,`name`);if(t.type===`StringLiteral`)return Y(t,`value`);if(t.type===`NumericLiteral`)return String(t.value)}},Hm=(e,t,n,r=new Set)=>{let i=`${t.path}\0${n}`;if(r.has(i))return;r.add(i);let a=t.declarations.get(n);if(a!==void 0)return{module:t,value:a.value};let o=t.imports.get(n);if(o===void 0)return;if(o.kind===`asset`)return{asset:o.path};if(o.kind!==`project`)return;let s=e.project.modules.get(o.path);if(s===void 0)return;if(o.imported==="default"){let e=s.defaultExport;return e===void 0?void 0:{module:s,value:e}}let c=s.exports.get(o.imported);return c===void 0?void 0:Hm(e,s,c,r)},Um=(e,t,n,r=new Set)=>{let i=Zp(n);switch(i.type){case`StringLiteral`:return{ok:!0,value:i.value};case`NumericLiteral`:return{ok:!0,value:i.value};case`BooleanLiteral`:return{ok:!0,value:i.value};case`NullLiteral`:return{ok:!0,value:null};case`TemplateLiteral`:{if(Yp(i,`expressions`).length>0)return Bm(t,i,"a template string with a `${}` part is computed at run time");let e=Yp(i,`quasis`)[0]?.value,n=e?.cooked??e?.raw;return{ok:!0,value:typeof n==`string`?n:``}}case`UnaryExpression`:{let e=J(i,`argument`);return Y(i,`operator`)===`-`&&e!==void 0&&e.type===`NumericLiteral`&&typeof e.value==`number`?{ok:!0,value:-e.value}:Bm(t,i,`only a negative number literal is data`)}case`Identifier`:{let n=Y(i,`name`)??``;if(n===`undefined`)return{ok:!0,value:void 0};let a=Hm(e,t,n);if(a===void 0)return Bm(t,i,`\`${n}\` is not a constant in the project`);if(`asset`in a){let r=e.assetUrl(a.asset);return r===void 0?Bm(t,i,`\`${n}\` names an asset the build did not address`):{ok:!0,value:r}}let o=`${a.module.path}\0${n}\0${a.value.start}`;if(r.has(o))return Bm(t,i,`\`${n}\` refers to itself`);r.add(o);let s=Um(e,a.module,a.value,r);return r.delete(o),s}case`ArrayExpression`:{let n=[];for(let a of Array.isArray(i.elements)?i.elements:[]){if(typeof a!=`object`||!a)return Bm(t,i,`an array hole`);let o=a;if(o.type===`SpreadElement`){let i=J(o,`argument`);if(i===void 0)return Bm(t,o,`an empty spread`);let a=Um(e,t,i,r);if(!a.ok)return a;if(!Array.isArray(a.value))return Bm(t,o,`a spread of a non-array`);n.push(...a.value);continue}let s=Um(e,t,o,r);if(!s.ok)return s;n.push(s.value)}return{ok:!0,value:n}}case`ObjectExpression`:{let n={};for(let a of Yp(i,`properties`)){if(a.type===`SpreadElement`){let i=J(a,`argument`);if(i===void 0)return Bm(t,a,`an empty spread`);let o=Um(e,t,i,r);if(!o.ok)return o;if(typeof o.value!=`object`||o.value===null||Array.isArray(o.value))return Bm(t,a,`a spread of a non-object`);Object.assign(n,o.value);continue}let i=Vm(a);if(i===void 0)return Bm(t,a,`a computed or method property`);let o=J(a,`value`);if(o===void 0)return Bm(t,a,`a property without a value`);let s=Um(e,t,o,r);if(!s.ok)return s;s.value!==void 0&&(n[i]=s.value)}return{ok:!0,value:n}}case`CallExpression`:{let n=J(i,`callee`),a=Yp(i,`arguments`)[0];return n?.type===`Identifier`&&Y(n,`name`)===`jsonSchema`&&a!==void 0?Um(e,t,a,r):Bm(t,i,`a call is computed at run time`)}default:return Bm(t,i,`${i.type} is not data`)}},Wm=40,Gm={"+":`+`,"-":`-`,"*":`*`,"/":`/`,"%":`%`},Km={"===":`eq`,"!==":`ne`,"<":`lt`,">":`gt`,"<=":`le`,">=":`ge`},qm={money:[2,3],number:[1,3],date:[1,3],time:[1,3],plural:[2,3],list:[1,2]},Jm=new Set([`reduce`,`filter`,`slice`,`join`,`sort`,`concat`,`flatMap`,`find`,`some`,`every`,`toFixed`,`toLocaleString`,`toLocaleDateString`,`toUpperCase`,`toLowerCase`,`trim`,`split`,`replace`,`padStart`,`includes`,`indexOf`,`at`]),Ym=e=>{let t=e.split(/\r\n|\n|\r/),n=0;for(let[e,r]of t.entries())/[^ \t]/.test(r)&&(n=e);let r=``;for(let[e,i]of t.entries()){let a=i.replace(/\t/g,` `);e!==0&&(a=a.replace(/^ +/,``)),e!==t.length-1&&(a=a.replace(/ +$/,``)),a!==``&&(e!==n&&(a+=` `),r+=a)}return r},Xm=e=>e.type===`JSXIdentifier`?Y(e,`name`)??``:e.type===`JSXNamespacedName`?`${Y(J(e,`namespace`)??e,`name`)??``}:${Y(J(e,`name`)??e,`name`)??``}`:e.type===`JSXMemberExpression`?`${Xm(J(e,`object`)??e)}.${Y(J(e,`property`)??e,`name`)??``}`:``,Zm=e=>e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`,Qm=e=>e===`VariableDeclaration`?"`const`":e===`IfStatement`?"`if`":/For|While/.test(e)?`a loop`:`a statement`,$m=class{options;sources=[];uniqueId=0;reservedAttributes;constructor(e){this.options=e,this.reservedAttributes=Fc(e.brandPlugin)}get findings(){return this.options.findings}src(e,t){let n=e.parsed.position(t.start);if(e.path===this.options.project.entry.path)return[n.line,n.column];let r=this.sources.indexOf(e.path);return r<0&&(r=this.sources.length,this.sources.push(e.path)),[n.line,n.column,r+1]}error(e,t,n,r,i){this.findings.add(e.module.parsed,t,n,r,i)}dynamic(e,t,n,r){this.error(e,t,`dynamic-expression`,`${n} runs code, and templates render without running code.`,r)}functionExpression(e,t){let n=J(t,`body`);if(n===void 0)return;if(n.type!==`BlockStatement`)return n;let r=Yp(n,`body`),i=r[0];if(r.length===1&&i?.type===`ReturnStatement`){let e=J(i,`argument`);if(e!==void 0)return e}let a=r.find(e=>e.type!==`ReturnStatement`)??n,o=Qm(a.type);this.error(e,a,`statement-in-body`,`A body is one expression, and ${o} is a statement.`,"Write the value where it is used: `cond && <X />` or `cond ? <A /> : <B />` for branches, `.map` for lists. Compute anything else in the caller and send it in the payload.")}bindPattern(e,t,n,r,i){switch(t.type){case`Identifier`:{let e=Y(t,`name`)??``;r.set(e,n??{k:`value`,value:null});return}case`AssignmentPattern`:{let a=J(t,`left`),o=J(t,`right`);if(a===void 0||o===void 0)return;if(!i){this.error(e,t,`unsupported-pattern`,`A default value on the input is never inserted, so it is not part of the profile.`,`Remove the default; declare the field as required or guard it where it is read.`);return}let s=n;if(s===void 0){let t=Um(this.options.staticContext,e.module,o);if(!t.ok){this.error(e,o,`dynamic-expression`,`A default prop value must be a literal.`,`Use a string, number or boolean literal.`);return}s={k:`value`,value:t.value}}this.bindPattern(e,a,s,r,i);return}case`ObjectPattern`:for(let a of Yp(t,`properties`)){if(a.type===`RestElement`){this.error(e,a,`unsupported-pattern`,`A rest element gathers props at run time.`,`Name each prop you use.`);continue}let t=J(a,`key`),o=J(a,`value`),s=Xp(t);if(s===void 0||o===void 0||a.computed===!0){this.error(e,a,`unsupported-pattern`,`A computed key cannot be read statically.`);continue}let c=n===void 0?void 0:this.field(e,n,s,a);this.bindPattern(e,o,c,r,i)}return;default:this.error(e,t,`unsupported-pattern`,`A parameter is a name or an object pattern of names.`,"Write `(input) =>` or `({ name, items }) =>`.")}}field(e,t,n,r){switch(t.k){case`path`:return n===`length`&&t.path!==``?{k:`value`,value:{length:{bind:t.path}}}:{k:`path`,path:em(t.path,n)};case`object`:return t.fields.get(n);case`value`:if(n===`length`)return{k:`value`,value:{length:t.value}};if(t.value===null)return{k:`value`,value:null};this.error(e,r,`dynamic-expression`,`\`.${n}\` reads a property of a computed value.`,`Read fields of the input directly.`);return;case`nodes`:this.error(e,r,`dynamic-expression`,"`children` has no fields.","Render `{children}` as is.");return}}binding(e,t){let n=Zp(t);if(n.type===`Identifier`){let t=Y(n,`name`)??``;if(t===`undefined`)return{k:`value`,value:null};let r=e.env.get(t);if(r!==void 0)return r;let i=e.module.imports.get(t);if(i?.kind===`asset`){let e=this.options.assetUrl(i.path);if(e!==void 0)return{k:`value`,value:e}}this.error(e,n,`dynamic-expression`,`\`${t}\` is not a binding the template declared.`,"Read the input through the function's parameter, for example `input.name`.");return}if(n.type===`MemberExpression`){let t=J(n,`object`),r=J(n,`property`);if(t===void 0||r===void 0)return;if(n.computed!==!0&&Y(r,`name`)===`length`&&this.filterChain(e,t)!==void 0){let n=this.filterChain(e,t);if(n.list===void 0)return;let r=n.filters[0],i=r===void 0?void 0:Yp(r,`params`)[0],a=this.uniqueName(e,i?.type===`Identifier`?Y(i,`name`)??`item`:`item`),o=this.whereClause({...e,loops:[...e.loops,a]},a,n.filters);return o===void 0?void 0:{k:`value`,value:{count:n.list,as:a,where:o}}}let i=this.binding(e,t);if(i===void 0)return;let a;if(n.computed===!0){if(r.type===`StringLiteral`?a=Y(r,`value`):r.type===`NumericLiteral`&&(a=String(r.value)),a===void 0){this.dynamic(e,n,`A computed property`,"Use `.name`, or a numeric index such as `[0]`.");return}}else a=Y(r,`name`);return a===void 0?void 0:this.field(e,i,a,n)}if(n.type===`OptionalMemberExpression`||n.type===`OptionalCallExpression`){this.dynamic(e,n,`Optional chaining`,"Guard the field: `input.discount && <p>{input.discount.label}</p>`.");return}let r=this.value(e,n,!1);return r===void 0?void 0:{k:`value`,value:r}}value(e,t,n){let r=Zp(t);switch(r.type){case`StringLiteral`:return this.checkedText(e,r,Y(r,`value`)??``);case`NumericLiteral`:return typeof r.value==`number`?r.value:void 0;case`BooleanLiteral`:return r.value===!0;case`NullLiteral`:return null;case`Identifier`:case`MemberExpression`:case`OptionalMemberExpression`:{let t=this.binding(e,r);if(t===void 0)return;let n=tm(t);if(n!==void 0)return n;this.error(e,r,`dynamic-expression`,t.k===`path`?`The input as a whole is not a value.`:"An object or `children` is not text.",t.k===`path`?"Read one field: `input.name`.":"Render `{children}` as content, or read one field.");return}case`TemplateLiteral`:return this.template(e,r,n);case`ConditionalExpression`:{let t=J(r,`test`),i=J(r,`consequent`),a=J(r,`alternate`);if(t===void 0||i===void 0||a===void 0)return;let o=this.predicate(e,t),s=this.value(e,i,n),c=this.value(e,a,n);return o===void 0||s===void 0||c===void 0?void 0:{if:o,then:s,else:c}}case`LogicalExpression`:{let t=Y(r,`operator`),i=J(r,`left`),a=J(r,`right`);if(i===void 0||a===void 0)return;if(t===`||`){let t=this.value(e,i,n),r=this.value(e,a,n);return t===void 0||r===void 0?void 0:{if:{truthy:t},then:t,else:r}}if(t===`??`){this.error(e,r,`dynamic-expression`,"`??` is not one of the conditions the profile reads.",'Write the condition out: `input.name === null ? "there" : input.name`, or `input.name || "there"`.');return}this.error(e,r,`dynamic-expression`,"`&&` in a value position yields its left operand when that is falsy.","Use a conditional: `cond ? value : fallback`, or `cond && <X />` in content.");return}case`CallExpression`:return this.call(e,r);case`BinaryExpression`:{let t=Y(r,`operator`)??``,i=Gm[t],a=J(r,`left`),o=J(r,`right`);if(i===void 0||a===void 0||o===void 0){this.error(e,r,`dynamic-expression`,`\`${t}\` produces a condition, not a value.`,"Use it as the test of `&&`, `? :` or `||`.");return}if(!n){this.error(e,r,`dynamic-expression`,"Arithmetic runs code, and it is allowed only inside a `fmt.*` argument or a condition.","Wrap it: `fmt.number(item.price * item.qty)`, or send the computed value in the payload.");return}if(i===`+`&&[a,o].some(e=>/StringLiteral|TemplateLiteral/.test(Zp(e).type))){this.error(e,r,`dynamic-expression`,"`+` with a string joins text at run time.","Use a template string: `${a} ${b}`.");return}let s=this.value(e,a,!0),c=this.value(e,o,!0);return s===void 0||c===void 0?void 0:{op:i,args:[s,c]}}case`UnaryExpression`:{let t=Y(r,`operator`),i=J(r,`argument`);if(t===`-`&&i!==void 0){let t=Zp(i);if(t.type===`NumericLiteral`&&typeof t.value==`number`)return-t.value;if(n){let t=this.value(e,i,!0);return t===void 0?void 0:{op:`-`,args:[0,t]}}}if(t===`!`){this.error(e,r,`dynamic-expression`,"`!` produces a condition, not a value.","Use it as the test of `&&`, `? :` or `||`.");return}return this.dynamic(e,r,`\`${t??`?`}\``,`Send the computed value in the payload.`)}case`JSXElement`:case`JSXFragment`:this.error(e,r,`dynamic-expression`,`Markup is not a text value.`,`Use it as content.`);return;case`ArrowFunctionExpression`:case`FunctionExpression`:return this.dynamic(e,r,`A function`,`Write the value directly.`);case`NewExpression`:case`AwaitExpression`:case`AssignmentExpression`:case`UpdateExpression`:case`SequenceExpression`:case`ObjectExpression`:case`ArrayExpression`:case`SpreadElement`:return this.dynamic(e,r,`\`${r.type}\``,`Send the computed value in the payload.`);default:return this.dynamic(e,r,`\`${r.type}\``,`Send the computed value in the payload.`)}}checkedText(e,t,n){return/[-]/.test(n)&&this.error(e,t,`reserved-character`,`This text contains a private-use character the compiler reserves.`,`Remove the characters U+E000 to U+E003.`),n}template(e,t,n){let r=Yp(t,`quasis`),i=Yp(t,`expressions`),a=[],o=!0;for(let[t,s]of r.entries()){let r=nh(s);r!==``&&a.push(this.checkedText(e,s,r));let c=i[t];if(c!==void 0){let t=this.value(e,c,n);t===void 0?o=!1:a.push(t)}}if(o)return rh(a)}call(e,t){let n=J(t,`callee`),r=Yp(t,`arguments`);if(n===void 0)return;let i=Zp(n);if(i.type===`MemberExpression`&&i.computed!==!0){let n=J(i,`object`),a=J(i,`property`),o=a===void 0?void 0:Y(a,`name`);if(n!==void 0&&o!==void 0&&this.isFmt(e,n)){if(!Oc.includes(o)){this.error(e,t,`unknown-formatter`,`\`fmt.${o}\` is not a formatter.`,`Use one of ${Oc.map(e=>`fmt.${e}`).join(`, `)}.`);return}let n=o,[i,a]=qm[n];if(r.length<i||r.length>a){this.error(e,t,`formatter-arguments`,`\`fmt.${n}\` takes ${i===a?i:`${i} to ${a}`} arguments.`,`Check the formatter table in the reference.`);return}let s=[];for(let t of r){let n=Zp(t);if(n.type===`ObjectExpression`){let t=Um(this.options.staticContext,e.module,n);if(!t.ok){this.error(e,n,`dynamic-expression`,`Formatter options are literal.`,`Write plain string and number values.`);return}s.push({lit:t.value});continue}if(n.type===`ArrayExpression`){let t=Um(this.options.staticContext,e.module,n);if(t.ok){s.push({lit:t.value});continue}}let r=this.value(e,t,!0);if(r===void 0)return;s.push(r)}return{format:n,args:s}}if(o!==void 0&&Jm.has(o))return this.dynamic(e,t,`\`.${o}(…)\``,"Send the computed value in the payload and bind it, or format with `fmt.*`.")}if(i.type===`Identifier`&&/^use[A-Z]/.test(Y(i,`name`)??``)){this.error(e,t,`hook-call`,`\`${Y(i,`name`)}\` is a hook, and a template has no state, effects or context.`,`Read the input through the function's parameter; send anything else in the payload.`);return}let a=i.type===`Identifier`?Y(i,`name`)??``:i.type===`MemberExpression`?`${eh(J(i,`object`))}.${Y(J(i,`property`)??i,`name`)??``}`:`a call`;return this.dynamic(e,t,`\`${a}(…)\``,"Send the computed value in the payload and bind it, or format with `fmt.money`, `fmt.number`, `fmt.date`, `fmt.time`, `fmt.plural` or `fmt.list`.")}isFmt(e,t){let n=Zp(t);if(n.type!==`Identifier`)return!1;let r=e.module.imports.get(Y(n,`name`)??``);return r?.kind===`markup`&&r.specifier===`@samva/markup/fmt`}predicate(e,t){let n=Zp(t);if(n.type===`LogicalExpression`){let t=Y(n,`operator`),r=J(n,`left`),i=J(n,`right`);if(r!==void 0&&i!==void 0&&(t===`&&`||t===`||`)){let n=this.predicate(e,r),a=this.predicate(e,i);if(n===void 0||a===void 0)return;if(t===`&&`){let e=e=>`and`in e?e.and:[e];return{and:[...e(n),...e(a)]}}let o=e=>`or`in e?e.or:[e];return{or:[...o(n),...o(a)]}}}if(n.type===`UnaryExpression`&&Y(n,`operator`)===`!`){let t=J(n,`argument`),r=t===void 0?void 0:this.predicate(e,t);return r===void 0?void 0:{not:r}}if(n.type===`BinaryExpression`){let t=Y(n,`operator`)??``,r=Km[t],i=J(n,`left`),a=J(n,`right`);if(r===void 0||i===void 0||a===void 0){this.error(e,n,`dynamic-expression`,t===`==`||t===`!=`?`\`${t}\` coerces types at run time.`:`\`${t}\` is not a comparison the profile reads.`,"Use `===`, `!==`, `<`, `>`, `<=` or `>=`.");return}let o=this.value(e,i,!0),s=this.value(e,a,!0);return o===void 0||s===void 0?void 0:{cmp:r,args:[o,s]}}let r=this.value(e,n,!0);if(r!==void 0)return typeof r==`object`&&r&&`bind`in r?{present:r.bind}:{truthy:r}}jsxChildren(e,t){let n=[];for(let r of Yp(t,`children`))switch(r.type){case`JSXText`:{let t=Ym(Y(r,`value`)??``);t!==``&&n.push(this.checkedText(e,r,t));break}case`JSXExpressionContainer`:{let t=J(r,`expression`);if(t===void 0||t.type===`JSXEmptyExpression`)break;n.push(...this.content(e,t));break}case`JSXElement`:case`JSXFragment`:n.push(...this.element(e,r));break;case`JSXSpreadChild`:this.dynamic(e,r,`A spread child`,`List the children.`)}return n}content(e,t){if(e.depth>Wm)return this.error(e,t,`nesting-limit`,`The template nests too deeply.`,`Flatten it.`),[];let n=Zp(t);switch(n.type){case`JSXElement`:case`JSXFragment`:return this.element(e,n);case`StringLiteral`:{let t=Y(n,`value`)??``;return t===``?[]:[this.checkedText(e,n,t)]}case`NumericLiteral`:return typeof n.value==`number`?[n.value]:[];case`BooleanLiteral`:case`NullLiteral`:return[];case`Identifier`:{let t=Y(n,`name`)??``;if(t===`undefined`)return[];let r=e.env.get(t);if(r?.k===`nodes`)return[...r.nodes];break}case`LogicalExpression`:{let t=Y(n,`operator`),r=J(n,`left`),i=J(n,`right`);if(t===`&&`&&r!==void 0&&i!==void 0){let t=this.predicate(e,r),a=this.content(e,i);return t===void 0?[]:[{if:t,then:a,src:this.src(e.module,n)}]}break}case`ConditionalExpression`:{let t=J(n,`test`),r=J(n,`consequent`),i=J(n,`alternate`);if(t===void 0||r===void 0||i===void 0)return[];let a=this.predicate(e,t),o=this.content(e,r),s=this.content(e,i);return a===void 0?[]:[{if:a,then:o,...s.length===0?{}:{else:s},src:this.src(e.module,n)}]}case`CallExpression`:{let t=J(n,`callee`),r=t===void 0?void 0:Zp(t),i=r===void 0?void 0:J(r,`property`);if(r?.type===`MemberExpression`&&r.computed!==!0&&i!==void 0&&Y(i,`name`)===`map`)return this.each(e,n,r);break}}let r=this.value(e,n,!1);return r===void 0?[]:[r]}freshName(e,t){return this.uniqueName(e,t)}uniqueName(e,t){return e.loops.includes(t)?(this.uniqueId+=1,`${t}_${this.uniqueId}`):t}each(e,t,n){let r=J(n,`object`),i=Yp(t,`arguments`)[0];if(r===void 0||i===void 0)return[];let a=this.filterChain(e,r),o=a===void 0?this.value(e,r,!1):a.list,s=Zp(i);if(s.type!==`ArrowFunctionExpression`&&s.type!==`FunctionExpression`)return this.dynamic(e,i,`A callback that is not an inline function`,"Write `.map((item) => <Row item={item} />)`."),[];if(o===void 0)return[];let c=this.eachOver(e,t,o,s,a?.filters??[]);return c===void 0?[]:[c]}filterChain(e,t){let n=[],r=Zp(t);for(;r.type===`CallExpression`;){let e=J(r,`callee`),t=e===void 0?void 0:Zp(e),i=t===void 0?void 0:J(t,`property`);if(t?.type!==`MemberExpression`||t.computed===!0||i===void 0||Y(i,`name`)!==`filter`)break;let a=Yp(r,`arguments`)[0],o=J(t,`object`);if(a===void 0||o===void 0)return;n.unshift(Zp(a)),r=Zp(o)}if(n.length!==0)return{list:this.value(e,r,!1),filters:n}}whereClause(e,t,n){let r=[];for(let i of n){if(!/Function/.test(i.type)){this.dynamic(e,i,"A `.filter` callback that is not an inline function","Write `.filter((item) => item.done)`.");return}let n=Yp(i,`params`);if(n.length>1){this.error(e,i,`dynamic-expression`,"A `.filter` callback reads the item; its index and the array are not part of the profile.",`Remove the extra parameters.`);return}let a=new Map(e.env);n[0]!==void 0&&this.bindPattern(e,n[0],{k:`path`,path:`$${t}`},a,!1);let o={...e,env:a},s=this.functionExpression(o,i),c=s===void 0?void 0:this.predicate(o,s);if(c===void 0)return;r.push(c)}if(r.length!==0)return r.length===1?r[0]:{and:r}}eachOver(e,t,n,r,i=[],a={}){let o=Yp(r,`params`);if(o.length>2){this.error(e,r,`dynamic-expression`,"`.map` callbacks read the item and its index; a third parameter is the whole array.",`Remove the third parameter.`);return}let s=new Map(e.env),c=[...e.loops],l=``,u,d=o[0];if(d!==void 0){let t=d.type===`Identifier`?Y(d,`name`)??`item`:`item`;l=this.uniqueName({...e,loops:c},a.name??t),c.push(l),this.bindPattern({...e,loops:c},d,{k:`path`,path:`$${l}`},s,!1)}else l=this.uniqueName(e,a.name??`item`),c.push(l);let f=o[1];f!==void 0&&(f.type===`Identifier`?(u=this.uniqueName({...e,loops:c},Y(f,`name`)??`index`),c.push(u),s.set(Y(f,`name`)??`index`,{k:`value`,value:{bind:`$${u}`}})):this.error(e,f,`unsupported-pattern`,`The index is a plain name.`));let p=i.length===0?void 0:this.whereClause(e,l,i);if(i.length>0&&p===void 0)return;let m={...e,env:s,loops:c,depth:e.depth+1},h=this.functionExpression(m,r);if(h===void 0)return;let g=this.content(m,h);return{each:n,as:l,...u===void 0?{}:{index:u},...p===void 0?{}:{where:p},...a.chunk===void 0?{}:{chunk:a.chunk},children:g,src:this.src(e.module,t)}}element(e,t){if(t.type===`JSXFragment`)return this.jsxChildren({...e,depth:e.depth+1},t);let n=J(t,`openingElement`),r=n===void 0?void 0:J(n,`name`);if(n===void 0||r===void 0)return[];let i=Xm(r),a={...e,depth:e.depth+1};return a.depth>Wm?(this.error(e,t,`nesting-limit`,`The template nests too deeply.`,`Flatten it.`),[]):/^[a-z]/.test(i)&&!i.includes(`.`)?this.intrinsic(a,t,n,i):this.component(a,t,n,i)}attributeName(e){let t=J(e,`name`);return t===void 0?``:Xm(t)}intrinsic(e,t,n,r){let i=Wc(r);if(i===void 0){let n=fm(r,Object.keys(Uc));return this.error(e,t,`unsupported-element`,`<${r}> is not part of the supported email vocabulary.`,n===void 0?`Use one of: ${Object.keys(Uc).join(`, `)}.`:`Did you mean <${n}>? Supported elements: ${Object.keys(Uc).join(`, `)}.`),[]}let a={},o,s=[this.findings.locate(e.module.parsed,t)];for(let t of Yp(n,`attributes`)){if(t.type===`JSXSpreadAttribute`){this.dynamic(e,t,`A spread attribute`,`Write each attribute.`);continue}let n=this.attributeName(t),c=J(t,`value`);if(n===`key`)continue;if(n===`ref`||n===`dangerouslySetInnerHTML`||/^on[A-Z]/.test(n)){let r=n===`dangerouslySetInnerHTML`;this.error(e,t,r?`dangerous-html`:n===`ref`?`unsupported-attribute`:`event-handler`,r?"`dangerouslySetInnerHTML` injects unescaped markup.":n===`ref`?"A `ref` needs a running component.":`\`${n}\` is an event handler; email clients strip scripting and Samva refuses it.`,r?`Write the markup as elements.`:`Remove it.`);continue}if(this.reservedAttributes.has(n)){this.error(e,t,`reserved-attribute`,`\`${n}\` is written only by BrandFooter from ${this.options.brandPlugin.specifier}.`,`Render <BrandFooter /> instead of marking an element as the footer.`);continue}if(n===`className`||n===`class`){let t=c===void 0?``:this.classValue(e,c);t!==void 0&&t!==``&&(a.class=t);continue}if(n===`style`){o=this.styleAttribute(e,c);continue}let l;if(c===void 0)l=!0;else if(c.type===`StringLiteral`)l=this.checkedText(e,c,Y(c,`value`)??``);else if(c.type===`JSXExpressionContainer`){let t=J(c,`expression`);l=t===void 0?void 0:this.value(e,t,!1)}else{this.error(e,c,`dynamic-expression`,`An attribute value is text, a number or a binding.`);continue}if(l!==void 0&&l!==!1&&l!==null){if(l===this.options.brandPlugin.unsubscribeUrlPlaceholder){this.error(e,t,`reserved-url`,`That URL is the unsubscribe placeholder only BrandFooter can write.`,`Render <BrandFooter /> instead.`);continue}if(Zm(l)){let a=ml(r,n,l,s);if(a.text===void 0&&a.diagnostics.length===0){let a=fm(n,Object.keys({...i.attributes,id:0,title:0,lang:0,dir:0,role:0}));this.error(e,t,`unsupported-attribute`,`<${r}> does not support the ${n} attribute.`,a===void 0?`Supported: ${Object.keys(i.attributes).join(`, `)||`none`}, plus id, title, lang, dir, role, class, style, data-* and aria-*.`:`Did you mean \`${a}\`?`);continue}this.findings.items.push(...a.diagnostics)}a[n]=l}}let c=i.content===`void`?[]:this.jsxChildren(e,t);return[{el:r,...Object.keys(a).length===0?{}:{attrs:a},...o===void 0?{}:{style:o},...c.length===0?{}:{children:c},src:this.src(e.module,t)}]}classValue(e,t){let n=t.type===`JSXExpressionContainer`?J(t,`expression`):t;if(n===void 0)return;let r=this.classExpression(e,n);return r===void 0&&this.error(e,t,`dynamic-class`,`This class is built at run time, and Tailwind cannot see class names it does not read.`,'Write the classes literally, or choose between literal classes: `input.vip ? "bg-amber-100" : "bg-white"`.'),r}classExpression(e,t){let n=Zp(t);switch(n.type){case`StringLiteral`:return Y(n,`value`)??``;case`NullLiteral`:return``;case`BooleanLiteral`:return``;case`Identifier`:case`MemberExpression`:{if(n.type===`Identifier`&&Y(n,`name`)===`undefined`)return``;let t=this.binding(e,n);return t?.k===`value`&&th(t.value)?t.value:void 0}case`TemplateLiteral`:{let t=Yp(n,`quasis`),r=Yp(n,`expressions`),i=[];for(let[n,a]of t.entries()){let t=nh(a);t!==``&&i.push(t);let o=r[n];if(o!==void 0){let t=this.classExpression(e,o);if(t===void 0)return;i.push(t)}}return rh(i)}case`ConditionalExpression`:{let t=J(n,`test`),r=J(n,`consequent`),i=J(n,`alternate`);if(t===void 0||r===void 0||i===void 0)return;let a=this.predicate(e,t),o=this.classExpression(e,r),s=this.classExpression(e,i);return a===void 0||o===void 0||s===void 0?void 0:{if:a,then:o,else:s}}case`LogicalExpression`:{let t=J(n,`left`),r=J(n,`right`);if(Y(n,`operator`)!==`&&`||t===void 0||r===void 0)return;let i=this.predicate(e,t),a=this.classExpression(e,r);return i===void 0||a===void 0?void 0:{if:i,then:a,else:``}}case`BinaryExpression`:{let t=J(n,`left`),r=J(n,`right`);if(Y(n,`operator`)!==`+`||t===void 0||r===void 0)return;let i=this.classExpression(e,t),a=this.classExpression(e,r);return i===void 0||a===void 0?void 0:rh([i,a])}default:return}}styleAttribute(e,t){let n=t===void 0?void 0:J(t,`expression`),r=n===void 0?void 0:Zp(n);if(r===void 0||r.type!==`ObjectExpression`){t!==void 0&&this.error(e,t,`invalid-style`,"`style` is an object literal of CSS properties.",`Write style={{ backgroundColor: "#fff" }}, or use Tailwind classes.`);return}return this.styleObject(e,r)}styleObject(e,t){let n=[];for(let r of Yp(t,`properties`)){if(r.type!==`ObjectProperty`||r.computed===!0){this.dynamic(e,r,`A spread or computed style entry`,`Write each property.`);continue}let t=J(r,`key`),i=J(r,`value`),a=Xp(t);if(a===void 0||i===void 0)continue;let o=this.value(e,i,!1);o!=null&&n.push([a,o])}return n}component(e,t,n,r){let i=r.split(`.`)[0]??r,a=e.module.imports.get(i),o=e.module.declarations.get(i),s=Yp(n,`attributes`);if(a?.kind===`markup`||a?.kind===`brand`)return zm({lowerer:this,ctx:e,node:t,attributes:s,name:r,binding:a,brand:this.options.brand,brandPlugin:this.options.brandPlugin,channel:this.options.channel});let c;if(a?.kind===`project`){let e=this.options.project.modules.get(a.path);e!==void 0&&(c=this.exportedFunction(e,a.imported,new Set))}else o!==void 0&&(c={module:e.module,value:o.value});return c===void 0||!/Function|Arrow/.test(c.value.type)?(this.error(e,t,`unknown-component`,`<${r}> is not a component the profile can read.`,`Import it from @samva/markup/email, or from a project file that exports it as a function.`),[]):this.partial(e,t,s,r,c.module,c.value)}exportedFunction(e,t,n){let r=`${e.path}\0${t}`;if(n.has(r))return;if(n.add(r),t==="default"){let t=e.defaultExport;if(t===void 0)return;if(t.type===`Identifier`){let n=e.declarations.get(Y(t,`name`)??``);return n===void 0?void 0:{module:e,value:n.value}}return{module:e,value:t}}let i=e.exports.get(t);if(i===void 0)return;let a=e.declarations.get(i);if(a!==void 0)return{module:e,value:a.value};let o=e.imports.get(i);if(o?.kind===`project`){let e=this.options.project.modules.get(o.path);return e===void 0?void 0:this.exportedFunction(e,o.imported,n)}}attributeBindings(e,t){let n=new Map,r=!0;for(let i of t){if(i.type===`JSXSpreadAttribute`){this.dynamic(e,i,`A spread attribute`,`Write each prop.`),r=!1;continue}let t=this.attributeName(i);if(t===`key`)continue;let a=J(i,`value`);if(a===void 0){n.set(t,{k:`value`,value:!0});continue}if(a.type===`StringLiteral`){n.set(t,{k:`value`,value:this.checkedText(e,a,Y(a,`value`)??``)});continue}let o=a.type===`JSXExpressionContainer`?J(a,`expression`):void 0;if(o===void 0){this.error(e,a,`dynamic-expression`,`A prop value is text, a number, a binding or an object.`),r=!1;continue}let s=this.propBinding(e,o);s===void 0?r=!1:n.set(t,s)}return r?n:void 0}propBinding(e,t){let n=Zp(t);if(n.type===`ObjectExpression`){let t=new Map;for(let r of Yp(n,`properties`)){if(r.type!==`ObjectProperty`||r.computed===!0){this.dynamic(e,r,`A spread or computed entry`,`Write each field.`);return}let n=J(r,`key`),i=J(r,`value`),a=n===void 0?void 0:n.type===`Identifier`?Y(n,`name`):Y(n,`value`);if(a===void 0||i===void 0)return;let o=this.propBinding(e,i);if(o===void 0)return;t.set(a,o)}return{k:`object`,fields:t}}if(n.type===`Identifier`||n.type===`MemberExpression`)return this.binding(e,n);if(n.type===`JSXElement`||n.type===`JSXFragment`)return{k:`nodes`,nodes:this.element(e,n)};let r=this.value(e,n,!1);return r===void 0?void 0:{k:`value`,value:r}}partial(e,t,n,r,i,a){let o=`${i.path}#${a.start}`;if(e.stack.includes(o))return this.error(e,t,`recursive-partial`,`<${r}> renders itself, and the compiler inlines partials.`,"Flatten the recursion, or repeat the structure with `.map`."),[];let s=this.attributeBindings(e,n);if(s===void 0)return[];let c=this.jsxChildren(e,t);c.length>0&&s.set(`children`,{k:`nodes`,nodes:c});let l={module:i,env:new Map,stack:[...e.stack,o],loops:e.loops,depth:e.depth+1},u=new Map,d=Yp(a,`params`)[0];if(d!==void 0){let e={k:`object`,fields:s};d.type===`Identifier`?u.set(Y(d,`name`)??`props`,e):this.bindPattern(l,d,e,u,!0)}let f={...l,env:u},p=this.functionExpression(f,a);return p===void 0?[]:this.content(f,p)}},eh=e=>e===void 0?``:e.type===`Identifier`?Y(e,`name`)??``:`…`,th=e=>typeof e==`string`?!0:typeof e!=`object`||!e?!1:`if`in e?th(e.then)&&th(e.else):`concat`in e&&e.concat.every(th),nh=e=>{let t=e.value;if(typeof t!=`object`||!t)return``;let n=t.cooked,r=t.raw;return typeof n==`string`?n:typeof r==`string`?r:``},rh=e=>{let t=[];for(let n of e){let e=t[t.length-1];if(typeof n==`string`&&typeof e==`string`)t[t.length-1]=e+n;else if(typeof n==`object`&&n&&`concat`in n)for(let e of n.concat){let n=t[t.length-1];typeof e==`string`&&typeof n==`string`?t[t.length-1]=n+e:t.push(e)}else t.push(n)}return t.length===0?``:t.length===1?t[0]:{concat:t}},ih=()=>void 0,ah=60,oh=60,sh=1024,ch=25,lh=2,uh=1,dh=10,fh=10,ph=e=>e.type===`JSXIdentifier`?Y(e,`name`)??``:e.type===`JSXMemberExpression`?`${ph(J(e,`object`)??e)}.${Y(J(e,`property`)??e,`name`)??``}`:``,mh=e=>{let t=J(e,`openingElement`),n=t===void 0?void 0:J(t,`name`);return n===void 0?``:ph(n)},hh=e=>{let t=J(e,`openingElement`);return t===void 0?[]:Yp(t,`attributes`)},gh=(e,t,n,r)=>{let i=e.openFunction(t);if(i===void 0)return;let{ctx:a,body:o}=i,s=Zp(o),c=s.type===`JSXElement`?mh(s):``,l=a.module.imports.get(c);if(s.type!==`JSXElement`||l?.kind!==`markup`||l.specifier!==r||l.imported!==n){e.lowerer.error(a,s,`wrong-channel`,`The ${n===`Sms`?`sms`:`whatsapp`} channel returns one <${n}> element imported from ${r}.`,`Write \`import { ${n} } from "${r}"\` and return <${n}>…</${n}>.`);return}return{ctx:a,node:s,local:c}},_h={name:{code:`whatsapp-template-name`,message:`Meta's name for a WhatsApp template comes from the template's handle, not from <WhatsApp>.`,fix:"Remove `name`; rename the template's handle to change its Meta name."}},vh=(e,t,n,r={})=>{let i=new Map;for(let a of hh(t.node)){if(a.type===`JSXSpreadAttribute`){e.lowerer.error(t.ctx,a,`dynamic-expression`,`A spread attribute runs code, and templates render without running code.`,`Write each attribute as a string literal.`);continue}let o=J(a,`name`),s=o===void 0?``:ph(o);if(s===`key`)continue;let c=Object.hasOwn(r,s)?r[s]:void 0;if(c!==void 0){e.lowerer.error(t.ctx,a,c.code,c.message,c.fix);continue}if(!n.includes(s)){e.lowerer.error(t.ctx,a,`unknown-attribute`,`\`${s}\` is not an attribute of this component.`,`The attributes are ${n.join(`, `)}.`);continue}let l=J(a,`value`),u=l?.type===`JSXExpressionContainer`?J(l,`expression`):l;if(u?.type!==`StringLiteral`){e.lowerer.error(t.ctx,a,`dynamic-expression`,`\`${s}\` is fixed when the template is compiled, so it is a string literal.`,`Write ${s}="…".`);continue}i.set(s,Y(u,`value`)??``)}return i},yh=(e,t,n,r,i,a)=>a.includes(i)?!0:(e.lowerer.error(t.ctx,n,`invalid-attribute`,`\`${i}\` is not a ${r} this channel accepts.`,`Use one of ${a.join(`, `)}.`),!1),bh=e=>e.every(e=>rm(e)),xh=e=>e.some(e=>rm(e)?!1:`el`in e||`raw`in e?!0:`if`in e?xh(e.then)||xh(e.else??[]):`each`in e&&xh(e.children)),Sh=(e,t)=>{let n=gh(e,t,`Sms`,`@samva/markup/sms`);if(n===void 0)return;let r=vh(e,n,sm),i=hh(n.node).find(e=>Y(J(e,`name`)??e,`name`)===`category`),a=r.get(`category`);if(a!==void 0&&i!==void 0&&!yh(e,n,i,`category`,a,im))return;let o=e.lowerer.jsxChildren(n.ctx,n.node);return xh(o)&&e.lowerer.error(n.ctx,n.node,`sms-markup`,`An SMS body is plain text, and this one contains an element.`,`Write the message as text and bindings; use a newline in the text for a line break.`),e.schema!==void 0&&e.checks.push(...Sm(e.schema,o,[])),{...a===void 0?{}:{category:a},body:o}},Ch=e=>typeof e==`string`?e.length:typeof e==`number`?String(e).length:typeof e==`object`&&e&&`concat`in e?e.concat.reduce((e,t)=>e+Ch(t),0):0,wh={url:0,phone:0,quickReply:0,total:0},Th=e=>{let t=wh;for(let n of e){let e;if(`if`in n){let t=Th(n.then),r=Th(n.else??[]);e={url:Math.max(t.url,r.url),phone:Math.max(t.phone,r.phone),quickReply:Math.max(t.quickReply,r.quickReply),total:Math.max(t.total,r.total)}}else e={url:+(n.type===`url`),phone:+(n.type===`phone`),quickReply:+(n.type===`quick-reply`),total:1};t={url:t.url+e.url,phone:t.phone+e.phone,quickReply:t.quickReply+e.quickReply,total:t.total+e.total}}return t},Eh=e=>e.flatMap(e=>{if(`if`in e)return[{if:e.if,then:Eh(e.then),...e.else===void 0?{}:{else:Eh(e.else)},...e.src===void 0?{}:{src:e.src}}];switch(e.type){case`quick-reply`:return[e.text];case`url`:return[e.text,e.url];case`phone`:return[e.text,e.phone];case`copy-code`:return[e.code]}}),Dh=(e,t)=>{let n=gh(e,t,`WhatsApp`,`@samva/markup/whatsapp`);if(n===void 0)return;let{lowerer:r}=e,{ctx:i}=n,a=vh(e,n,cm,_h);for(let e of[`category`,`language`])a.has(e)||r.error(i,n.node,`missing-attribute`,`<WhatsApp> needs \`${e}\`.`,e===`category`?`Write category="utility" (${am.join(`, `)}).`:`Write language="en_US".`);let o=a.get(`category`),s=hh(n.node).find(e=>Y(J(e,`name`)??e,`name`)===`category`);if(o!==void 0&&s!==void 0&&!yh(e,n,s,`category`,o,am))return;let c=new Map;for(let e of Yp(n.node,`children`)){if(e.type===`JSXText`){(Y(e,`value`)??``).trim()!==``&&r.error(i,e,`whatsapp-structure`,`Text sits inside Header, Body, Footer or Buttons, not directly in <WhatsApp>.`,`Move it into <WhatsApp.Body>.`);continue}let t=e.type===`JSXElement`?mh(e):``,a=t.startsWith(`${n.local}.`)?t.slice(n.local.length+1):``;if(![`Header`,`Body`,`Footer`,`Buttons`].includes(a)){r.error(i,e,`whatsapp-structure`,`<WhatsApp> holds <WhatsApp.Header>, <WhatsApp.Body>, <WhatsApp.Footer> and <WhatsApp.Buttons>.`,`Wrap the content in one of them.`);continue}if(c.has(a)){r.error(i,e,`whatsapp-structure`,`<WhatsApp.${a}> appears twice.`,`A WhatsApp template has at most one of each part.`);continue}c.set(a,e)}let l=[],u=(e,t,n,a)=>{n>a&&r.findings.add(i.module.parsed,t,`whatsapp-length`,`The ${e} is at least ${n} characters, and Meta allows ${a}.`,`Shorten the ${e}.`,`warning`)},d=(e,t,n)=>{let a=r.jsxChildren(i,t);if(!bh(a)){r.error(i,t,`whatsapp-conditional`,`A WhatsApp ${e} cannot branch or contain elements: Meta registers its text once.`,`Choose the wording as a parameter in the payload, or write separate templates.`);return}return u(e,t,a.reduce((e,t)=>e+(rm(t)?Ch(t):0),0),n),l.push(...a),a},f,p=c.get(`Header`);if(p!==void 0){let e=hh(p).find(e=>Y(J(e,`name`)??e,`name`)===`type`),t=e===void 0?void 0:J(e,`value`),n=t?.type===`JSXExpressionContainer`?J(t,`expression`):t,a=n?.type===`StringLiteral`?Y(n,`value`)??`text`:`text`;if(e!==void 0&&n?.type!==`StringLiteral`)r.error(i,e,`dynamic-expression`,"`type` is fixed when the template is compiled, so it is a string literal.",`Write type="image".`);else if(e!==void 0&&!om.includes(a))r.error(i,e,`invalid-attribute`,`\`${a}\` is not a header type.`,`Use one of ${om.join(`, `)}.`);else{let e=a,t=d(`header`,p,e===`text`?ah:1/0);t!==void 0&&(e===`text`?um(t).params.length>1&&r.error(i,p,`whatsapp-header-variables`,`A WhatsApp header text takes at most one variable.`,`Keep one binding in the header and move the rest to the body.`):t.length!==1&&r.error(i,p,`whatsapp-header-media`,`A ${e} header is one URL.`,`Write the media URL as the only child: a literal or one binding.`),f={type:e,content:t})}}let m=[],h=c.get(`Body`);if(h===void 0)r.error(i,n.node,`whatsapp-body-required`,`A WhatsApp template needs a body.`,`Add <WhatsApp.Body>…</WhatsApp.Body>.`);else{let e=d(`body`,h,sh);m=e??[],e!==void 0&&e.length===0&&r.error(i,h,`whatsapp-body-required`,`The WhatsApp body is empty.`,`Write the message text.`)}let g=c.get(`Footer`),_=g===void 0?void 0:d(`footer`,g,oh),v=c.get(`Buttons`),y=v===void 0?void 0:kh(e,i,n.local,v);if(y!==void 0){let e=Th(y),t=(e,t,n)=>{t>n&&r.error(i,v,`whatsapp-button-limit`,`A WhatsApp template allows ${n} ${e}, and these conditions can produce ${t}.`,`Remove ${t-n}, or split the template.`)};t(`URL buttons`,e.url,lh),t(`phone buttons`,e.phone,uh),t(`quick-reply buttons`,e.quickReply,dh),t(`buttons in all`,e.total,fh),l.push(...Eh(y))}if(e.schema!==void 0&&e.checks.push(...Sm(e.schema,l,[])),o!==void 0&&a.has(`language`))return{category:o,language:a.get(`language`),...f===void 0?{}:{header:f},body:m,..._===void 0?{}:{footer:_},...y===void 0?{}:{buttons:y}}},Oh=[`UrlButton`,`QuickReplyButton`,`PhoneButton`,`CopyCodeButton`],kh=(e,t,n,r)=>{let{lowerer:i}=e,a=(e,n)=>{let r=i.jsxChildren(t,e);if(!bh(r)||r.length===0){i.error(t,e,r.length===0?`whatsapp-button-text`:`whatsapp-conditional`,r.length===0?`A button needs its ${n}.`:`A button ${n} cannot branch or contain elements.`,`Write the ${n} as text between the tags.`);return}let a=rh(r);return n===`label`&&Ch(a)>ch&&i.findings.add(t.module.parsed,e,`whatsapp-length`,`The button label is at least ${Ch(a)} characters, and Meta allows ${ch}.`,`Shorten the label.`,`warning`),a},o=(e,n)=>{let r=i.attributeBindings(t,hh(e));if(r===void 0)return;let a=hh(e).map(e=>Y(J(e,`name`)??e,`name`));for(let r of a)r!==void 0&&r!==n&&r!==`key`&&i.error(t,e,`unknown-attribute`,`\`${r}\` is not an attribute of this button.`,n===void 0?`Remove it.`:`The attribute is ${n}.`);if(n===void 0)return;let o=r.get(n),s=o===void 0?void 0:tm(o);return s===void 0&&i.error(t,e,`missing-attribute`,`This button needs \`${n}\`.`,`Write ${n}="…" or ${n}={input.field}.`),s},s=e=>{let r=mh(e);switch(r.startsWith(`${n}.`)?r.slice(n.length+1):``){case`UrlButton`:{let t=o(e,`url`),n=a(e,`label`);return t===void 0||n===void 0?void 0:{type:`url`,text:n,url:t}}case`PhoneButton`:{let t=o(e,`phone`),n=a(e,`label`);return t===void 0||n===void 0?void 0:{type:`phone`,text:n,phone:t}}case`QuickReplyButton`:{o(e,void 0);let t=a(e,`label`);return t===void 0?void 0:{type:`quick-reply`,text:t}}case`CopyCodeButton`:{let t=a(e,`code`);return t===void 0?void 0:{type:`copy-code`,code:t}}default:i.error(t,e,`whatsapp-structure`,`<WhatsApp.Buttons> holds ${Oh.map(e=>`<WhatsApp.${e}>`).join(`, `)}.`,`Use one of the button components.`);return}},c=e=>{let n=Zp(e);switch(n.type){case`JSXElement`:{let e=s(n);return e===void 0?[]:[e]}case`JSXFragment`:return l(n);case`NullLiteral`:case`BooleanLiteral`:return[];case`LogicalExpression`:{let e=J(n,`left`),r=J(n,`right`);if(Y(n,`operator`)===`&&`&&e!==void 0&&r!==void 0){let a=i.predicate(t,e),o=c(r);return a===void 0?[]:[{if:a,then:o,src:i.src(t.module,n)}]}break}case`ConditionalExpression`:{let e=J(n,`test`),r=J(n,`consequent`),a=J(n,`alternate`);if(e===void 0||r===void 0||a===void 0)return[];let o=i.predicate(t,e),s=c(r),l=c(a);return o===void 0?[]:[{if:o,then:s,...l.length===0?{}:{else:l},src:i.src(t.module,n)}]}}return i.error(t,n,`dynamic-expression`,`Buttons are fixed by the template, and this expression builds them at render time.`,"List each button; wrap one in `condition && <WhatsApp.UrlButton … />` to make it optional."),[]},l=e=>{let n=[];for(let r of Yp(e,`children`))if(r.type===`JSXText`)(Y(r,`value`)??``).trim()!==``&&i.error(t,r,`whatsapp-structure`,`Text cannot sit between buttons.`,`Put the label inside the button.`);else if(r.type===`JSXExpressionContainer`){let e=J(r,`expression`);e!==void 0&&e.type!==`JSXEmptyExpression`&&n.push(...c(e))}else n.push(...c(r));return n};return l(r)},Ah=e=>{let t=e.fields.get(`sms`),n=e.fields.get(`whatsapp`),r=t===void 0?void 0:Sh(e,t),i=n===void 0?void 0:Dh(e,n);return{...r===void 0?{}:{sms:r},...i===void 0?{}:{whatsapp:i}}},jh=8,Mh=(e,t)=>{if(`leaf`in e){let n=e.leaf,r=e=>`leaf`in e?{leaf:n+e.leaf}:{pred:e.pred,then:r(e.then),else:r(e.else)};return r(t)}return{pred:e.pred,then:Mh(e.then,t),else:Mh(e.else,t)}},Nh=e=>{if(typeof e==`string`)return{leaf:e};if(typeof e==`object`&&e){if(`if`in e){let t=Nh(e.then),n=Nh(e.else);return t===void 0||n===void 0?void 0:{pred:e.if,then:t,else:n}}if(`concat`in e){let t={leaf:``};for(let n of e.concat){let e=Nh(n);if(e===void 0)return;t=Mh(t,e)}return t}}},Ph=e=>`leaf`in e?[e.leaf]:[...Ph(e.then),...Ph(e.else)],Fh=(e,t,n={next:0})=>{if(`leaf`in e)return t(n.next++);let r=Fh(e.then,t,n),i=Fh(e.else,t,n);return JSON.stringify(r)===JSON.stringify(i)?r:{if:e.pred,then:r,else:i}},Ih=(e,t)=>{for(let n of e)rm(n)||(`el`in n?(t.push({kind:`el`,el:n}),Ih(n.children??[],t)):`if`in n?(Ih(n.then,t),Ih(n.else??[],t)):`each`in n?Ih(n.children,t):`raw`in n&&t.push({kind:`raw`,raw:n}))},Lh=(e,t)=>t.map(t=>typeof t==`string`?t:e.value(`attr`in t?t.attr:t.text)).join(``),Rh=(e,t,n)=>{let r=[];Ih([e],r);let i=new Dm,a=r.map(e=>{if(e.kind!==`el`)return;let t=e.el.attrs?.class;if(t===void 0)return;let n=Nh(t);if(n!==void 0)return n}),o=a.map(e=>e===void 0?1:Ph(e).length);for(let[t,i]of o.entries())if(i>jh){let a=r[t],o=a?.kind===`el`?n.locate(a.el.src):void 0;return n.report({code:`too-many-class-variants`,severity:`error`,message:`This class list chooses between ${i} literal lists; the compiler resolves at most ${jh}.`,fix:`Split the choice into fewer conditions, or move part of it to a partial.`,origins:o===void 0?[]:[o]}),{root:e,headCss:``,fontFaceCss:``}}let s=Math.max(1,...o),c=(e,t,r)=>e.flatMap(e=>{if(rm(e))return[];if(`el`in e){let o=r.next++,s=a[o],l=s===void 0?void 0:Ph(s),u={};for(let[t,n]of Object.entries(e.attrs??{}))t!==`class`&&(typeof n==`string`||typeof n==`number`?u[t]=n:typeof n==`object`&&n&&(u[t]=i.value(n)));l===void 0?e.attrs?.class!==void 0&&(u.class=i.value(e.attrs.class)):u.class=l[Math.min(t,l.length-1)];let d=e.style;if(Array.isArray(d)){let e={};for(let[t,n]of d)n!==null&&typeof n!=`boolean`&&(e[t]=typeof n==`number`?n:i.value(n));u.style=e}else if(typeof d==`string`&&d!==``){let e={};for(let t of d.split(`;`)){let n=t.indexOf(`:`);n>0&&(e[t.slice(0,n)]=t.slice(n+1))}u.style=e}let f=n.locate(e.src);return[cs.Element({tag:e.el,props:u,children:c(e.children??[],t,r),origins:f===void 0?[]:[f],authored:!0})]}return`if`in e?[cs.Fragment({children:[...c(e.then,t,r),...c(e.else??[],t,r)]})]:`each`in e?[cs.Fragment({children:c(e.children,t,r)})]:`raw`in e?(r.next++,[cs.Raw({html:Lh(i,e.raw),text:``,origins:[]})]):[]}),l=(e,t)=>{for(let n of e)n.type===`Fragment`?l(n.children,t):n.type===`Raw`?t.raws.push(n.html):n.type===`Element`&&(t.styles.push(n.props.style===void 0?void 0:n.props.style),t.bgcolors.push(typeof n.props.bgcolor==`string`?n.props.bgcolor:void 0),l(n.children,t))},u=[],d=``,f=``,p=new Set;for(let r=0;r<s;r++){let i=pu(c([e],r,{next:0})[0]??cs.Fragment({children:[]}),t);r===0&&(d=i.headCss,f=i.fontFaceCss);for(let e of i.diagnostics){let t=`${e.code}\0${e.message}`;p.has(t)||(p.add(t),n.report(e))}let a={styles:[],bgcolors:[],raws:[]};l([i.tree],a),u.push(a)}let m=(e,t)=>{if(e===void 0)return``;let r=Object.entries(e);if(r.length===0)return``;let a=n.locate(t.src),o=r.some(([,e])=>e.includes(``)),s=pl(Object.fromEntries(r.filter(([,e])=>!e.includes(``))),a===void 0?[]:[a]);for(let e of s.diagnostics)n.report(e);return o?r.map(([e,t])=>[e,i.toValue(t)??t]):s.css},h=0,g=0,_=0,v=e=>e.map(e=>{if(rm(e))return e;if(`el`in e){let t=h++,n=g++,r=a[t],o=u[0],s=o?.styles[n],c=r!==void 0&&Ph(r).length>1?Fh(r,t=>m(u[Math.min(t,u.length-1)]?.styles[n],e)):m(s,e),l=o?.bgcolors[n],d=typeof e.attrs?.bgcolor==`string`&&l!==void 0&&l!==e.attrs.bgcolor?{...e.attrs,bgcolor:i.toValue(l)??l}:e.attrs,f=v(e.children??[]),{style:p,children:_,attrs:y,...b}=e;return{...b,...d===void 0?{}:{attrs:d},...c===``?{}:{style:c},...f.length===0?{}:{children:f}}}if(`if`in e){let t=v(e.then),n=v(e.else??[]);return{...e,then:t,...e.else===void 0?{}:{else:n}}}if(`each`in e)return{...e,children:v(e.children)};if(`raw`in e){h++;let t=u[0]?.raws[_++];return t===void 0?e:{...e,raw:Am(i,t)}}return e});return{root:v([e])[0]??e,headCss:d,fontFaceCss:f}},zh=`defineTemplate`,Bh=[`email`,`sms`,`whatsapp`],Vh=(e,t)=>{let n=e.entry,r=n.defaultExport;r?.type===`Identifier`&&(r=n.declarations.get(Y(r,`name`)??``)?.value);let i=(e,i,a=`no-template`)=>{t.add(n.parsed,r??n.parsed.program,a,e,i)};if(r===void 0||r.type!==`CallExpression`)return i(`The entry must default-export defineTemplate({ ... }).`,"Write `export default defineTemplate({ id, schema, fixtures, email })`.");let a=J(r,`callee`),o=a===void 0?void 0:Y(a,`name`),s=o===void 0?void 0:n.imports.get(o);if(o===`defineEmail`)return i("`defineEmail` runs a render function, which the static profile does not read.","Use `defineTemplate` from @samva/markup with `email: { subject, preheader, body }`.",`legacy-definition`);if(s?.kind!==`markup`||s.imported!==zh)return i(`The entry must default-export defineTemplate({ ... }) imported from @samva/markup.`,'Add `import { defineTemplate } from "@samva/markup";`.');let c=Yp(r,`arguments`)[0],l=c===void 0?void 0:Zp(c);if(l===void 0||l.type!==`ObjectExpression`)return i(`defineTemplate takes one object literal.`,`Write defineTemplate({ id, schema, fixtures, email }).`);let u=new Map;for(let e of Yp(l,`properties`)){let r=Vm(e),i=J(e,`value`);if(r===void 0||i===void 0){t.add(n.parsed,e,`dynamic-definition`,`A definition field is written out, not spread or computed.`,"Write each field as `name: value`.");continue}u.set(r,i)}return{module:n,call:r,fields:u}},Hh=(e,t,n)=>{let r=Zp(n);if(/Function/.test(r.type))return{module:t,fn:r};if(r.type===`Identifier`){let n=Y(r,`name`)??``,i=t.declarations.get(n);if(i!==void 0)return Hh(e,t,i.value);let a=t.imports.get(n);if(a?.kind===`project`){let t=e.modules.get(a.path);if(t===void 0)return;let n=a.imported==="default"?void 0:t.exports.get(a.imported);if(a.imported==="default"&&t.defaultExport!==void 0)return Hh(e,t,t.defaultExport);let r=n===void 0?void 0:t.declarations.get(n);return r===void 0?void 0:Hh(e,t,r.value)}}},Uh=e=>{let t=[],n=new Set,r=i=>{if(!n.has(i.path)){n.add(i.path);for(let n of i.ordered)if(n.kind===`css`)t.includes(n.path)||t.push(n.path);else{let t=e.modules.get(n.path);t!==void 0&&r(t)}}};return r(e.entry),t},Wh=(e,t,n)=>{let r=!1,i=e=>e.map(e=>{if(r||rm(e))return e;if(`el`in e)return t(e)?(r=!0,n(e)):{...e,...e.children===void 0?{}:{children:i(e.children)}};if(`if`in e){let t=i(e.then),n=i(e.else??[]);return{...e,then:t,...e.else===void 0?{}:{else:n}}}return`each`in e?{...e,children:i(e.children)}:e});return{nodes:i(e),done:r}},Gh={raw:[`<!--[if !mso]><!-->`]},Kh={raw:[`<!--<![endif]-->`]},qh=(e,t,n={},r=[])=>({ir:e.blocking?void 0:t,fixtures:n,assets:r,diagnostics:e.items}),Jh=(e,t,n,r)=>{let i=(e,t={},i=r.assets)=>qh(n,e,t,i),a=r.urlFor,o={project:t,assetUrl:a},s=Vh(t,n);if(s===void 0)return i(void 0);let{module:c,fields:l}=s,u=e=>l.get(e)??s.call,d=l.has(`id`)?Um(o,c,l.get(`id`)):void 0;d===void 0||!d.ok||typeof d.value!=`string`?n.add(c.parsed,u(`id`),`invalid-template-id`,`The template id is a string literal.`,`Write id: "order-shipped".`):Dc.test(d.value)||n.add(c.parsed,u(`id`),`invalid-template-id`,`Template id ${JSON.stringify(d.value)} is not lowercase kebab-case.`,`Write lowercase letters and digits joined by single hyphens, for example "order-shipped".`);let f=d!==void 0&&d.ok&&typeof d.value==`string`?d.value:``,p,m=l.get(`schema`);if(m===void 0)n.add(c.parsed,s.call,`missing-schema`,`The template declares no schema.`,"Add `schema: jsonSchema<Input>({ ... })`.");else{let t=Um(o,c,m);t.ok&&typeof t.value==`object`&&t.value!==null?p=t.value:e.schema===void 0?n.add(t.ok?c.parsed:t.module.parsed,t.ok?m:t.node,`schema-not-static`,`The schema cannot be read without running it${t.ok?``:` (${t.reason})`}.`,'Write the schema as a literal: `jsonSchema<Input>({ type: "object", properties: { … } })`, or compile with the schema a library already converted.'):p={...e.schema}}let h=()=>!0;if(p!==void 0)try{let e=Tc(Cc(p));h=e.validate,p=e.schema}catch(e){if(!(e instanceof TypeError))throw e;n.add(c.parsed,u(`schema`),`invalid-schema`,e.message,`Use only the JSON Schema keywords the README lists.`),p=void 0}let g={},_=l.get(`fixtures`);if(_===void 0)n.add(c.parsed,s.call,`missing-fixtures`,`The template declares no fixtures.`,"Add `fixtures: { default: { … } }`.");else{let e=Um(o,c,_);if(!e.ok)n.add(e.module.parsed,e.node,`fixtures-not-static`,`Fixtures are data, and this one is computed (${e.reason}).`,`Write each fixture as a literal object; an imported asset is allowed.`);else if(typeof e.value!=`object`||e.value===null||Object.keys(e.value).length===0)n.add(c.parsed,_,`missing-fixtures`,`The template declares no fixtures.`,"Declare at least one: `fixtures: { default: { … } }`.");else{let t=Zp(_),r=new Map;if(t.type===`ObjectExpression`)for(let e of Yp(t,`properties`)){let t=Vm(e);t!==void 0&&r.set(t,J(e,`key`)??e)}for(let[t,i]of Object.entries(e.value)){if(!Ec.test(t)){n.add(c.parsed,r.get(t)??_,`invalid-fixture-name`,`Fixture key ${JSON.stringify(t)} is not one path segment.`,"Use letters, digits, `.`, `_` and `-`, starting with a letter or digit.");continue}if(g[t]=i,p!==void 0&&!h(i)){let e=h.errors?.at(-1)??h.errors?.[0];n.add(c.parsed,r.get(t)??_,`fixture-invalid`,`Fixture ${JSON.stringify(t)} does not match the schema${e===void 0?``:`: ${e.instanceLocation===`#`||e.instanceLocation===void 0?``:`${e.instanceLocation.replace(/^#/,``)} `}${e.error??`is invalid`}`}.`,`Change the fixture, or the schema, so a fixture is a payload a send could make.`)}}}}let v=l.has(`locale`)?Um(o,c,l.get(`locale`)):void 0,y=v?.ok===!0&&typeof v.value==`string`?v.value:void 0;l.has(`locale`)&&y===void 0&&n.add(c.parsed,u(`locale`),`invalid-locale`,`The locale is a string literal.`,`Write locale: "en-US".`);let b=new $m({project:t,findings:n,staticContext:o,assetUrl:a,brand:e.brand,brandPlugin:e.brandPlugin??jc,channel:ih}),x=e=>({module:e,env:new Map,stack:[],loops:[],depth:0}),S=e=>{let r=Hh(t,c,e);if(r===void 0){n.add(c.parsed,e,`not-a-function`,`A channel field is a function of the input, written in place or declared in the project.`,"Write `(input) => …`.");return}let i=x(r.module),a=new Map,o=Yp(r.fn,`params`)[0];o!==void 0&&b.bindPattern(i,o,{k:`path`,path:``},a,!1);let s={...i,env:a},l=b.functionExpression(s,r.fn);return l===void 0?void 0:{ctx:s,body:l}};for(let e of l.keys())[`id`,`schema`,`fixtures`,`locale`,...Bh].includes(e)||n.add(c.parsed,u(e),`unknown-field`,`\`${e}\` is not a defineTemplate field.`,`The fields are id, schema, fixtures, locale, email, sms and whatsapp.`);let C,w=[],T=l.get(`email`),E;if(T!==void 0){let i=Zp(T),a=new Map;if(i.type===`ObjectExpression`)for(let e of Yp(i,`properties`)){let t=Vm(e),n=J(e,`value`);t!==void 0&&n!==void 0&&a.set(t,n)}else n.add(c.parsed,T,`invalid-channel`,"The email channel is an object: `{ subject, preheader, body }`.",`Write email: { subject: …, body: … }.`);for(let e of a.keys())[`subject`,`preheader`,`body`].includes(e)||n.add(c.parsed,a.get(e),`unknown-field`,`\`${e}\` is not an email field.`,`The fields are subject, preheader and body.`);let o=e=>{let t=a.get(e);if(t===void 0)return;let n=S(t);return n===void 0?void 0:b.value(n.ctx,n.body,!1)},s=a.has(`subject`)?o(`subject`):void 0;!a.has(`subject`)&&i.type===`ObjectExpression`&&n.add(c.parsed,T,`missing-subject`,`The email channel needs a subject.`,"Add `subject: (input) => …`.");let l=o(`preheader`),d,f=a.get(`body`);if(f===void 0&&i.type===`ObjectExpression`)n.add(c.parsed,T,`missing-body`,`The email channel needs a body.`,"Add `body: (input) => (<Email>…</Email>)`.");else if(f!==void 0){let e=S(f);if(e!==void 0){let t=b.content(e.ctx,e.body);t.length===1?d=t[0]:n.blocking||n.add(e.ctx.module.parsed,e.body,`multiple-roots`,t.length===0?`The email body renders nothing.`:`The email body renders more than one root.`,`Wrap the body in a single element such as <Email>.`)}}if(s!==void 0&&d!==void 0){let i=[];r.tailwindSheet!==void 0&&i.push(r.tailwindSheet);for(let e of Uh(t)){let t=r.stylesheets.get(e);t!==void 0&&i.push(t)}let a=[e.entry,...b.sources],o=Rh(d,qp(i),{locate:t=>{if(t!==void 0)return{fileName:a[t[2]??0]??e.entry,lineNumber:t[0],columnNumber:t[1]}},report:e=>{n.items.push(e)}}),f=o.root;if(o.headCss!==``||o.fontFaceCss!==``){let e=[...o.headCss===``?[]:[{el:`style`,children:[o.headCss]}],...o.fontFaceCss===``?[]:[Gh,{el:`style`,children:[o.fontFaceCss]},Kh]],t=Wh([f],e=>e.el===`head`,t=>({...t,children:[...t.children??[],...e]}));t.done?f=t.nodes[0]??f:n.report({code:`missing-head`,severity:`error`,message:`Styles that cannot be inlined — media queries, dark-scheme rules and pseudo-selectors — need a <head> to live in.`,fix:`Wrap the message in <Email>, or write those declarations as inline styles.`,origins:[]})}if(l!==void 0){let e=Wh([f],e=>e.el===`body`,e=>({...e,children:[{preheader:!0},...e.children??[]]}));e.done?f=e.nodes[0]??f:n.add(c.parsed,u(`email`),`preheader-without-shell`,`A preheader is the hidden inbox preview inside <body>, and this body has no <Email> shell.`,`Wrap the body in <Email>.`)}Cm([f],e=>w.push(e)),p!==void 0&&w.push(...Sm(p,[f],[s,...l===void 0?[]:[l]])),E={subject:s,...l===void 0?{}:{preheader:l},body:f}}}let D=Ah({lowerer:b,findings:n,fields:l,module:c,openFunction:S,checks:w,schema:p}),O=[e.entry,...b.sources];for(let t of w){let r=t.src,i=O[r?.[2]??0]??e.entry;n.report({code:t.code,severity:`error`,message:t.message,...t.fix===void 0?{}:{fix:t.fix},origins:r===void 0?[{fileName:e.entry,lineNumber:1,columnNumber:1}]:[{fileName:i,lineNumber:r[0],columnNumber:r[1]}]})}return p!==void 0&&f!==``&&(E!==void 0||D.sms!==void 0||D.whatsapp!==void 0)?C={sml:1,template:f,...y===void 0?{}:{locale:y},sources:O,...E===void 0?{}:{email:E},...D.sms===void 0?{}:{sms:D.sms},...D.whatsapp===void 0?{}:{whatsapp:D.whatsapp},schema:p}:T===void 0&&!l.has(`sms`)&&!l.has(`whatsapp`)&&n.add(c.parsed,s.call,`no-channel`,`The template declares no channel.`,"Add `email`, `sms` or `whatsapp`."),i(C,g)},Yh=`@samva/markup`,Xh=`@samva/markup/`,Zh={"@samva/markup/email/components":`@samva/markup/email`},Qh=[`.tsx`,`.ts`],$h=(e,t,n)=>{let r=Gp(Wp(e),t.replace(/[?#].*$/,``));if(r!==void 0){if(Object.hasOwn(n,r))return r;for(let e of Qh)if(Object.hasOwn(n,`${r}${e}`))return`${r}${e}`;for(let e of Qh)if(Object.hasOwn(n,`${r}/index${e}`))return`${r}/index${e}`}},eg=e=>/\.[cm]?[jt]sx?$/.test(e),tg=e=>e.type===`Identifier`?[Y(e,`name`)??``]:[],ng=(e,t,n,r)=>{let i=new Map,a=new Set,o=new Set,s=!1,c=t=>{let l=i.get(t);if(l!==void 0)return l;if(o.has(t))return;let u=e[t];if(u===void 0)return;let d=typeof u==`string`?u:new TextDecoder().decode(u),f;try{f=$p(t,d)}catch(e){if(!(e instanceof Qp))throw e;n.items.push({code:`syntax-error`,severity:`error`,message:e.message,origins:[{fileName:t,lineNumber:e.line,columnNumber:e.column}]}),s=!0;return}o.add(t);let p=new Map,m=[],h=new Map,g=new Map,_,v=e=>{if(e.type===`VariableDeclaration`)for(let t of Yp(e,`declarations`)){let n=J(t,`id`),r=J(t,`init`);if(n!==void 0&&r!==void 0)for(let t of tg(n))h.set(t,{value:Zp(r),node:e})}else if(e.type===`FunctionDeclaration`){let t=Y(J(e,`id`)??e,`name`);t!==void 0&&h.set(t,{value:e,node:e})}};for(let i of Yp(f.program,`body`))switch(i.type){case`ImportDeclaration`:{let o=Y(J(i,`source`)??i,`value`)??``,c=Y(i,`importKind`)===`type`,l=Yp(i,`specifiers`);if(c)break;let u=e=>Y(J(e,`local`)??e,`name`)??``,d=e=>{if(e.type===`ImportDefaultSpecifier`)return`default`;if(e.type===`ImportNamespaceSpecifier`)return`*`;let t=J(e,`imported`);return t===void 0?u(e):Y(t,`name`)??Y(t,`value`)??u(e)},h=Zh[o];if(h!==void 0){n.add(f,J(i,`source`)??i,`moved-import`,`\`${o}\` moved to \`${h}\`; the imported names are unchanged.`,`Import from "${h}".`),s=!0;break}if(o===Yh||o.startsWith(Xh)){for(let e of l)Y(e,`importKind`)!==`type`&&p.set(u(e),{kind:`markup`,specifier:o,imported:d(e),node:e});break}if(Pc(o,r.brandPlugin)!==void 0){for(let e of l)Y(e,`importKind`)!==`type`&&p.set(u(e),{kind:`brand`,specifier:o,imported:d(e),node:e});break}if(!/^\.{0,2}\//.test(o)){n.add(f,i,`non-project-import`,`\`${o}\` is not part of the project; templates import only @samva/markup and files inside the project.`,`Remove the import, or copy the code you need into a project file.`),s=!0;break}let g=$h(t,o,e);if(g===void 0&&r.lenient===!0){let e=Gp(Wp(t),o.replace(/[?#].*$/,``)),n=e!==void 0&&gu(e),r=e!==void 0&&(eg(e)||!/\.[a-z0-9]+$/i.test(e));if(e!==void 0&&(e.endsWith(`.css`)||n||r)){if(!e.endsWith(`.css`))for(let t of l)n?p.set(u(t),{kind:`asset`,path:e,node:t}):(a.add(u(t)),p.set(u(t),{kind:`project`,path:e,imported:d(t),node:t}));break}}if(g===void 0){n.add(f,i,`unresolved-import`,`\`${o}\` names no file in the project.`,`Check the path and the file extension.`),s=!0;break}if(g.endsWith(`.css`)){m.push({kind:`css`,path:g});break}if(gu(g)){for(let e of l)p.set(u(e),{kind:`asset`,path:g,node:e});break}if(eg(g)){m.push({kind:`script`,path:g});for(let e of l)p.set(u(e),{kind:`project`,path:g,imported:d(e),node:e});break}n.add(f,i,`unresolved-import`,`\`${o}\` is a file type templates cannot import.`,`Import a script, a stylesheet or an asset such as .png or .woff2.`),s=!0;break}case`ExportNamedDeclaration`:{let e=J(i,`declaration`);if(e!==void 0){if(v(e),e.type===`VariableDeclaration`)for(let t of Yp(e,`declarations`))for(let e of tg(J(t,`id`)??t))g.set(e,e);else if(e.type===`FunctionDeclaration`){let t=Y(J(e,`id`)??e,`name`);t!==void 0&&g.set(t,t)}}else for(let e of Yp(i,`specifiers`)){let t=J(e,`exported`),n=J(e,`local`),r=t===void 0?void 0:Y(t,`name`)??Y(t,`value`),i=n===void 0?void 0:Y(n,`name`);r!==void 0&&i!==void 0&&g.set(r,i)}break}case`ExportDefaultDeclaration`:{let e=J(i,`declaration`);e!==void 0&&(_=Zp(e));break}case`VariableDeclaration`:case`FunctionDeclaration`:v(i)}let y={path:t,parsed:f,imports:p,ordered:m,declarations:h,exports:g,defaultExport:_};i.set(t,y),o.delete(t);for(let e of m)e.kind===`script`&&c(e.path);return y},l=c(t);if(!(l===void 0||s))return{modules:i,entry:l,unresolved:a}},rg=`template.tsx`,ig=new Set([`brand-unavailable`,`unmatched-class`]),ag=(e,t)=>typeof e==`string`?{[t]:e}:e,og=(e,t=rg,n=jc)=>{let r=new Kp,i=ng(ag(e,t),t,r,{brandPlugin:n,lenient:!0});if(i===void 0)return r.items;Jh({entry:t,brand:void 0,brandPlugin:n},i,r,{assets:[],stylesheets:new Map,tailwindSheet:void 0,urlFor:e=>`https://assets.invalid/${e}`});let a=[...i.unresolved];return r.items.filter(e=>!ig.has(e.code)&&!e.code.startsWith(`tailwind-`)&&!a.some(t=>e.message.includes(`<${t}`)||e.message.includes(`\`${t}\``)))},sg=e=>`${e.code}\0${e.message}`,cg=(e,t)=>{let n=new Map;for(let t of e)t.severity===`error`&&n.set(sg(t),(n.get(sg(t))??0)+1);let r=[];for(let e of t){if(e.severity!==`error`)continue;let t=n.get(sg(e))??0;t>0?n.set(sg(e),t-1):r.push(e)}return r},lg=e=>is(e)&&`type`in e&&typeof e.type==`string`&&`start`in e&&typeof e.start==`number`&&`end`in e&&typeof e.end==`number`,ug=e=>Array.isArray(e)?e.filter(lg):[],dg=(e,t,n=null)=>{if(Array.isArray(e)){for(let r of e)dg(r,t,n);return}if(lg(e)){t(e,n);for(let[n,r]of Object.entries(e))n!==`loc`&&n!==`extra`&&n!==`comments`&&dg(r,t,e)}},fg=e=>{try{let t=zp(e,{sourceType:`module`,plugins:[`typescript`,`jsx`]});return lg(t)?t:null}catch{return null}},pg=e=>e.type===`Identifier`||e.type===`MemberExpression`&&e.computed===!1&&lg(e.object)&&pg(e.object),mg=e=>e.split(/\r\n|\n|\r|\u2028|\u2029/).map(e=>e.trim()).filter(e=>e!==``).join(` `),hg=(e,t,n,r)=>{let i=t.type===`JSXExpressionContainer`&&lg(t.expression)?t.expression:t,a=i.type===`StringLiteral`||i.type===`NumericLiteral`||i.type===`BooleanLiteral`||i.type===`JSXText`,o=n.slice(i.start,i.end),s=i.type===`JSXText`?{start:i.start+(o.length-o.trimStart().length),end:i.end-(o.length-o.trimEnd().length)}:{start:t.start,end:t.end};return{name:e,literalType:i.type===`NumericLiteral`?`number`:i.type===`BooleanLiteral`?`boolean`:`string`,kind:a?`literal`:pg(i)?`binding`:`computed`,value:a&&i.type===`JSXText`&&typeof i.value==`string`?mg(i.value):a&&(typeof i.value==`string`||typeof i.value==`number`||typeof i.value==`boolean`)?String(i.value):n.slice(i.start,i.end),start:s.start,end:s.end,syntax:r}},gg=(e,t,n)=>{if(t?.type!==`JSXElement`&&t?.type!==`JSXFragment`)return{previous:null,next:null};let r=ug(t.children).filter(e=>e.type!==`JSXText`||n.slice(e.start,e.end).trim()!==``),i=r.findIndex(t=>t.start===e.start),a=e=>e?.type===`JSXElement`?{start:e.start,end:e.end}:null;return{previous:a(r[i-1]),next:a(r[i+1])}},_g=(e,t,n)=>{if(t!==n.fileName)return null;let r=fg(e);if(r===null)return null;let i=bs(e),a=i[n.lineNumber-1];if(a===void 0||!Number.isInteger(n.columnNumber)||n.columnNumber<1)return null;let o=a+n.columnNumber-1;if(o>=(i[n.lineNumber]??e.length))return null;let s=null;return dg(r,(t,n)=>{if(t.type!==`JSXElement`||t.start!==o||!lg(t.openingElement))return;let r=t.openingElement,i=[];for(let t of ug(r.attributes))if(t.type===`JSXAttribute`&&lg(t.name)&&typeof t.name.name==`string`&&lg(t.value)){let n=t.value,r=n.type===`JSXExpressionContainer`&&lg(n.expression)?n.expression:null;if(t.name.name===`style`&&r?.type===`ObjectExpression`&&!ug(r.properties).some(e=>e.type===`SpreadElement`))for(let t of ug(r.properties)){if(t.type!==`ObjectProperty`||t.computed===!0||!lg(t.key)||!lg(t.value))continue;let n=t.key.type===`Identifier`?t.key.name:t.key.value;typeof n==`string`&&i.push(hg(`style.${n}`,t.value,e,`value`))}else i.push(hg(t.name.name,n,e,`attribute`))}let a=ug(t.children).filter(t=>t.type!==`JSXText`||e.slice(t.start,t.end).trim()!==``);if(a.length===1&&a[0]!==void 0&&a[0].type!==`JSXElement`&&a[0].type!==`JSXFragment`)i.unshift(hg(`children`,a[0],e,`child`));else if(a.length>1){let t=a.flatMap((t,n)=>t.type===`JSXText`?[hg(`text.${n}`,t,e,`child`)]:[]);i.unshift(...t)}s={start:t.start,end:t.end,contentStart:r.selfClosing===!0?null:r.end,contentEnd:lg(t.closingElement)?t.closingElement.start:null,tag:lg(r.name)?e.slice(r.name.start,r.name.end):`element`,properties:i,attributeInsertion:(()=>{let e=ug(r.attributes).at(-1);return e===void 0?lg(r.name)?r.name.end:r.end-1:e.end})(),hasSpread:ug(r.attributes).some(e=>e.type===`JSXSpreadAttribute`),structural:n?.type===`JSXElement`||n?.type===`JSXFragment`,...gg(t,n,e)}}),s},vg=/^[^\s{}<>&](?:[^{}<>&\r\n\u2028\u2029]*[^\s{}<>&])?$/,yg=(e,t,n)=>{if(t.kind!==`literal`||t.literalType===`number`&&(n.trim()===``||!Number.isFinite(Number(n)))||t.literalType===`boolean`&&n!==`true`&&n!==`false`)return null;let r=t.literalType===`string`?JSON.stringify(n):t.literalType===`number`?String(Number(n)):n,i=e.slice(t.start,t.end),a=t.syntax===`child`&&!i.startsWith(`{`)&&vg.test(n);return{start:t.start,end:t.end,before:i,after:a?n:t.syntax===`child`||t.syntax===`attribute`&&t.literalType!==`string`?`{${r}}`:r}},bg=(e,t,n)=>({start:t.start,end:t.end,before:e.slice(t.start,t.end),after:t.syntax===`value`?n:`{${n}}`}),xg=(e,t,n)=>{let r=n.file??n.entry,i=e=>({...n.files,[r]:e}),a=cg(og(i(e),n.entry),og(i(t),n.entry)),o=a[0];if(o===void 0)return null;let s=a.length>1?` (and ${a.length-1} more)`:``;return`This change leaves the static profile: ${o.message}${o.fix===void 0?``:` ${o.fix}`}${s}`},Sg=(e,t,n={})=>{let r=[...t].sort((e,t)=>t.start-e.start),i=e.length,a=e;for(let t of r){if(t.start<0||t.end<t.start||t.end>i||e.slice(t.start,t.end)!==t.before)return{ok:!1,reason:`Source changed at this target. Select it again before applying the edit.`};a=a.slice(0,t.start)+t.after+a.slice(t.end),i=t.start}if(fg(a)===null)return{ok:!1,reason:`This change is not valid TSX. Review it in Source.`};if(n.profile!==void 0&&a!==e){let t=xg(e,a,n.profile);if(t!==null)return{ok:!1,reason:t}}return{ok:!0,source:a}},Cg=(e,t)=>{let n=Math.max(e.lastIndexOf(`
26
+ `,t-1),e.lastIndexOf(`\r`,t-1)),r=e.slice(n+1,t);return/^[ \t]*$/.test(r)?r:null},wg=(e,t)=>{if(Cg(e,t.start)===null)return t;let n=/^[ \t]*(\r\n|\n|\r)/.exec(e.slice(t.end));return n===null?t:{start:t.start-(Cg(e,t.start)??``).length,end:t.end+n[0].length}},Tg=(e,t,n)=>{if(n.kind===`insert`)return t.contentEnd===null?null:[{start:t.contentEnd,end:t.contentEnd,before:``,after:n.tsx}];if(!t.structural)return null;let r=e.slice(t.start,t.end);if(n.kind===`duplicate`){let n=Cg(e,t.start);return[{start:t.end,end:t.end,before:``,after:n===null?r:`\n${n}${r}`}]}if(n.kind===`reorder`){let i=n.direction===`before`?t.previous:t.next;return i===null?null:[{start:i.start,end:i.end,before:e.slice(i.start,i.end),after:r},{start:t.start,end:t.end,before:r,after:e.slice(i.start,i.end)}]}let i=wg(e,t),a={start:i.start,end:i.end,before:e.slice(i.start,i.end),after:``};if(n.kind===`delete`)return[a];let o=n.destination.contentEnd;return o===null||o>=t.start&&o<=t.end?null:[a,{start:o,end:o,before:``,after:r}]},Eg=(e,t)=>{let n=e.program;if(!lg(n))return null;for(let e of ug(n.body)){let n=e.type===`ExportNamedDeclaration`&&lg(e.declaration)?e.declaration:e;if(n.type===`VariableDeclaration`){for(let e of ug(n.declarations))if(lg(e.id)&&e.id.name===t&&lg(e.init)&&e.init.type===`ObjectExpression`)return e.init}}return null},Dg=e=>{let t=fg(e);if(t===null)return[];let n=[];return dg(t,r=>{if(r.type!==`CallExpression`||!lg(r.callee)||r.callee.type!==`Identifier`||r.callee.name!==`defineTemplate`)return;let i=ug(r.arguments)[0];if(i?.type!==`ObjectExpression`)return;let a=ug(i.properties).find(e=>e.type===`ObjectProperty`&&lg(e.key)&&e.key.name===`fixtures`&&e.computed!==!0);if(a!==void 0&&lg(a.value)&&a.value.type===`ObjectExpression`)for(let r of ug(a.value.properties)){if(r.type!==`ObjectProperty`||r.computed===!0||!lg(r.key)||!lg(r.value))continue;let i=r.key.type===`Identifier`?r.key.name:r.key.value,a=r.value.type===`Identifier`&&typeof r.value.name==`string`?Eg(t,r.value.name)??r.value:r.value;typeof i==`string`&&n.push({name:i,start:a.start,end:a.end,source:e.slice(a.start,a.end)})}}),n},Og=e=>e.split(/\s+/).filter(e=>e!==``),kg=(e,t,n)=>{let r=t.properties.find(e=>e.name===`className`),i=e=>{if(n.kind===`set`)return Og(n.value).join(` `);let t=Og(n.tokens);return n.kind===`add`?[...e,...t.filter(t=>!e.includes(t))].join(` `):e.filter(e=>!t.includes(e)).join(` `)};if(r===void 0){if(t.hasSpread)return{ok:!1,reason:`A spread attribute can supply className here, so a class list cannot be added safely. Edit it in Source.`};if(n.kind===`remove`)return{ok:!0,edits:[]};let e=i([]);return e===``?{ok:!0,edits:[]}:{ok:!0,edits:[{start:t.attributeInsertion,end:t.attributeInsertion,before:``,after:` className=${JSON.stringify(e)}`}]}}if(r.kind!==`literal`||r.literalType!==`string`)return{ok:!1,reason:`className is ${r.kind===`binding`?`bound to`:`computed from`} \`${r.value}\`, so editing it would discard that choice. Change the literal classes inside it in Source.`};let a=i(Og(r.value));return{ok:!0,edits:[{start:r.start,end:r.end,before:e.slice(r.start,r.end),after:JSON.stringify(a)}]}},Ag=e=>is(e)&&typeof e.type==`string`&&typeof e.start==`number`&&typeof e.end==`number`,jg=e=>Array.isArray(e)?e.filter(Ag):[],Mg=(e,t)=>{let n=e[t];return Ag(n)?n:null},Ng=e=>{try{let t=zp(e,{sourceType:`module`,plugins:[`typescript`,`jsx`]});return Ag(t)?t:null}catch{return null}},Pg=(e,t)=>{if(Array.isArray(e)){for(let n of e)Pg(n,t);return}if(Ag(e)&&t(e)!==!1)for(let[n,r]of Object.entries(e))n!==`loc`&&n!==`extra`&&n!==`comments`&&Pg(r,t)},Fg=e=>e===null?``:e.type===`JSXIdentifier`?typeof e.name==`string`?e.name:``:e.type===`JSXMemberExpression`?`${Fg(Mg(e,`object`))}.${Fg(Mg(e,`property`))}`:``,Ig=e=>{if(e.type!==`JSXElement`)return null;let t=Mg(e,`openingElement`);if(t===null)return null;let n=Mg(e,`closingElement`);return{node:e,opening:t,closing:n,tag:Fg(Mg(t,`name`)),children:jg(e.children),attributes:jg(t.attributes),selfClosing:t.selfClosing===!0,contentStart:t.end,contentEnd:n===null?t.end:n.start}},Lg=e=>{let t=Mg(e,`body`);if(t===null)return null;if(t.type===`JSXElement`)return t;if(t.type!==`BlockStatement`)return null;let n=jg(t.body).filter(e=>e.type!==`EmptyStatement`),r=n.length===1?n[0]:void 0,i=r?.type===`ReturnStatement`&&r!==void 0?Mg(r,`argument`):null;return i!==null&&i.type===`JSXElement`?i:null},Rg=e=>{if(e.computed===!0)return null;let t=Mg(e,`key`);return t===null?null:t.type===`Identifier`?typeof t.name==`string`?t.name:null:t.type===`StringLiteral`&&typeof t.value==`string`?t.value:null},zg=(e,t)=>{let n=null;return Pg(e,e=>{if(n!==null)return!1;if(e.type!==`CallExpression`)return;let r=Mg(e,`callee`);if(r?.type!==`Identifier`||r.name!==`defineTemplate`)return;let i=jg(e.arguments)[0];if(i?.type!==`ObjectExpression`)return!1;for(let e of jg(i.properties)){if(Rg(e)!==t)continue;let r=e.type===`ObjectMethod`?e:e.type===`ObjectProperty`?Mg(e,`value`):null;if(r===null||r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`&&r.type!==`ObjectMethod`)return!1;let i=Lg(r),a=i===null?null:Ig(i);return a!==null&&(n={root:a,parameter:jg(r.params)[0]??null}),!1}return!1}),n},Bg=(e,t,n)=>{let r=n;return Pg(e,e=>{if(e.type===`ImportDeclaration`){if(Mg(e,`source`)?.value!==t)return!1;for(let t of jg(e.specifiers)){let e=Mg(t,`imported`),i=Mg(t,`local`);t.type===`ImportSpecifier`&&(e?.name===n||e?.value===n)&&(r=typeof i?.name==`string`?i.name:n)}return!1}}),r},Vg=e=>{let t=e.split(/\r\n|\n|\r/),n=0;t.forEach((e,t)=>{/[^ \t]/.test(e)&&(n=t)});let r=``;return t.forEach((e,i)=>{let a=e.replace(/\t/g,` `);i!==0&&(a=a.replace(/^ +/,``)),i!==t.length-1&&(a=a.replace(/ +$/,``)),a!==``&&(r+=i===n?a:`${a} `)}),r},Hg=e=>{let t=Mg(e,`expression`);if(t===null)return null;if(t.type===`StringLiteral`&&typeof t.value==`string`)return t.value;if(t.type===`TemplateLiteral`&&jg(t.expressions).length===0){let e=jg(t.quasis)[0]?.value;return is(e)&&typeof e.cooked==`string`?e.cooked:null}return null},Ug=(e,t)=>{let n=e.slice(t.start,t.end).replace(/\s+/g,` `).trim();return n.length>60?`${n.slice(0,59)}…`:n},Wg=(e,t)=>{let n=[],r=t.contentStart,i=``,a=e=>{n.push({kind:`text`,text:i,start:r,end:e}),i=``};for(let o of t.children){if(o.type===`JSXText`){i+=Vg(typeof o.value==`string`?o.value:``);continue}if(o.type===`JSXExpressionContainer`){let e=Hg(o);if(e!==null){i+=e;continue}}a(o.start),n.push({kind:`locked`,summary:Ug(e,o),start:o.start,end:o.end}),r=o.end}return a(t.contentEnd),n},Gg=e=>!/[{}<>&\r\n\t]/.test(e),Kg=(e,t,n)=>{let r=[...e],i=r.map(e=>!Gg(e));if(t)for(let e=0;e<r.length&&/\s/.test(r[e]);e++)i[e]=!0;if(n)for(let e=r.length-1;e>=0&&/\s/.test(r[e]);e--)i[e]=!0;let a=``,o=``,s=!1,c=()=>{o!==``&&(a+=s?`{${JSON.stringify(o)}}`:o,o=``)};return r.forEach((e,t)=>{o!==``&&i[t]!==s&&c(),s=i[t],o+=e}),c(),a},qg=(e,t,n,r,i)=>{let a=n[r];if(a?.kind!==`text`)return{ok:!1,reason:`That part of the body is locked.`};if(a.text===i)return{ok:!0,edits:[]};if(t.selfClosing){let n=t.opening,r=n.end-2;for(;r>n.start&&/\s/.test(e[r-1]);)r--;return{ok:!0,edits:[{start:r,end:n.end,before:e.slice(r,n.end),after:`>${Kg(i,!1,!1)}</${t.tag}>`}]}}let o=e.slice(a.start,a.end),s=/^\s*/.exec(o)?.[0]??``,c=/[\r\n]/.test(s)?s:``,l=o.slice(c.length),u=/\s*$/.exec(l)?.[0]??``,d=/[\r\n]/.test(u)?u:``,f=a.start+c.length,p=a.end-d.length;return{ok:!0,edits:[{start:f,end:p,before:e.slice(f,p),after:Kg(i,c!==``,d!==``)}]}},Jg=(e,t)=>e.attributes.find(e=>e.type===`JSXAttribute`&&Fg(Mg(e,`name`))===t)??null,Yg=(e,t,n)=>{let r=Jg(t,n);if(r===null)return{kind:`absent`};let i=Mg(r,`value`);if(i?.type===`StringLiteral`&&typeof i.value==`string`)return{kind:`literal`,value:i.value};if(i?.type===`JSXExpressionContainer`){let e=Hg(i);if(e!==null)return{kind:`literal`,value:e}}return{kind:`expression`,source:Ug(e,i??r)}},Xg=e=>/["&\\\r\n]/.test(e)?`{${JSON.stringify(e)}}`:`"${e}"`,Zg=(e,t,n,r)=>({start:t,end:n,before:e.slice(t,n),after:r}),Qg=(e,t,n,r)=>{let i=Jg(t,n);if(i===null){if(r===void 0)return{ok:!0,edits:[]};let i=t.attributes.at(-1)?.end??Mg(t.opening,`name`)?.end??t.opening.end;return{ok:!0,edits:[Zg(e,i,i,` ${n}=${Xg(r)}`)]}}if(Yg(e,t,n).kind===`expression`)return{ok:!1,reason:`\`${n}\` reads the input. Edit it in Source.`};if(r===void 0){let n=i.start;for(;n>t.opening.start&&/\s/.test(e[n-1]);)n--;return{ok:!0,edits:[Zg(e,n,i.end,``)]}}let a=Mg(i,`value`);return{ok:!0,edits:a===null?[Zg(e,i.end,i.end,`=${Xg(r)}`)]:[Zg(e,a.start,a.end,Xg(r))]}},$g=` `,e_=(e,t)=>{let n=e.lastIndexOf(`
27
+ `,t-1)+1,r=e.slice(n,t);return/^[ \t]*$/.test(r)?r:null},t_=(e,t)=>{let n=e_(e,t.start),r=/^[ \t]*(\r?\n)/.exec(e.slice(t.end));return n===null||r===null?Zg(e,t.start,t.end,``):Zg(e,t.start-n.length,t.end+r[0].length,``)},n_=(e,t,n,r)=>{let i=e_(e,t.start);return n===`before`?Zg(e,t.start,t.start,i===null?r:`${r}\n${i}`):Zg(e,t.end,t.end,i===null?r:`\n${i}${r}`)},r_=(e,t,n)=>{let r=new Set,i=e=>{if(n?.type===`Identifier`&&typeof n.name==`string`){let t=RegExp(`\\b${n.name}((?:\\??\\.[A-Za-z_$][\\w$]*)+)`,`g`);for(let n of e.matchAll(t))r.add(n[1].replace(/\?/g,``).slice(1))}else if(n?.type===`ObjectPattern`)for(let t of jg(n.properties)){let n=Mg(t,`key`);n?.type===`Identifier`&&typeof n.name==`string`&&RegExp(`\\b${n.name}\\b`).test(e)&&r.add(n.name)}};return Pg(t.node,t=>{t.type===`JSXExpressionContainer`&&Hg(t)===null&&i(e.slice(t.start,t.end))}),[...r].sort()},i_=e=>{let t=Ng(e);if(t===null)return null;let n=zg(t,`sms`);return n===null||n.root.tag!==Bg(t,`@samva/markup/sms`,`Sms`)?null:{...n,tree:t}},a_=e=>{let t=i_(e);return t===null?null:{category:Yg(e,t.root,`category`),segments:Wg(e,t.root),variables:r_(e,t.root,t.parameter)}},o_=(e,t)=>{let n=i_(e);return n===null?{ok:!1,reason:`The SMS body is not editable here.`}:t.kind===`category`?t.value!==void 0&&!im.includes(t.value)?{ok:!1,reason:`\`${t.value}\` is not an SMS category.`}:Qg(e,n.root,`category`,t.value):qg(e,n.root,Wg(e,n.root),t.segment,t.text)},s_={"quick-reply":`QuickReplyButton`,url:`UrlButton`,phone:`PhoneButton`,"copy-code":`CopyCodeButton`},c_={"quick-reply":`Reply`,url:`Visit site`,phone:`Call us`,"copy-code":`CODE`},l_=(e,t)=>{if(!e.startsWith(`${t}.`))return null;let n=e.slice(t.length+1);return Object.keys(s_).find(e=>s_[e]===n)??null},u_=e=>{let t=Ng(e);if(t===null)return null;let n=zg(t,`whatsapp`),r=Bg(t,`@samva/markup/whatsapp`,`WhatsApp`);if(n===null||n.root.tag!==r)return null;let i=e=>{for(let t of n.root.children){let n=Ig(t);if(n?.tag===`${r}.${e}`)return n}return null};return{...n,local:r,header:i(`Header`),body:i(`Body`),footer:i(`Footer`),buttons:i(`Buttons`)}},d_=(e,t)=>{if(t.buttons===null)return[];let n=[];for(let r of t.buttons.children){if(r.type===`JSXText`&&Vg(String(r.value??``))===``)continue;let i=Ig(r),a=i===null?null:l_(i.tag,t.local);if(i===null||a===null){n.push({row:{kind:`locked`,summary:Ug(e,r)},node:r});continue}let o=Wg(e,i),s=o[0];n.push({node:r,row:o.length===1&&s?.kind===`text`?{kind:`editable`,type:a,text:s.text,url:Yg(e,i,`url`),phone:Yg(e,i,`phone`)}:{kind:`locked`,summary:Ug(e,r)}})}return n},f_=e=>{let t=u_(e);if(t===null||t.body===null)return null;let{root:n}=t;return{language:Yg(e,n,`language`),category:Yg(e,n,`category`),header:t.header===null?null:Wg(e,t.header),headerType:t.header===null?{kind:`absent`}:Yg(e,t.header,`type`),body:Wg(e,t.body),footer:t.footer===null?null:Wg(e,t.footer),buttons:d_(e,t).map(({row:e})=>e),variables:r_(e,n,t.parameter)}},p_=(e,t,n,r)=>{let i=`${e}.${s_[t]}`;return`<${i}${t===`url`&&r.url!==void 0?` url=${Xg(r.url)}`:t===`phone`&&r.phone!==void 0?` phone=${Xg(r.phone)}`:``}>${Kg(n,!1,!1)}</${i}>`},m_=(e,t)=>p_(e,t,c_[t],{url:`https://example.com`,phone:`+15555550100`}),h_=(e,t,n,r,i)=>{let a=t[n];if(a===null){if(n===`body`||i===``||r!==0)return{ok:!0,edits:[]};let a=`${t.local}.${n===`header`?`Header`:`Footer`}`,o=`<${a}>${Kg(i,!1,!1)}</${a}>`;return{ok:!0,edits:[n_(e,n===`header`?t.body.node:t.buttons?.node??t.body.node,n===`header`?`before`:`after`,o)]}}let o=Wg(e,a);return n!==`body`&&i===``&&o.length===1?{ok:!0,edits:[t_(e,a.node)]}:qg(e,a,o,r,i)},g_=(e,t)=>{let n=u_(e);if(n===null||n.body===null)return{ok:!1,reason:`The WhatsApp body is not editable here.`};let{root:r,local:i}=n;switch(t.kind){case`attribute`:return t.name===`category`&&!am.includes(t.value)?{ok:!1,reason:`Choose a WhatsApp category.`}:Qg(e,r,t.name,t.value);case`headerType`:return n.header===null?{ok:!1,reason:`Add the header text before choosing its type.`}:om.includes(t.value)?Qg(e,n.header,`type`,t.value===`text`?void 0:t.value):{ok:!1,reason:`\`${t.value}\` is not a header type.`};case`text`:return h_(e,n,t.part,t.segment,t.text);case`buttonAdd`:{let r=m_(i,t.type),a=n.buttons;if(a===null){let t=n.footer??n.body,a=`${i}.Buttons`,o=e_(e,t.node.start),s=o===null?`<${a}>${r}</${a}>`:`<${a}>\n${o}${$g}${r}\n${o}</${a}>`;return{ok:!0,edits:[n_(e,t.node,`after`,s)]}}if(a.selfClosing){let t=`${i}.Buttons`,n=e_(e,a.node.start),o=n===null?`<${t}>${r}</${t}>`:`<${t}>\n${n}${$g}${r}\n${n}</${t}>`;return{ok:!0,edits:[Zg(e,a.node.start,a.node.end,o)]}}let o=a.children.findLast(e=>e.type!==`JSXText`||Vg(String(e.value??``))!==``);if(o!==void 0)return{ok:!0,edits:[n_(e,o,`after`,r)]};let s=e_(e,a.node.start);return{ok:!0,edits:[Zg(e,a.contentStart,a.contentEnd,s===null?r:`\n${s}${$g}${r}\n${s}`)]}}}let a=d_(e,n),o=a[t.button];if(o===void 0||n.buttons===null)return{ok:!1,reason:`That button no longer exists.`};if(t.kind===`buttonRemove`)return{ok:!0,edits:[t_(e,a.length===1?n.buttons.node:o.node)]};let s=Ig(o.node);if(o.row.kind===`locked`||s===null)return{ok:!1,reason:`That button is locked. Edit it in Source.`};switch(t.kind){case`buttonText`:return qg(e,s,Wg(e,s),0,t.text);case`buttonAttribute`:return Qg(e,s,t.name,t.value);default:{let{row:n}=o,r=e=>e.kind===`literal`?e.value:void 0,a=p_(i,t.type,n.text,{url:r(n.url)??`https://example.com`,phone:r(n.phone)??`+15555550100`});return{ok:!0,edits:[Zg(e,o.node.start,o.node.end,a)]}}}},__=new Set([`[`,`]`,`{`,`}`,`\\`,`~`,`|`,`€`,`^`,`\f`]),v_=/^[@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,\-./:;<=>?¡0-9ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà]*$/,y_=e=>{for(let t of e)if(!__.has(t)&&!v_.test(t))return!0;return!1},b_=e=>{if(y_(e)){let t=[...e].length,n=t<=70?1:Math.ceil(t/67);return{encoding:`ucs2`,characterCount:e.length,segmentCount:n}}let t=0;for(let n of e)t+=__.has(n)?2:1;let n=t<=160?1:Math.ceil(t/153);return{encoding:`gsm7`,characterCount:e.length,segmentCount:n}},x_=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),S_=o(((e,t)=>{t.exports=x_()})),C_={};function w_(e,t){let n=W.useRef(C_);return n.current===C_&&(n.current=e(t)),n}var T_=[],E_=void 0;function D_(){return E_}function O_(e){T_.push(e)}function k_(e){let t=(t,n)=>{let r=w_(j_).current,i;try{E_=r;for(let e of T_)e.before(r);i=e(t,n);for(let e of T_)e.after(r);r.didInitialize=!0}finally{E_=void 0}return i};return t.displayName=e.displayName||e.name,t}function A_(e){return W.forwardRef(k_(e))}function j_(){return{didInitialize:!1}}function M_(){}var N_=Object.freeze([]),P_=Object.freeze({}),X=typeof document<`u`?W.useLayoutEffect:()=>{};function F_(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var I_=F_(`https://base-ui.com/production-error`,`Base UI`),L_=W.createContext(void 0);function R_(e){let t=W.useContext(L_);if(t===void 0&&!e)throw Error(I_(72));return t}function z_(e){W.useEffect(e,N_)}var B_=0,V_=class e{static create(){return new e}currentId=B_;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=B_,t()},e)}isStarted(){return this.currentId!==B_}clear=()=>{this.currentId!==B_&&(clearTimeout(this.currentId),this.currentId=B_)};disposeEffect=()=>this.clear};function H_(){let e=w_(V_.create).current;return z_(e.disposeEffect),e}function U_(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:W_,platform:G_,maxTouchPoints:K_}=U_(),q_=W_.toLowerCase(),J_=G_.toLowerCase(),Y_=/^i(os$|p)/.test(J_)||J_===`macintel`&&K_>1,X_=`android`,Z_=J_===X_||q_.includes(X_),Q_=!Y_&&J_.startsWith(`mac`);J_.startsWith(`win`),!Z_&&/^(linux|chrome os)/.test(J_);var $_=Q_||Y_,ev=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!ev&&q_.includes(`firefox`),!ev&&q_.includes(`chrom`);var tv=$_,nv=/jsdom|happydom/.test(q_);function rv(e){e.preventDefault(),e.stopPropagation()}function iv(e){return`nativeEvent`in e}function av(e){return e.pointerType===``&&e.isTrusted?!0:Z_&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function ov(e){return nv?!1:!Z_&&e.width===0&&e.height===0||Z_&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function sv(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function cv(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function lv(){return typeof window<`u`}function uv(e){return pv(e)?(e.nodeName||``).toLowerCase():`#document`}function dv(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function fv(e){return((pv(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function pv(e){return lv()?e instanceof Node||e instanceof dv(e).Node:!1}function mv(e){return lv()?e instanceof Element||e instanceof dv(e).Element:!1}function hv(e){return lv()?e instanceof HTMLElement||e instanceof dv(e).HTMLElement:!1}function gv(e){return!lv()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof dv(e).ShadowRoot}function _v(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Ov(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function vv(e){return/^(table|td|th)$/.test(uv(e))}function yv(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var bv=/transform|translate|scale|rotate|perspective|filter/,xv=/paint|layout|strict|content/,Sv=e=>!!e&&e!==`none`,Cv;function wv(e){let t=mv(e)?Ov(e):e;return Sv(t.transform)||Sv(t.translate)||Sv(t.scale)||Sv(t.rotate)||Sv(t.perspective)||!Ev()&&(Sv(t.backdropFilter)||Sv(t.filter))||bv.test(t.willChange||``)||xv.test(t.contain||``)}function Tv(e){let t=Av(e);for(;hv(t)&&!Dv(t);){if(wv(t))return t;if(yv(t))return null;t=Av(t)}return null}function Ev(){return Cv??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Cv}function Dv(e){return/^(html|body|#document)$/.test(uv(e))}function Ov(e){return dv(e).getComputedStyle(e)}function kv(e){return mv(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Av(e){if(uv(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||gv(e)&&e.host||fv(e);return gv(t)?t.host:t}function jv(e){let t=Av(e);return Dv(t)?(e.ownerDocument||e).body:hv(t)&&_v(t)?t:jv(t)}function Mv(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=jv(e),i=r===e.ownerDocument?.body,a=dv(r);if(i){let e=Nv(a);return t.concat(a,a.visualViewport||[],_v(r)?r:[],e&&n?Mv(e):[])}return t.concat(r,Mv(r,[],n))}function Nv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Pv(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Fv(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&gv(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Iv(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var Lv=`data-base-ui-focusable`,Rv=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,zv=`ArrowLeft`,Bv=`ArrowRight`,Vv=`ArrowUp`,Hv=`ArrowDown`,Uv=`data-starting-style`,Wv=`data-ending-style`,Gv={[Uv]:``},Kv={[Wv]:``},qv={transitionStatus(e){return e===`starting`?Gv:e===`ending`?Kv:null}},Jv=`data-open`,Yv=`data-closed`,Xv=`data-anchor-hidden`,Zv=`data-popup-open`,Qv=`data-pressed`,$v={[Zv]:``},ey={[Zv]:``,[Qv]:``},ty={[Jv]:``},ny={[Yv]:``},ry={[Xv]:``},iy={open(e){return e?$v:null}},ay={open(e){return e?ey:null}},oy={open(e){return e?ty:ny},anchorHidden(e){return e?ry:null}},sy={...oy,...qv},cy=`data-trigger-disabled`;function ly(e,t){if(!mv(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(cy);for(let[,e]of t.entries())if(Fv(e,n))return!e.hasAttribute(cy);return!1}function uy(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function dy(e){return e.matches(`html,body`)}function fy(e){return hv(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function py(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Rv}`)!=null}function my(e){return e?e.getAttribute(`role`)===`combobox`&&fy(e):!1}function hy(e){if(!e||nv)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function gy(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function _y(e,t){return t!=null&&!sv(t)?0:typeof e==`function`?e():e}function vy(e,t,n){let r=_y(e,n);return typeof r==`number`?r:r?.[t]}function yy(e){return typeof e==`function`?e():e}function by(e,t){return t||e===`click`||e===`mousedown`}function xy(e){return e?.includes(`mouse`)&&e!==`mousedown`}var Sy=`none`,Cy=`trigger-press`,wy=`trigger-hover`,Ty=`trigger-focus`,Ey=`outside-press`,Dy=`item-press`,Oy=`close-press`,ky=`focus-out`,Ay=`escape-key`,jy=`close-watcher`,My=`list-navigation`,Ny=`cancel-open`,Py=`sibling-open`,Fy=`disabled`,Iy=`imperative-action`,Ly=`swipe`,Ry=`window-resize`;function zy(e,t,n,r){let i=!1,a=!1,o=r??P_;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var Z=S_(),By=W.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new V_,currentIdRef:{current:null},currentContextRef:{current:null}});function Vy(e,t){e.current=t.current}function Hy(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:l,hasProvider:u,timeout:d}=W.useContext(By),[f,p]=W.useState(!1),m=W.useRef(n);return X(()=>{m.current=n},[n]),X(()=>{function e(){l.current?.setIsInstantPhase(!1),a.current=null,l.current=null,o.current=c.current,d.clear()}if(a.current&&!n&&a.current===i){if(p(!1),s){let t=i;return d.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(m.current||a.current!==t)&&d.clear()}}e()}},[n,i,a,o,s,c,l,d,r]),X(()=>{if(!n)return;let e=l.current,t=a.current;d.clear(),l.current={onOpenChange:r.setOpen,setIsInstantPhase:p},a.current=i,o.current={open:0,close:vy(c.current,`close`)},t!==null&&t!==i?(p(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,zy(Sy))):(p(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,l,d]),X(()=>()=>{if(a.current===i){if(l.current=null,!m.current)return;a.current=null,Vy(o,c),d.clear()}},[l,a,o,i,c,d]),W.useMemo(()=>({activeIdRef:a,hasProvider:u,delayRef:o,isInstantPhase:f}),[a,u,o,f])}function Uy(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Wy(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Gy(e,t,n,r){let i=w_(qy).current;return Jy(i,e,t,n,r)&&Xy(i,[e,t,n,r]),i.callback}function Ky(e){let t=w_(qy).current;return Yy(t,e)&&Xy(t,e),t.callback}function qy(){return{callback:null,cleanup:null,refs:[]}}function Jy(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Yy(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Xy(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function Zy(e){let t=w_(Qy,e).current;return t.next=e,X(t.effect),t}function Qy(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var $y={...W},eb=$y.useInsertionEffect,tb=eb&&eb!==$y.useLayoutEffect?eb:e=>e();function Q(e){let t=w_(nb).current;return t.next=e,tb(t.effect),t.trampoline}function nb(){let e={next:void 0,callback:rb,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function rb(){}var ib=null;globalThis.requestAnimationFrame;var ab=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},ob=class e{static create(){return new e}static request(e){return ab.request(e)}static cancel(e){return ab.cancel(e)}currentId=ib;request(e){this.cancel(),this.currentId=ab.request(()=>{this.currentId=ib,e()})}cancel=()=>{this.currentId!==ib&&(ab.cancel(this.currentId),this.currentId=ib)};disposeEffect=()=>this.cancel};function sb(){let e=w_(ob.create).current;return z_(e.disposeEffect),e}function cb(e){return e?.ownerDocument||document}var lb={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},ub={...lb,position:`fixed`,top:0,left:0},db={...lb,position:`absolute`},fb=W.forwardRef(function(e,t){let[n,r]=W.useState();X(()=>{tv&&ev&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,Z.jsx)(`span`,{...e,ref:t,style:ub,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),pb=Math.min,mb=Math.max,hb=Math.round,gb=Math.floor,_b=e=>({x:e,y:e}),vb={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function yb(e,t,n){return mb(e,pb(t,n))}function bb(e,t){return typeof e==`function`?e(t):e}function xb(e){return e.split(`-`)[0]}function Sb(e){return e.split(`-`)[1]}function Cb(e){return e===`x`?`y`:`x`}function wb(e){return e===`y`?`height`:`width`}function Tb(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Eb(e){return Cb(Tb(e))}function Db(e,t,n){n===void 0&&(n=!1);let r=Sb(e),i=Eb(e),a=wb(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Ib(o)),[o,Ib(o)]}function Ob(e){let t=Ib(e);return[kb(e),t,kb(t)]}function kb(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Ab=[`left`,`right`],jb=[`right`,`left`],Mb=[`top`,`bottom`],Nb=[`bottom`,`top`];function Pb(e,t,n){switch(e){case`top`:case`bottom`:return n?t?jb:Ab:t?Ab:jb;case`left`:case`right`:return t?Mb:Nb;default:return[]}}function Fb(e,t,n,r){let i=Sb(e),a=Pb(xb(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(kb)))),a}function Ib(e){let t=xb(e);return vb[t]+e.slice(t.length)}function Lb(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Rb(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Lb(e)}function zb(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Bb(e,t){return t<0||t>=e.length}function Vb(e,t){return Ub(e.current,{disabledIndices:t})}function Hb(e,t){return Ub(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Ub(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Wb(e,a,r));return a}function Wb(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!Kb(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function Gb(e){return e.visibility===`hidden`||e.visibility===`collapse`}function Kb(e,t=e?Ov(e):null){return!e||!e.isConnected||!t||Gb(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var qb=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Jb(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return gv(n)?n.host:null}function Yb(e){for(let t of Array.from(e.children))if(uv(t)===`summary`)return t;return null}function Xb(e,t){let n=Yb(t);return!!n&&(e===n||Fv(n,e))}function Zb(e){let t=e?uv(e):``;return e!=null&&e.matches(qb)&&(t!==`summary`||e.parentElement!=null&&uv(e.parentElement)===`details`&&Yb(e.parentElement)===e)&&(t!==`details`||Yb(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Qb(e){if(!Zb(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Jb(t)){let n=t!==e,r=uv(t)===`slot`;if(t.hasAttribute(`inert`)||n&&uv(t)===`details`&&!t.open&&!Xb(e,t)||t.hasAttribute(`hidden`)||!r&&!$b(t,n))return!1}return!0}function $b(e,t){let n=Ov(e);return t?n.display!==`none`:Kb(e,n)}function ex(e){let t=e.tabIndex;if(t<0){let t=uv(e);if(t===`details`||t===`audio`||t===`video`||hv(e)&&e.isContentEditable)return 0}return t}function tx(e){if(uv(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function nx(e,t){let n=tx(e);if(!n)return!0;let r=t.find(e=>{let t=tx(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=tx(e);return t?.name===n.name&&t.form===n.form})===n}function rx(e){if(hv(e)&&uv(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return hv(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function ix(e,t){rx(e).forEach(e=>{Zb(e)&&t.push(e),ix(e,t)})}function ax(e,t,n){rx(e).forEach(e=>{hv(e)&&e.matches(t)&&n.push(e),ax(e,t,n)})}function ox(e){return Qb(e)&&ex(e)>=0}function sx(e){let t=[];return ix(e,t),t.filter(Qb)}function cx(e){let t=sx(e);return t.filter(e=>ex(e)>=0&&nx(e,t))}function lx(e,t){let n=cx(e),r=n.length;if(r===0)return;let i=Pv(cb(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function ux(e){return lx(cb(e).body,1)||e}function dx(e){return lx(cb(e).body,-1)||e}function fx(e,t){if(!e)return null;let n=cx(cb(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function px(e){return fx(e,1)}function mx(e){return fx(e,-1)}function hx(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Fv(n,r)}function gx(e){cx(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function _x(e){let t=[];ax(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function vx(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...vx(e,t.id,n)])}function yx(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function bx(e){return`data-base-ui-${e}`}var xx=0;function Sx(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(xx);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),M_;let o=requestAnimationFrame(a);return xx=o,()=>{xx===o&&(cancelAnimationFrame(o),xx=0)}}var Cx={inert:new WeakMap,"aria-hidden":new WeakMap},wx=`data-base-ui-inert`,Tx={inert:new WeakSet,"aria-hidden":new WeakSet},Ex=new WeakMap,Dx=0;function Ox(e){return Tx[e]}function kx(e){return e?gv(e)?e.host:kx(e.parentNode):null}var Ax=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=kx(t);return e.contains(n)?n:null}).filter(e=>e!=null),jx=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},Mx=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{uv(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Nx(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=Ax(t,e),l=i?Mx(t,jx(c),new Set(c)):[],u=[],d=[];if(a){let e=Cx[a],n=Ox(a);s=n,o=e;let r=Ax(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);Mx(t,jx(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(Ex.get(e)||0)+1;Ex.set(e,t),d.push(e),t===1&&e.setAttribute(wx,``)}),Dx+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(Ex.get(e)||0)-1;Ex.set(e,t),t||e.removeAttribute(wx)}),--Dx,Dx||(Cx.inert=new WeakMap,Cx[`aria-hidden`]=new WeakMap,Tx.inert=new WeakSet,Tx[`aria-hidden`]=new WeakSet,Ex=new WeakMap)}}function Px(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=cb(e[0]).body;return Nx(e,a,n,r,{mark:i})}var Fx=0;function Ix(e,t=`mui`){let[n,r]=W.useState(e),i=e||n;return W.useEffect(()=>{n??(Fx+=1,r(`${t}-${Fx}`))},[n,t]),i}var Lx=$y.useId;function Rx(e,t){if(Lx!==void 0){let n=Lx();return e??(t?`${t}-${n}`:n)}return Ix(e,t)}var zx=19;function Bx(e){return zx>=e}function Vx(e){if(!W.isValidElement(e))return null;let t=e,n=t.props;return(Bx(19)?n?.ref:t.ref)??null}function Hx(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function Ux(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Wx(e,t){return typeof e==`function`?e(t):e}function Gx(e,t){return typeof e==`function`?e(t):e}var Kx={};function qx(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Yx(t);let a=Yx(e);return t&&(a=Xx(a,t)),n&&(a=Xx(a,n)),r&&(a=Xx(a,r)),i&&(a=Xx(a,i)),a}function Jx(e){if(e.length===0)return Kx;if(e.length===1)return Yx(e[0]);let t=Yx(e[0]);for(let n=1;n<e.length;n+=1)t=Xx(t,e[n]);return t}function Yx(e){return eS(e)?{...tS(e,Kx)}:Zx(e)}function Xx(e,t){return eS(t)?tS(t,e):Qx(e,t)}function Zx(e){let t={...e};for(let e in t){let n=t[e];$x(e,n)&&(t[e]=rS(n))}return t}function Qx(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Hx(e.style,r);break;case`className`:e[n]=aS(e.className,r);break;default:e[n]=$x(n,r)?nS(e[n],r):r}}return e}function $x(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function eS(e){return typeof e==`function`}function tS(e,t){return eS(e)?e(t):e??Kx}function nS(e,t){return t?e?(...n)=>{let r=n[0];if(oS(r)){let i=r;iS(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:rS(t):e}function rS(e){return e&&((...t)=>{let n=t[0];return oS(n)&&iS(n),e(...t)})}function iS(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function aS(e,t){return t?e?t+` `+e:t:e}function oS(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function sS(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=dS(r));let i=cS(t,n,r);if(n.enabled===!1)return null;let a=n.state??P_;return fS(e,r,i,a)}function cS(e,t,n){let{className:r,style:i}=e,{state:a=P_,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Wx(r,a):void 0,d=l?Gx(i,a):void 0,f=l?Ux(a,c):P_,p=l&&s?lS(s):void 0,m=l?Hx(f,p)??{}:P_;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?Ky([m.ref,Vx(n),...o]):Gy(m.ref,Vx(n),o):Gy(null,null)),l?(u!==void 0&&(m.className=aS(m.className,u)),d!==void 0&&(m.style=Hx(m.style,d)),m):P_}function lS(e){return Array.isArray(e)?Jx(e):qx(void 0,e)}var uS=Symbol.for(`react.lazy`);function dS(e){if(e?.$$typeof!==uS)return e;let t=W.Children.toArray(e)[0];return W.isValidElement(t)?t:e}function fS(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=qx(n,t.props);return e.ref=n.ref,W.cloneElement(t,e)}if(e&&typeof e==`string`)return pS(e,n);throw Error(I_(8))}function pS(e,t){return e===`button`?(0,W.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,W.createElement)(`img`,{alt:``,...t,key:t.key}):W.createElement(e,t)}var mS={style:{transition:`none`}},hS=`data-base-ui-click-trigger`,gS=`data-base-ui-swipe-ignore`,_S=`data-swipe-ignore`,vS=`[${gS}]`;`${_S}`;var yS={fallbackAxisSide:`none`},bS={fallbackAxisSide:`end`},xS={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},SS=c(m(),1),CS=W.createContext(null),wS=()=>W.useContext(CS),TS=bx(`portal`);function ES(e={}){let{ref:t,container:n,componentProps:r=P_,elementProps:i}=e,a=Rx(),o=wS()?.portalNode,[s,c]=W.useState(null),[l,u]=W.useState(null),d=Q(e=>{e!==null&&u(e)}),f=W.useRef(null);X(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(pv(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=sS(`div`,r,{ref:[t,d],props:[{id:a,[TS]:``},i]}),m=s&&p?SS.createPortal(p,s):null;return{node:l,nodeId:W.isValidElement(p)?p.props.id:void 0,subtree:m}}var DS=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=ES({container:o,ref:t,componentProps:e,elementProps:c}),f=W.useRef(null),p=W.useRef(null),m=W.useRef(null),h=W.useRef(null),[g,_]=W.useState(null),v=W.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;W.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&hx(e)&&(e.type===`focusin`?v.current&&=(_x(l),!1):(gx(l),v.current=!0))}return Wy(Uy(l,`focusin`,e,!0),Uy(l,`focusout`,e,!0))},[l,y]),X(()=>{l&&b===!0&&v.current&&(_x(l),v.current=!1)},[b,l]);let S=W.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,Z.jsxs)(W.Fragment,{children:[d,(0,Z.jsxs)(CS.Provider,{value:S,children:[x&&l&&(0,Z.jsx)(fb,{"data-type":`outside`,ref:f,onFocus:e=>{hx(e,l)?m.current?.focus():dx(g?g.domReference:null)?.focus()}}),x&&l&&(0,Z.jsx)(`span`,{role:s,"aria-owns":u,style:xS}),l&&SS.createPortal(a,l),x&&l&&(0,Z.jsx)(fb,{"data-type":`outside`,ref:p,onFocus:e=>{hx(e,l)?h.current?.focus():(ux(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,zy(`focus-out`,e.nativeEvent)))}})]})]})});function OS(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var kS=class{nodesRef={current:[]};events=OS();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},AS=W.createContext(null),jS=W.createContext(null),MS=()=>W.useContext(AS)?.id||null,NS=e=>{let t=W.useContext(jS);return e??t};function PS(e){let t=Rx(),n=NS(e),r=MS();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function FS(e){let{children:t,id:n}=e,r=MS();return(0,Z.jsx)(AS.Provider,{value:W.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function IS(e){let{children:t,externalTree:n}=e,r=w_(()=>n??new kS).current;return(0,Z.jsx)(jS.Provider,{value:r,children:t})}function LS(e){return e==null?e:`current`in e?e.current:e}function RS(e,t){let n=dv(Iv(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var zS=20,BS=[];function VS(){BS=BS.filter(e=>e.deref()?.isConnected)}function HS(e){VS(),e&&uv(e)!==`body`&&(BS.push(new WeakRef(e)),BS.length>zS&&(BS=BS.slice(-20)))}function US(){return VS(),BS[BS.length-1]?.deref()}function WS(e){return e?ox(e)?e:cx(e)[0]||e:null}function GS(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=sx(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return ox(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function KS(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=Q(()=>b.current.floatingContext?.nodeId),S=i===!1,C=my(_)&&S,w=Zy(i),T=Zy(a),E=Zy(l),D=Zy(g),O=NS(p),k=wS(),A=W.useRef(!1),j=W.useRef(!1),M=W.useRef(!1),N=W.useRef(null),P=W.useRef(``),F=W.useRef(``),I=W.useRef(null),L=W.useRef(null),R=Gy(I,f,k?.beforeInsideRef),ee=Gy(L,k?.afterInsideRef),z=H_(),te=H_(),ne=sb(),re=k!=null,B=gy(v),ie=Q((e=B)=>e?cx(e):[]),ae=Q(()=>m?.().filter(e=>e!=null)??[]);W.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&Fv(B,Pv(cb(B)))&&ie().length===0&&!C&&rv(e)}return Uy(cb(B),`keydown`,e)},[r,B,s,C,ie]),W.useEffect(()=>{if(r||!g)return;let e=cb(B);function t(){M.current=!1}function n(e){let t=Iv(e),n=ae(),r=Fv(v,t)||Fv(_,t)||Fv(k?.portalNode,t)||n.some(e=>e===t||Fv(e,t));M.current=!r,F.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(j.current=!0,te.start(0,()=>{j.current=!1}))}function i(){F.current=`keyboard`}return Wy(Uy(e,`pointerdown`,n,!0),Uy(e,`pointerup`,t,!0),Uy(e,`pointercancel`,t,!0),Uy(e,`keydown`,i,!0),t)},[r,v,_,B,g,k,te,ae]),W.useEffect(()=>{if(r||!c)return;let e=cb(B);function t(){j.current=!0,te.start(0,()=>{j.current=!1})}function n(e){let t=Iv(e);ox(t)&&(N.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=Iv(t);s&&n==null&&i!=null&&Fv(v,i)&&HS(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=ae(),f=n?.hasAttribute(bx(`focus-guard`))&&[I.current,L.current,k?.beforeInsideRef.current,k?.afterInsideRef.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,LS(d),LS(u)].includes(n),p=!(Fv(_,n)||Fv(v,n)||Fv(n,v)||Fv(k?.portalNode,n)||l.some(e=>e===n||Fv(e,n))||c.hasMatchingElement(e=>Fv(e,n))||f||O&&(vx(O.nodesRef.current,a).find(e=>Fv(e.context?.elements.floating,n)||Fv(e.context?.elements.domReference,n))||yx(O.nodesRef.current,a).find(e=>[e.context?.elements.floating,gy(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&B&&GS(B),o&&r!==_&&!Kb(i)&&Pv(e)===e.body){if(hv(B)&&(B.focus(),o===`popup`)){ne.request(()=>{B.focus()});return}let e=ie(),t=N.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||B;hv(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!s)&&n&&p&&!j.current&&(C||n!==US())&&(A.current=!0,h.setOpen(!1,zy(ky,t)))})}function a(){M.current||(b.current.insideReactTree=!0,z.start(0,()=>{b.current.insideReactTree=!1}))}let l=hv(_)?_:null;if(v||l)return Wy(l&&Uy(l,`focusout`,i),l&&Uy(l,`pointerdown`,t),v&&Uy(v,`focusin`,n),v&&Uy(v,`focusout`,i),v&&k&&Uy(v,`focusout`,a,!0))},[r,_,v,B,s,O,k,h,c,o,ie,C,x,b,z,te,ne,u,d,ae]),W.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(k?.portalNode?.querySelectorAll(`[${bx(`portal`)}]`)||[]),t=(O?yx(O.nodesRef.current,x()):[]).find(e=>my(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Px([v,...e,I.current,L.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,...ae(),t,LS(d),LS(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=Px([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,k,C,O,x,u,d,ae]),X(()=>{if(!g||r||!hv(B))return;P.current=``,F.current=``;let e=cb(B),t=Pv(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||Fv(B,t))return;let i=null,a=()=>(i??=ie(B),i[0]||B),o;o=r===!0||r===null?a():LS(r),o||=a();let s=Fv(B,Pv(e));Sx(o,{preventScroll:o===B,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=Pv(e);return!(t!==o&&Fv(B,t))}})})},[r,g,B,ie,w,E,D]),X(()=>{if(r||!B)return;let e=cb(B),t=Pv(e),n=E.current==null;HS(t);function i(e){if(e.open||(P.current=RS(e.nativeEvent,F.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(A.current=!0),e.reason===`outside-press`){if(e.nested)A.current=!1;else if(av(e.nativeEvent)||ov(e.nativeEvent))A.current=!1;else{let e=!1;cb(B).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?A.current=!1:A.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&uv(t)!==`body`?t:null,s=n?o||a:a||o;return s||=US()||null,typeof i==`boolean`?s:LS(i)||s||null}return()=>{y.off(`openchange`,i);let t=Pv(e),n=ae(),r=Fv(v,t)||n.some(e=>e===t||Fv(e,t))||O&&vx(O.nodesRef.current,x(),!1).some(e=>Fv(e.context?.elements.floating,t)),o=T.current,s=P.current,c=a(s);queueMicrotask(()=>{let n=WS(c),i=typeof o!=`boolean`;if(o&&!A.current&&hv(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}A.current=!1})}},[r,v,B,T,E,y,O,_,x,ae]),X(()=>{if(!ev||g||!v)return;let e=Pv(cb(v));hv(e)&&fy(e)&&Fv(v,e)&&e.blur()},[g,v]),X(()=>{if(!r&&k)return k.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{k.setFocusManagerState(null)}},[r,k,s,g,h,c,_]),X(()=>{if(!r&&B)return GS(B),()=>{queueMicrotask(VS)}},[r,B]);let oe=!r&&(!s||!C)&&(re||s);return(0,Z.jsxs)(W.Fragment,{children:[oe&&(0,Z.jsx)(fb,{"data-type":`inside`,ref:R,onFocus:e=>{if(s){let e=ie();Sx(e[e.length-1])}else k?.portalNode&&(A.current=!1,hx(e,k.portalNode)?ux(_)?.focus():LS(d??k.beforeOutsideRef)?.focus())}}),n,oe&&(0,Z.jsx)(fb,{"data-type":`inside`,ref:ee,onFocus:e=>{s?Sx(ie()[0]):k?.portalNode&&(c&&(A.current=!0),hx(e,k.portalNode)?dx(_)?.focus():LS(u??k.afterOutsideRef)?.focus())}})]})}function qS(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Cy}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=W.useRef(void 0),f=sb(),p=H_(),m=W.useMemo(()=>{function e(e,t,n,r){let i=zy(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=sv(e.pointerType,!0)&&ov(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||sv(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=Iv(o);if(fy(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}sv(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return W.useMemo(()=>n?{reference:m}:P_,[n,m])}function JS(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function YS(e){return e!=null&&e.clientX!=null}function XS(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,l=W.useRef(!1),u=W.useRef(null),[d,f]=W.useState(),[p,m]=W.useState([]),h=Q(e=>{i.set(`positionReference`,e)}),g=Q((e,t,n)=>{l.current||(!c.current.openEvent||YS(c.current.openEvent))&&i.set(`positionReference`,JS(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:d}))}),_=Q(e=>{a?u.current||(g(e.clientX,e.clientY,e.currentTarget),m([])):g(e.clientX,e.clientY,e.currentTarget)}),v=sv(d)?o:a;W.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=dv(o);function r(t){let n=Iv(t);Fv(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||YS(c.current.openEvent)?u.current=Uy(t,`mousemove`,r):h(s),e},[v,n,o,c,s,i,g,h,p]),W.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),W.useEffect(()=>{n&&!o&&(l.current=!1)},[n,o]),W.useEffect(()=>{!n&&a&&(l.current=!0)},[n,a]);let y=W.useMemo(()=>{function e(e){f(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return W.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function ZS(){return!1}function QS(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function $S(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=ZS,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f,events:p}=l.context,m=NS(c),h=Q(typeof i==`function`?i:()=>!1),g=typeof i==`function`?h:i,_=g!==!1,v=Q(()=>a),{escapeKey:y,outsidePress:b}=QS(s),x=W.useRef(!1),S=W.useRef(!1),C=W.useRef(!1),w=W.useRef(!1),T=W.useRef(!1),E=W.useRef(``),D=W.useRef(null),O=H_(),k=H_(),A=Q(()=>{k.clear(),f.current.insideReactTree=!1}),j=Q(e=>{let t=f.current.floatingContext?.nodeId;return(m?vx(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=Q(e=>uy(e,l.select(`floatingElement`))||uy(e,l.select(`domReferenceElement`))),N=Q(e=>{o()&&l.setOpen(!1,zy(Cy,e.nativeEvent))}),P=Q(e=>{if(!u||!n||!r||e.key!==`Escape`||T.current||!y&&j(`__escapeKeyBubbles`))return;let t=zy(Ay,iv(e)?e.nativeEvent:e);l.setOpen(!1,t),t.isCanceled||e.preventDefault(),!y&&!t.isPropagationAllowed&&e.stopPropagation()}),F=Q(()=>{f.current.insideReactTree=!0,k.start(0,A)}),I=Q(e=>{if(!u||!n||e.button!==0)return;let t=Iv(e.nativeEvent);Fv(l.select(`floatingElement`),t)&&(x.current||(x.current=!0,S.current=!1))}),L=Q(e=>{u&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&x.current&&(S.current=!0)});W.useEffect(()=>{function e(e){e.open||(w.current=!1)}return p.on(`openchange`,e),()=>{p.off(`openchange`,e)}},[p]),W.useEffect(()=>{if(!u||!n)return u||(w.current=!1),A;f.current.__escapeKeyBubbles=y,f.current.__outsidePressBubbles=b;let e=new V_,t=new V_,i=cb(d);function a(){e.clear(),T.current=!0}function o(){e.start(ev?5:0,()=>{T.current=!1})}function s(){C.current=!0,t.start(0,()=>{C.current=!1})}function c(){x.current=!1,S.current=!1}function p(){let e=E.current,t=e===`pen`||!e?`mouse`:e,n=v(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function h(e){let t=p();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function k(e){let t=f.current.floatingContext?.nodeId,n=m&&vx(m.nodesRef.current,t).some(t=>uy(e,t.context?.elements.floating));return M(e)||n}function N(e){if(h(e)){e.type!==`click`&&!M(e)&&(t.clear(),C.current=!1),A();return}if(f.current.insideReactTree){A();return}let n=Iv(e),r=`[${bx(`inert`)}]`,i=mv(n)?n.getRootNode():null,a=Array.from((gv(i)?i:cb(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>Fv(e,n))))return;let s=mv(n)?n:null;for(;s&&!Dv(s);){let e=Av(s);if(Dv(e)||!mv(e))break;s=e}if(!(a.length&&mv(n)&&!dy(n)&&!Fv(n,l.select(`floatingElement`))&&a.every(e=>!Fv(s,e)))){if(hv(n)&&!(`touches`in e)){let t=Dv(n),r=Ov(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!k(e)){if(p()===`intentional`){if(e.detail!==0&&!av(e)&&!w.current)return;if(C.current){t.clear(),C.current=!1;return}}(typeof g!=`function`||g(e))&&(j(`__outsidePressBubbles`)||(l.setOpen(!1,zy(Ey,e)),A()))}}}function F(e){p()===`sloppy`&&e.pointerType!==`touch`&&l.select(`open`)&&n&&!M(e)&&N(e)}function I(e){if(p()!==`sloppy`||!l.select(`open`)||!n||M(e))return;let t=e.touches[0];t&&(D.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=Iv(e);if(!n)return;let r=Uy(n,e.type,()=>{t(e),r()})}function R(e){E.current=`touch`,L(e,I)}function ee(e){O.clear(),e.type===`pointerdown`&&(e.button===0&&(w.current=!0),E.current=e.pointerType),(e.type!==`mousedown`||!D.current||D.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function z(e){if(e.type===`pointercancel`&&(w.current=!1),!x.current)return;let n=S.current;if(c(),p()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!k(e)){if(n){s();return}(typeof g!=`function`||g(e))&&(t.clear(),C.current=!0,A())}}}function te(e){if(p()!==`sloppy`||!D.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-D.current.startX),r=Math.abs(t.clientY-D.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(D.current.dismissOnTouchEnd=!0),i>10&&(N(e),O.clear(),D.current=null)}function ne(e){L(e,te)}function re(e){p()===`sloppy`&&D.current&&!M(e)&&(D.current.dismissOnTouchEnd&&N(e),O.clear(),D.current=null)}function B(e){L(e,re)}let ie=Wy(r&&Wy(Uy(i,`keydown`,P),Uy(i,`compositionstart`,a),Uy(i,`compositionend`,o)),_&&Wy(Uy(i,`click`,ee,!0),Uy(i,`pointerdown`,ee,!0),Uy(i,`pointerup`,z,!0),Uy(i,`pointercancel`,z,!0),Uy(i,`mousedown`,ee,!0),Uy(i,`mouseup`,z,!0),Uy(i,`touchstart`,R,{capture:!0,passive:!0}),Uy(i,`touchmove`,ne,{capture:!0,passive:!0}),Uy(i,`touchend`,B,{capture:!0,passive:!0})));return()=>{ie(),e.clear(),t.clear(),c(),C.current=!1,A()}},[f,d,r,_,g,u,n,y,b,P,A,v,j,M,m,l,O]);let R=W.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),ee=W.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return W.useMemo(()=>n?{reference:R,floating:ee,trigger:R}:{},[n,R,ee])}function eC(e,t,n){let{reference:r,floating:i}=e,a=Tb(t),o=Eb(t),s=wb(o),c=xb(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Sb(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function tC(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=bb(t,e),p=Rb(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=zb(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=zb(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var nC=50,rC=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:tC},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=eC(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<nC&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=eC(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},iC=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=bb(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=xb(r),_=Tb(o),v=xb(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Ib(o)]:Ob(o)),x=p!==`none`;!d&&x&&b.push(...Fb(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Db(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Tb(t)||T.every(e=>Tb(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Tb(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},aC=new Set([`left`,`top`]);async function oC(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=xb(n),s=Sb(n),c=Tb(n)===`y`,l=aC.has(o)?-1:1,u=a&&c?-1:1,d=bb(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var sC=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await oC(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},cC=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=bb(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Tb(i),p=Cb(f),m=u[p],h=u[f],g=(e,t)=>yb(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},lC=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=bb(e,t),u={x:n,y:r},d=Tb(i),f=Cb(d),p=u[f],m=u[d],h=bb(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=aC.has(xb(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},uC=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=bb(e,t),c=await i.detectOverflow(t,s),l=xb(n),u=Sb(n),d=Tb(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=pb(p-c[m],g),y=pb(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*mb(c.left,c.right):S=p-2*mb(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function dC(e){let t=Ov(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=hv(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=hb(n)!==a||hb(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function fC(e){return mv(e)?e:e.contextElement}function pC(e){let t=fC(e);if(!hv(t))return _b(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=dC(t),o=(a?hb(n.width):n.width)/r,s=(a?hb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var mC=_b(0);function hC(e){let t=dv(e);return!Ev()||!t.visualViewport?mC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function gC(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===dv(e)}function _C(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=fC(e),o=_b(1);t&&(r?mv(r)&&(o=pC(r)):o=pC(e));let s=gC(a,n,r)?hC(a):_b(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=dv(a),t=mv(r)?dv(r):r,n=e,i=Nv(n);for(;i&&t!==n;){let e=pC(i),t=i.getBoundingClientRect(),r=Ov(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=dv(i),i=Nv(n)}}return zb({width:u,height:d,x:c,y:l})}function vC(e,t){let n=kv(e).scrollLeft;return t?t.left+n:_C(fv(e)).left+n}function yC(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-vC(e,n),y:n.top+t.scrollTop}}function bC(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=fv(r),s=t?yv(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=_b(1),u=_b(0),d=hv(r);if((d||!a)&&((uv(r)!==`body`||_v(o))&&(c=kv(r)),d)){let e=_C(r);l=pC(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?yC(o,c):_b(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function xC(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function SC(e){let t=kv(e),n=e.ownerDocument.body,r=mb(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=mb(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+vC(e),o=-t.scrollTop;return Ov(n).direction===`rtl`&&(a+=mb(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var CC=25;function wC(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=dv(e),a=fv(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Ev()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(vC(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=CC&&(s-=o)}return{width:s,height:c,x:l,y:u}}function TC(e,t){let n=_C(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=pC(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function EC(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=wC(e,n,t);else if(t===`document`)r=SC(fv(e));else if(mv(t))r=TC(t,n);else{let n=hC(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return zb(r)}function DC(e,t){let n=t.get(e);if(n)return n;let r=Mv(e,[],!1).filter(e=>mv(e)&&uv(e)!==`body`),i=null,a=Ov(e).position===`fixed`,o=a?Av(e):e;for(;mv(o)&&!Dv(o);){let e=Ov(o),t=wv(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Av(o)}return t.set(e,r),r}function OC(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?yv(t)?[]:DC(t,this._c):[].concat(n),r],o=EC(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=EC(t,a[e],i);s=mb(n.top,s),c=pb(n.right,c),l=pb(n.bottom,l),u=mb(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function kC(e){let{width:t,height:n}=dC(e);return{width:t,height:n}}function AC(e,t,n){let r=hv(t),i=fv(t),a=n===`fixed`,o=_C(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=_b(0);if((r||!a)&&((uv(t)!==`body`||_v(i))&&(s=kv(t)),r)){let e=_C(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=vC(i));let l=i&&!r&&!a?yC(i,s):_b(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function jC(e){return Ov(e).position===`static`}function MC(e,t){if(!hv(e)||Ov(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return fv(e)===n&&(n=n.ownerDocument.body),n}function NC(e,t){let n=dv(e);if(yv(e))return n;if(!hv(e)){let t=Av(e);for(;t&&!Dv(t);){if(mv(t)&&!jC(t))return t;t=Av(t)}return n}let r=MC(e,t);for(;r&&vv(r)&&jC(r);)r=MC(r,t);return r&&Dv(r)&&jC(r)&&!wv(r)?n:r||Tv(e)||n}var PC=async function(e){let t=this.getOffsetParent||NC,n=this.getDimensions,r=await n(e.floating);return{reference:AC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function FC(e){return Ov(e).direction===`rtl`}var IC={convertOffsetParentRelativeRectToViewportRelativeRect:bC,getDocumentElement:fv,getClippingRect:OC,getOffsetParent:NC,getElementRects:PC,getClientRects:xC,getDimensions:kC,getScale:pC,isElement:mv,isRTL:FC};function LC(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function RC(e,t,n){let r=null,i,a=fv(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=gb(d),h=gb(a.clientWidth-(u+f)),g=gb(a.clientHeight-(d+p)),_=gb(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:mb(0,pb(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!LC(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=dv(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function zC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=fC(e),u=i||a?[...l?Mv(l):[],...t?Mv(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?RC(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?_C(e):null;c&&g();function g(){let t=_C(e);h&&!LC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var BC=sC,VC=cC,HC=iC,UC=uC,WC=lC,GC=(e,t,n)=>{let r=new Map,i=n??{},a={...IC,...i.platform,_c:r};return rC(e,t,{...i,platform:a})},KC=typeof document<`u`?W.useLayoutEffect:function(){};function qC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!qC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!qC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function JC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function YC(e,t){let n=JC(e);return Math.round(t*n)/n}function XC(e){let t=W.useRef(e);return KC(()=>{t.current=e}),t}function ZC(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=W.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=W.useState(r);qC(f,r)||p(r);let[m,h]=W.useState(null),[g,_]=W.useState(null),v=W.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=W.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=W.useRef(null),C=W.useRef(null),w=W.useRef(u),T=c!=null,E=XC(c),D=XC(i),O=XC(l),k=W.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),GC(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!qC(w.current,t)&&(w.current=t,SS.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);KC(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=W.useRef(!1);KC(()=>(A.current=!0,()=>{A.current=!1}),[]),KC(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=W.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=W.useMemo(()=>({reference:b,floating:x}),[b,x]),N=W.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=YC(M.floating,u.x),r=YC(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...JC(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return W.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var QC=(e,t)=>{let n=BC(e);return{name:n.name,fn:n.fn,options:[e,t]}},$C=(e,t)=>{let n=VC(e);return{name:n.name,fn:n.fn,options:[e,t]}},ew=(e,t)=>({fn:WC(e).fn,options:[e,t]}),tw=(e,t)=>{let n=HC(e);return{name:n.name,fn:n.fn,options:[e,t]}},nw=(e,t)=>{let n=UC(e);return{name:n.name,fn:n.fn,options:[e,t]}},rw=o((e=>{var t=u();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),iw=o(((e,t)=>{t.exports=rw()})),aw=o((e=>{var t=u(),n=iw();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),ow=o(((e,t)=>{t.exports=aw()})),sw=iw(),cw=ow(),lw=Bx(19)?fw:pw;function uw(e,t,n,r,i){return lw(e,t,n,r,i)}function dw(e,t,n,r,i){let a=W.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,sw.useSyncExternalStore)(e.subscribe,a,a)}O_({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,sw.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function fw(e,t,n,r,i){let a=D_();if(!a)return dw(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function pw(e,t,n,r,i){return(0,cw.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var mw=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return uw(this,e,t,n,r)}},hw=class extends mw{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){W.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;X(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){W.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return W.useDebugValue(e),uw(this,this.selectors[e],t,n,r)}useContextCallback(e,t){W.useDebugValue(e);let n=Q(t??M_);this.context[e]=n}useStateSetter(e){let t=W.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},gw={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},_w=class extends hw{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:OS(),nested:n,triggerElements:i},gw),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&cv(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function vw(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=t.context.triggerElements,d=o,f=W.useRef(null);r===void 0&&f.current===null&&(f.current=new _w({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),X(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};mv(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function yw(e,t=!1,n=!1,r=!1){let[i,a]=W.useState(e&&t?`idle`:void 0),[o,s]=W.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),X(()=>{if(!e&&o&&i!==`ending`&&n){let e=ob.request(()=>{a(`ending`)});return()=>{ob.cancel(e)}}},[e,o,i,n]),X(()=>{if(!e||t)return;let n=ob.request(()=>{a(void 0)});return()=>{ob.cancel(n)}},[t,e]),X(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=ob.request(()=>{a(`idle`)});return()=>{ob.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var bw=null;function xw(e){if(!bw){let e=[];bw=e,queueMicrotask(()=>{bw=null,SS.flushSync(()=>{for(let t of e)t()})})}bw.push(e)}function Sw(e,t=!1,n=!1){let r=sb();return Q((i,a=null)=>{r.cancel();let o=LS(e);if(o==null)return;let s=o,c=()=>{if(!n){SS.flushSync(i);return}xw(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(s.getAnimations().some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=Uv;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function Cw(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=Q(a),s=Sw(r,n,i);W.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}var ww={tabIndex:-1,[Lv]:``};function Tw(e){return t=>t!==`touch`||e.current}function Ew(e,t=!1){let n=Rx(),r=MS()!=null,i=w_(()=>e(n,r)).current;return vw({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Dw({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function Ow(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function kw(e,t){let n=W.useRef(null);return Q(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),Ow(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Ow(t))})}function Aw(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function jw(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Mw(e,t,n,r={}){let i=n.reason,a=i===wy,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=jw(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=Aw(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?SS.flushSync(l):l()}function Nw(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=kw(e,n),o=Q(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=Q(e=>{a(e),e&&o(e)});return X(()=>(s(t.current),()=>s(null)),[s,t,n,e]),X(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Pw(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=W.useRef(null),i=e.useState(`open`);X(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=zy(Sy);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function Fw(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=yw(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=Q(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return Cw({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function Iw(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:P_,inactiveTriggerProps:P_,popupProps:P_})},[e])}function Lw(e,t){X(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),X(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Rw=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function zw(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new _w({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:P_,inactiveTriggerProps:P_,popupProps:P_}}var Bw=e=>e.triggerIdProp??e.activeTriggerId,Vw=e=>e.openProp??e.open,Hw=e=>(e.popupElement?.id??e.floatingId)||void 0;function Uw(e,t){return t!==void 0&&Vw(e)&&Bw(e)===t}function Ww(e,t){return Uw(e,t)?!0:t!==void 0&&Vw(e)&&Bw(e)==null&&e.triggerCount===1}var Gw={open:Vw,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Bw,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Hw,isTriggerActive:(e,t)=>t!==void 0&&Bw(e)===t,isOpenedByTrigger:(e,t)=>Uw(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Bw(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Ww(e,t)?Hw(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Kw(e){let t=W.useCallback(t=>e===void 0?M_:e.subscribeStore(t),[e]),n=W.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,sw.useSyncExternalStore)(t,n,()=>e?.serverStore)}function qw(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Rx(),a=MS()!=null,o=w_(()=>new _w({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Rw,floatingId:i,syncOnly:!1,nested:a})).current;return X(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=mv(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function Jw(e){return Yw(e,e.rootContext)}function Yw(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=W.useState(null),[d,f]=W.useState(void 0),[p,m]=W.useState(void 0),h=W.useRef(null),g=NS(r),_=W.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=ZC({...e,elements:{..._,...l&&{reference:l}}}),y=mv(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=W.useCallback(e=>{let t=mv(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=W.useCallback(e=>{(mv(e)||e===null)&&(h.current=e,f(e)),(mv(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!mv(e))&&v.refs.setReference(e)},[v.refs,f]),C=W.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=W.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=W.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=W.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return X(()=>{o&&(h.current=o)},[o]),X(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),W.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}var Xw=Q_&&ev;function Zw(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=W.useRef(!1),c=W.useRef(null),l=W.useRef(!0),u=H_();W.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=dv(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&hv(e)&&e===Pv(cb(e))&&(s.current=!0,c.current=e)}function a(){l.current=!0}function o(){l.current=!1}return Wy(Uy(t,`blur`,r),Xw&&Uy(t,`keydown`,a,!0),Xw&&Uy(t,`pointerdown`,o,!0))},[i,n]),W.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);mv(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let d=W.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Iv(t.nativeEvent);if(mv(a)){if(Xw&&!t.relatedTarget){if(!l.current&&!fy(a))return}else if(!hy(a))return}let o=ly(t.relatedTarget,i.context.triggerElements),{nativeEvent:d,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,zy(Ty,d,f));return}u.start(p,()=>{s.current||i.setOpen(!0,zy(Ty,d,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=mv(n)&&n.hasAttribute(bx(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=Pv(cb(e));(n||t!==e)&&(Fv(o.current.floatingContext?.refs.floating.current,t)||Fv(e,t)||a||ly(n??t,i.context.triggerElements)||i.setOpen(!1,zy(Ty,r)))})}}},[o,r,i,u]);return W.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var Qw=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new V_,this.restTimeout=new V_,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},$w=new WeakMap;function eT(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&$w.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),$w.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function tT(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=$w.get(n);a&&a!==e&&eT(a),eT(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,$w.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function nT(e){let t=e.context.dataRef.current,n=w_(()=>t.hoverInteractionState??Qw.create()).current;return t.hoverInteractionState||=n,z_(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function rT(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:l}=a.context,u=NS(),d=MS(),f=nT(a),p=H_(),m=Q(()=>by(l.current.openEvent?.type,f.interactedInside)),h=Q(()=>xy(l.current.openEvent?.type)),g=Q(()=>{eT(f)});X(()=>{o||(f.pointerType=void 0,f.restTimeoutPending=!1,f.interactedInside=!1,g())},[o,f,g]),W.useEffect(()=>g,[g]),X(()=>{if(n&&o&&f.handleCloseOptions?.blockPointerEvents&&h()&&mv(c)&&s){let e=c,t=s,n=cb(s),r=u?.nodesRef.current.find(e=>e.id===d)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=f.pointerEventsScopeElement===t?null:f.pointerEventsScopeElement,a=r===t?null:r,o=f.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return tT(f,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,o,c,s,f,h,u,d,g]),W.useEffect(()=>{if(!n)return;function e(){return!!(u&&d&&vx(u.nodesRef.current,d).length>0)}function t(e){let t=vy(r,`close`,f.pointerType),n=()=>{a.setOpen(!1,zy(wy,e)),u?.events.emit(`floating.closed`,e)};t?f.openChangeTimeout.start(t,n):(f.openChangeTimeout.clear(),n())}function o(e){let t=Iv(e);if(!py(t)){f.interactedInside=!1;return}f.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){f.openChangeTimeout.clear(),p.clear(),u?.events.off(`floating.closed`,v),g()}function _(n){if(e()&&u){u.events.on(`floating.closed`,v);return}if(ly(n.relatedTarget,a.context.triggerElements))return;let r=l.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(u&&r&&mv(o)&&vx(u.nodesRef.current,r,!1).some(e=>Fv(e.context?.elements.floating,o)))){if(f.handler){f.handler(n);return}g(),h()&&!m()&&t(n)}}function v(t){u&&d&&!e()&&p.start(0,()=>{u.events.off(`floating.closed`,v),a.setOpen(!1,zy(wy,t)),u.events.emit(`floating.closed`,t)})}let y=s;return Wy(y&&Uy(y,`mouseenter`,c),y&&Uy(y,`mouseleave`,_),y&&Uy(y,`pointerdown`,o,!0),()=>{u?.events.off(`floating.closed`,v)})},[n,s,a,l,r,i,h,m,g,f,u,d,p])}var iT={current:null};function aT(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=iT,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,h=`rootStore`in e?e.rootStore:e,{dataRef:g,events:_}=h.context,v=NS(l),y=nT(h),b=W.useRef(!1),x=Zy(i),S=Zy(r),C=Zy(o),w=Zy(n),T=Zy(p),E=Zy(f),D=Q(()=>by(g.current.openEvent?.type,y.interactedInside)),O=Q(()=>T.current?.()!==!1),k=Q((e,t,n)=>{let r=h.context.triggerElements;if(r.hasElement(t))return!e||!Fv(e,t);if(!mv(n))return!1;let i=n;return r.hasMatchingElement(e=>Fv(e,i))&&(!e||!Fv(e,i))}),A=Q(()=>{y.handler&&=(cb(h.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),j=Q(()=>{eT(y)});return u&&(y.handleCloseOptions=i?.__options),W.useEffect(()=>A,[A]),W.useEffect(()=>{if(!n)return;function e(e){e.open?b.current=!1:(b.current=e.reason===wy,A(),y.openChangeTimeout.clear(),y.restTimeout.clear(),y.blockMouseMove=!0,y.restTimeoutPending=!1)}return _.on(`openchange`,e),()=>{_.off(`openchange`,e)}},[n,_,y,A]),W.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=vy(S.current,`close`,y.pointerType);n?y.openChangeTimeout.start(n,()=>{h.setOpen(!1,zy(wy,e)),v?.events.emit(`floating.closed`,e)}):t&&(y.openChangeTimeout.clear(),h.setOpen(!1,zy(wy,e)),v?.events.emit(`floating.closed`,e))}let t=c.current??(u?h.select(`domReferenceElement`):null);if(!mv(t))return;function r(e){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!sv(y.pointerType))return;let t=yy(C.current),n=vy(S.current,`open`,y.pointerType),r=Iv(e),i=e.currentTarget??null,o=h.select(`domReferenceElement`),s=i;if(mv(r)&&!h.context.triggerElements.hasElement(r)){for(let e of h.context.triggerElements.elements())if(Fv(e,r)){s=e;break}}mv(i)&&mv(o)&&!h.context.triggerElements.hasElement(i)&&Fv(i,o)&&(s=o);let c=s!=null&&k(o,s,r),l=h.select(`open`),u=E.current?.()??h.select(`transitionStatus`)===`ending`,d=!l&&u&&b.current,f=!c&&mv(s)&&mv(o)&&Fv(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,g=!l||c;if(m){O()&&h.setOpen(!0,zy(wy,e,s));return}p||(n?y.openChangeTimeout.start(n,()=>{g&&O()&&h.setOpen(!0,zy(wy,e,s))}):g&&O()&&h.setOpen(!0,zy(wy,e,s)))}function i(t){if(D()){j();return}A();let n=cb(h.select(`domReferenceElement`));y.restTimeout.clear(),y.restTimeoutPending=!1;let r=g.current.floatingContext??d?.();if(!ly(t.relatedTarget,h.context.triggerElements)){if(x.current&&r){h.select(`open`)||y.openChangeTimeout.clear();let i=c.current;y.handler=x.current({...r,tree:v,x:t.clientX,y:t.clientY,onClose(){j(),A(),w.current&&!D()&&i===h.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,y.handler),y.handler(t);return}(y.pointerType!==`touch`||!Fv(h.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Fv(t,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let l=m?Uy(t,`mouseout`,o):void 0;return s?Wy(Uy(t,`mousemove`,r,{once:!0}),Uy(t,`mouseenter`,r),Uy(t,`mouseleave`,i),l):Wy(Uy(t,`mouseenter`,r),Uy(t,`mouseleave`,i),l)},[A,j,g,S,h,n,x,y,u,k,D,a,s,C,c,v,w,d,E,O,m]),W.useMemo(()=>{if(!n)return;function e(e){y.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=h.select(`domReferenceElement`),i=h.select(`open`),o=k(r,n,e.target);if(a&&!sv(y.pointerType))return;if(i&&o&&y.handleCloseOptions?.blockPointerEvents){let e=h.select(`floatingElement`);if(e){let t=y.handleCloseOptions?.getScope?.()??n.ownerDocument.body;tT(y,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=yy(C.current);if(i&&!o||s===0||!o&&y.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;y.restTimeout.clear();function c(){if(y.restTimeoutPending=!1,D())return;let e=h.select(`open`);!y.blockMouseMove&&(!e||o)&&O()&&h.setOpen(!0,zy(wy,t,n))}y.pointerType===`touch`?SS.flushSync(()=>{c()}):o&&i?c():(y.restTimeoutPending=!0,y.restTimeout.start(s,c))}}},[n,y,D,k,a,h,C,O])}var oT=`Escape`;function sT(e){return ev&&e.movementX===0&&e.movementY===0}function cT(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function lT(e,t){return cT(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function uT(e,t,n){return cT(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function dT(e,t,n){return cT(t,n?e===zv:e===Bv,e===Hv)}function fT(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===oT:cT(t,n?e===Bv:e===zv,e===Vv)}function pT(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,O=gy(T),k=my(E),A=Zy(O),j=MS(),M=NS(b),N=W.useRef(f),P=W.useRef(o??-1),F=W.useRef(null),I=W.useRef(!0),L=Q(e=>{i(P.current===-1?null:P.current,e)}),R=W.useRef(!!T),ee=W.useRef(w),z=W.useRef(!1),te=W.useRef(!1),ne=W.useRef(null),re=Zy(h),B=Zy(w),ie=Zy(o),ae=Zy(y),oe=sb(),se=sb(),ce=Q(()=>{function e(e){d?M?.events.emit(`virtualfocus`,e):ne.current=Sx(e,{sync:z.current,preventScroll:!0})}let t=n.current[P.current],r=te.current;t&&e(t),(z.current?e=>e():e=>oe.request(e))(()=>{let i=n.current[P.current]||t;i&&(t||e(i),fe&&(r||!I.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{D.current.orientation=g},[D,g]),X(()=>{a&&(w&&T?(P.current=o??-1,N.current&&o!=null&&(te.current=!0,L())):R.current&&(P.current=-1,L()))},[a,w,T,o,L]),X(()=>{if(a){if(!w){z.current=!1;return}if(T){if(r==null){if(z.current=!1,ie.current!=null)return;if(R.current&&(P.current=-1,ce()),(!ee.current||!R.current)&&N.current&&(F.current!=null||N.current===!0&&F.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>se.request(e):queueMicrotask)(t),e+=1):(P.current=F.current==null||uT(F.current,g,u)||l?Vb(n):Hb(n),F.current=null,L())};t()}}else Bb(n.current,r)||(P.current=r,ce(),te.current=!1)}}},[a,w,T,r,ie,l,n,g,u,L,ce,se]),X(()=>{if(!a||T||!M||d||!R.current)return;let e=M.nodesRef.current,t=e.find(e=>e.id===j)?.context?.elements.floating,n=Pv(cb(E??t??null)),r=e.some(e=>e.context&&Fv(e.context.elements.floating,n));t&&!r&&I.current&&t.focus({preventScroll:!0})},[a,T,E,M,j,d]),X(()=>{ee.current=w,R.current=!!T}),X(()=>{w||(F.current=null,N.current=f)},[w,f]);let le=r!=null,V=Q(e=>{if(!B.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(P.current!==t||r!==t)&&(P.current=t,L(e))}),H=Q(()=>_??M?.nodesRef.current.find(e=>e.id===j)?.context?.dataRef?.current.orientation),ue=Q(()=>Vb(n,re.current)),de=Q(e=>{if(I.current=!1,z.current=!0,e.which===229||!B.current&&e.currentTarget===A.current)return;if(l&&fT(e.key,g,u,S)){lT(e.key,H())||rv(e),C.setOpen(!1,zy(My,e.nativeEvent)),hv(E)&&(d?M?.events.emit(`virtualfocus`,E):E.focus());return}let t=P.current,r=Vb(n,h),i=Hb(n,h);if(k||(e.key===`Home`&&(rv(e),P.current=r,L(e)),e.key===`End`&&(rv(e),P.current=i,L(e))),x!=null){let t=x(e,P.current,n,g,c,u,h,r,i);if(t!=null&&(P.current=t,L(e)),g===`both`)return}if(lT(e.key,g)){if(rv(e),w&&!d&&Pv(e.currentTarget.ownerDocument)===e.currentTarget){P.current=uT(e.key,g,u)?r:i,L(e);return}uT(e.key,g,u)?c?t>=i?s&&t!==n.current.length?P.current=-1:(z.current=!1,P.current=r):P.current=Ub(n.current,{startingIndex:t,disabledIndices:h}):P.current=Math.min(i,Ub(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?P.current=n.current.length:(z.current=!1,P.current=i):P.current=Ub(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):P.current=Math.max(r,Ub(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),Bb(n.current,P.current)&&(P.current=-1),L(e)}}),fe=W.useMemo(()=>({onFocus(e){z.current=!0,V(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){sT(e)||(z.current=!0,te.current=!1,p&&V(e))},onPointerLeave(e){if(!B.current||!I.current||e.pointerType===`touch`)return;z.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&ae.current&&(ne.current?.(),ne.current=null,P.current=-1,L(e),!d)){let e=A.current,t=Pv(cb(e));e&&Fv(e,t)&&e.focus({preventScroll:!0})}}}),[V,B,A,p,n,L,ae,d]),U=W.useMemo(()=>d&&w&&le&&{"aria-activedescendant":`${v}-${r}`},[d,w,le,v,r]),pe=W.useMemo(()=>({...k?{}:U,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=Iv(e.nativeEvent);if(t&&!Fv(A.current,t))return;rv(e),C.setOpen(!1,zy(ky,e.nativeEvent)),hv(E)&&E.focus();return}de(e)},onPointerMove(e){sT(e)||(I.current=!0)}}),[U,de,A,k,C,w,d,E]),me=W.useMemo(()=>{function e(e){C.setOpen(!0,zy(My,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&av(e.nativeEvent)&&(N.current=!d)}function n(e){N.current=f,f===`auto`&&ov(e.nativeEvent)&&(N.current=!0)}return{onKeyDown(t){let n=C.select(`open`);I.current=!1;let r=t.key.startsWith(`Arrow`),i=dT(t.key,H(),u),a=lT(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return de(t);if(n||m||!r){if(o){let e=lT(t.key,H());F.current=l&&e?null:t.key}if(l){i&&(rv(t),n?(P.current=ue(),L(t)):e(t));return}a&&(ie.current!=null&&(P.current=ie.current),rv(t),!n&&m?e(t):de(t),n&&L(t))}},onFocus(e){C.select(`open`)&&!d&&(P.current=-1,L(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[de,f,ue,l,L,C,m,g,H,u,ie,d]),he=W.useMemo(()=>({...U,...me}),[U,me]);return W.useMemo(()=>a?{reference:he,floating:pe,item:fe,trigger:me}:{},[a,he,pe,me,fe])}function mT(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=H_(),m=W.useRef(``),h=W.useRef(u??i??-1),g=W.useRef(null),_=Q(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!Kb(n)||n?.matches(`:disabled`)?!1:o==null||!Wb(N_,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(rv(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(rv(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=Q(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);Fv(n,t)||Fv(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=W.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return W.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var hT=.1,gT=hT*hT,_T=.5;function vT(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function yT(e,t,n,r,i,a,o,s,c,l){let u=!1;return vT(e,t,n,r,i,a)&&(u=!u),vT(e,t,i,a,o,s)&&(u=!u),vT(e,t,o,s,c,l)&&(u=!u),vT(e,t,c,l,n,r)&&(u=!u),u}function bT(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function xT(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function ST(e={}){let{blockPointerEvents:t=!1}=e,n=new V_,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*gT;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Iv(r),g=r.type===`mouseleave`,_=Fv(u,h),v=Fv(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&mv(r.relatedTarget)&&Fv(u,r.relatedTarget))return;function y(){return!!(s&&vx(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=xT(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=xT(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=xT(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=xT(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!bT(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?_T/2:_T*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+_T+1,o=C||T?S.bottom-_T:S.top,s=C?T?S.bottom-_T:S.top:S.bottom-_T;M=yT(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?_T/2:_T*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-_T,o=C||T?S.top+_T:S.bottom,s=C?T?S.top+_T:S.bottom:S.top+_T;M=yT(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?_T/2:_T*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+_T+1,o=w||E?S.right-_T:S.left,s=w?E?S.right-_T:S.left:S.right-_T;M=yT(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?_T/2:_T*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-_T,o=w||E?S.left+_T:S.right,s=w?E?S.left+_T:S.right:S.left+_T;M=yT(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}var CT={...Gw,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},wT=class extends hw{constructor(e,t,n){let r=new Rw;super(TT(e,r,t,n),ET(r),CT)}setOpen=(e,t)=>{Mw(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,zy(Cy,e))}};function TT(e,t,n,r=!1){return{...zw(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function ET(e){return{popupRef:W.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var DT=k_(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=Ew((e,t)=>new wT({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Pw(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=Fw(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=W.useRef(null);X(()=>{m&&t&&p.setOpen(!1,zy(Fy))},[m,t,p]),X(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),X(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),W.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,zy(Iy))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,Z.jsxs)(L_.Provider,{value:p,children:[l&&(0,Z.jsx)(Dw,{handle:l,store:p}),T&&(0,Z.jsx)(OT,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function OT({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=$S(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=XS(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=W.useMemo(()=>qx(a.reference,i.reference),[a.reference,i.reference]);return Iw(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??P_}),null}function kT(e){return Rx(e,`base-ui`)}var AT=W.createContext(void 0);function jT(){return W.useContext(AT)}var MT=`data-base-ui-tooltip-trigger`;function NT(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(mv(n))return n}}let t=e.target;return mv(t)?t:null}function PT(e){let t=e;for(;t;){let e=t.closest(`[${MT}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&mv(n.host)?n.host:null}return null}var FT=A_(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=R_(!0),m=Kw(a)??p;if(!m)throw Error(I_(82));let h=kT(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=W.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=Nw(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=jT(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=Hy(v,{open:_}),O=nT(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Zy(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=W.useRef(!1),F=H_(),I=W.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=PT(e);return n!==null&&n!==t&&Fv(t,n)}function ee(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let z=aT(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?ST():null,restMs:L,delay(){return u==null&&D?{close:vy(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),te=Zw(v,{enabled:!A}).reference,ne=e=>{let t=P.current,n=NT(e),r=ee(n),i=y.current,a=i&&n&&Fv(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`){m.setOpen(!1,zy(wy,e));return}if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&sv(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,zy(wy,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},re=m.useState(`triggerProps`,S);return sS(`button`,e,{state:{open:_},ref:[t,x,y],props:[z,te,S||M!==`none`?re:void 0,{onMouseOver(e){ne(e.nativeEvent)},onFocus(e){R(NT(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[cy]:A?``:void 0,[MT]:A?void 0:``},f],stateAttributesMapping:iy})}),IT=W.createContext(void 0);function LT(){let e=W.useContext(IT);if(e===void 0)throw Error(I_(70));return e}var RT=W.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=ES({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,Z.jsxs)(W.Fragment,{children:[l,c&&SS.createPortal(n,c)]})}),zT=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return R_().useState(`mounted`)||n?(0,Z.jsx)(IT.Provider,{value:n,children:(0,Z.jsx)(RT,{ref:t,...r})}):null}),BT=W.createContext(void 0);function VT(){let e=W.useContext(BT);if(e===void 0)throw Error(I_(71));return e}var HT=W.createContext(void 0);function UT(){return W.useContext(HT)?.direction??`ltr`}var WT=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d=`real`}=bb(e,t)||{};if(l==null)return{};let f=Rb(u),p={x:n,y:r},m=Eb(i),h=wb(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=yb(k,j,A),N=!c.arrow&&Sb(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),GT=(e,t)=>{let{name:n,fn:r}=WT(e);return{name:n,fn:r,options:[e,t]}},KT={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},qT={sideX:`left`,sideY:`top`},JT=`--available-width`,YT=`--available-height`,XT=`--anchor-width`,ZT=`--anchor-height`,QT=`--transform-origin`,$T=JT,eE=YT;function tE(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function nE(e,t,n){let{rects:r,placement:i}=e;return{side:tE(t,xb(i),n),align:Sb(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function rE(e){return iE(e,Jw)}function iE(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,[C,w]=W.useState(null);!g&&C!==null&&w(null);let T=_.side||`flip`,E=_.align||`flip`,D=_.fallbackAxisSide||`end`,O=v?.crossAxis??!1,k=v?.rootBoundary,A=typeof n==`function`?n:void 0,j=Q(A),M=A?j:n,N=Zy(n),P=Zy(g),F=UT()===`rtl`,I=C||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],L=o===`center`?I:`${I}-${o}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let ee=+(i===`bottom`),z=+(i===`top`),te=+(i===`right`),ne=+(i===`left`),re={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},B=W.useRef(null),ie=Zy(a),ae=Zy(s),oe=typeof a==`function`?0:a,se=typeof s==`function`?0:s,ce=[];p&&ce.push(p),ce.push(QC(e=>{let t=nE(e,i,F),n=typeof ie.current==`function`?ie.current(t):ie.current,r=typeof ae.current==`function`?ae.current(t):ae.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[oe,se,F,i]));let le=E===`none`&&T!==`shift`,V=!le&&(u||O||T===`shift`),H=T===`none`?null:tw({...re,padding:{top:R.top+1+ee,right:R.right+1+ne,bottom:R.bottom+1+z,left:R.left+1+te},mainAxis:!O&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:D}),ue=le?null:$C({...re,rootBoundary:k,mainAxis:E!==`none`,crossAxis:V,limiter:u||O?void 0:ew(e=>{if(!B.current)return{};let{width:t,height:n}=B.current.getBoundingClientRect(),r=Tb(xb(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[re,u,O,k,R,E]);T===`shift`||E===`shift`||o===`center`?ce.push(ue,H):ce.push(H,ue),ce.push(nw({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty($T,`${t}px`),i.setProperty(eE,`${n}px`);let a=dv(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(XT,`${u}px`),i.setProperty(ZT,`${d}px`)}}),GT(e=>({element:B.current||cb(e.elements.floating).createElement(`div`),padding:B.current?d:0,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=xb(r),u=Sb(r),d=Tb(l)===`y`,f=B.current,p=typeof a==`function`?a(nE(e,i,F)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return V&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(QT,d?`${m} ${h}`:`${h} ${m}`),{}}},KT,b),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let de=W.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:fe,elements:U,x:pe,y:me,middlewareData:he,update:ge,placement:_e,context:ve,isPositioned:ye,floatingStyles:be}=t({rootContext:h,open:m?g:void 0,placement:L,middleware:ce,strategy:r,whileElementsMounted:m?void 0:(...e)=>zC(...e,de),nodeId:y,externalTree:S}),{sideX:xe,sideY:Se}=he.adaptiveOrigin||qT,Ce=ye?r:`fixed`,we=W.useMemo(()=>{let e;return e=ye?b?{position:Ce,[xe]:pe,[Se]:me}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[$T]=`100vw`,e[eE]=`100vh`,ye||(e.opacity=0),e},[b,Ce,xe,pe,Se,me,be,ye]),Te=W.useRef(null);X(()=>{if(!g)return;let e=N.current,t=typeof e==`function`?e():e,n=(aE(t)?t.current:t)||null;n!==Te.current&&(fe.setPositionReference(n),Te.current=n)},[g,fe,M,N]),W.useEffect(()=>{if(!g)return;let e=N.current;typeof e!=`function`&&aE(e)&&e.current!==Te.current&&(fe.setPositionReference(e.current),Te.current=e.current)},[g,fe,M,N]),W.useEffect(()=>{if(m&&g&&U.reference&&U.floating)return zC(U.reference,U.floating,ge,de)},[m,g,U,ge,de]);let Ee=xb(_e),De=tE(i,Ee,F),Oe=Sb(_e)||`center`,ke=!!he.hide?.referenceHidden;X(()=>{x&&g&&ye&&Ee!==I&&w(Ee)},[x,g,ye,Ee,I]);let Ae=W.useMemo(()=>({position:`absolute`,top:he.arrow?.y,left:he.arrow?.x}),[he.arrow]),je=he.arrow?.centerOffset!==0;return W.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:B,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:fe,context:ve,isPositioned:ye,update:ge}),[we,Ae,B,je,De,Oe,Ee,ke,fe,ve,ye,ge])}function aE(e){return e!=null&&`current`in e}function oE(e){return e===`starting`?mS:P_}function sE(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),sS(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},oE(r),i],stateAttributesMapping:oy})}var cE=W.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=bS,style:g,..._}=e,v=R_(),y=LT(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=rE({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=sE(e,W.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,Z.jsx)(BT.Provider,{value:D,children:O})}),lE=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=R_(),{side:s,align:c}=VT(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);Cw({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),rT(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return sS(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[ww,f,oE(d),a],stateAttributesMapping:sy})});function uE(e){return Bx(19)?e:e?`true`:void 0}function dE(e){let[t,n]=W.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function fE(e){let t=W.useRef(!0);t.current&&(t.current=!1,e())}function pE(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function mE({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=W.useRef(e!==void 0),[a,o]=W.useState(t);return[i&&e!==void 0?e:a,W.useCallback(e=>{i||o(e)},[])]}var hE=W.createContext(void 0),gE=W.createContext(void 0),_E=W.createContext(void 0);function vE(){let e=W.useContext(hE);if(e===void 0)throw Error(I_(60));return e}function yE(){let e=W.useContext(gE);if(e===void 0)throw Error(I_(101));return e}function bE(){let e=W.useContext(_E);if(e===void 0)throw Error(I_(61));return e}var xE=`data-valid`,SE=`data-invalid`,CE={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},wE={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},TE={valid(e){return e===null?null:e?{[xE]:``}:{[SE]:``}}},EE={invalid:void 0,name:void 0,validityData:{state:CE,errors:[],error:``,value:``,initialValue:null},setValidityData:M_,disabled:void 0,setTouched:M_,setDirty:M_,setFilled:M_,setFocused:M_,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:wE,registerFieldControl:M_,validation:{getValidationProps:(e,t=P_)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:M_,getInputControl:()=>null,commit:async()=>{},change:M_}},DE=W.createContext(EE);function OE(e=!0){let t=W.useContext(DE);if(t.setValidityData===M_&&!e)throw Error(I_(28));return t}function kE(e,t,n,r,i=!0,a){let{registerFieldControl:o}=OE(),s=w_(()=>Symbol());X(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),X(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var AE=W.createContext({controlId:void 0,registerControlId:M_,resetControlId:M_,labelId:void 0,setLabelId:M_,messageIds:[],setMessageIds:M_,getDescriptionProps:e=>e});function jE(){return W.useContext(AE)}function ME(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=jE(),o=kT(),s=w_(()=>Symbol()),c=W.useRef(!1),l=W.useRef(!1),u=Q(()=>{c.current&&i!==M_&&(c.current=!1,i(s.current,void 0))});return X(()=>{if(!n||i===M_){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}if(e===void 0){u();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,u]),X(()=>u,[u]),(n?r:void 0)??t??o}function NE(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var PE=(e,t)=>Object.is(e,t);function FE(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function IE(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!NE(e,t,(e,t)=>FE(e,t,n)):e!==t}function LE(e,t,n){return e?e.some(e=>e!==void 0&&FE(t,e,n)):!1}function RE(e,t,n){return e?e.findIndex(e=>e!==void 0&&FE(e,t,n)):-1}function zE(e,t){if(t!==PE)return n=>LE(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function BE(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(zE(t,n)):RE(e,t,n);return i===-1?null:i}function VE(e,t,n,r,i,a){return LE(r,t,i)?a!=null&&e>a&&LE(r,n[a],i)?a:e:e===a?BE(n,r,i,!0):a}function HE(e,t,n){return e.filter(e=>!FE(t,e,n))}function UE(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function WE(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function GE(e){return WE(e?.[0])}function KE(e){return GE(e)?e.flatMap(e=>e.items):e}function qE(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(GE(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function JE(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return UE(e)}function YE(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?UE(e.value):UE(e)}function XE(e,t,n){function r(){return JE(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=KE(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function ZE(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Z.jsx)(W.Fragment,{children:XE(r,t,n)},i)),e),[])}var QE={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:YE(t,r)!==``},hasNullItemLabel:(e,t)=>t?qE(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>FE(t,e,n)):FE(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},$E=W.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:M_,validationMode:`onSubmit`,submitCountRef:{current:0}});function eD(){return W.useContext($E)}function tD(e,t){let n=W.useRef(e),r=Q(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function nD(e){let t=W.useRef(``),n=W.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:W.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function rD(e,t){let{onClick:n,onPointerDown:r}=nD(Q((n,r)=>{(typeof e==`function`?e():e)||t(r||(Y_?`touch`:``))}));return W.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function iD(e){let[t,n]=W.useState(null),r=rD(e,n);return tD(e,t=>{t&&!e&&n(null)}),W.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function aD(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function oD(e,t){return Math.max(0,e-t)}function sD(e,t){if(t<=0)return 0;let n=aD(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function cD(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=PE,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=eD(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=OE(),F=ME({id:t}),I=M||d,L=j??c,[R,ee]=mE({controlled:n,default:y?r??N_:r,name:`Select`,state:`value`}),[z,te]=mE({controlled:a,default:o,name:`Select`,state:`open`}),ne=W.useRef([]),re=W.useRef([]),B=W.useRef(null),ie=W.useRef(null),ae=W.useRef(0),oe=W.useRef(null),se=W.useRef([]),ce=W.useRef(!1),le=W.useRef(null),V=W.useRef(null),H=W.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ue=W.useRef(!1),de=W.useRef(R),{mounted:fe,setMounted:U,transitionStatus:pe}=yw(z),{openMethod:me,triggerProps:he}=iD(z),ge=w_(()=>new hw({id:F,labelId:void 0,modal:m,multiple:y,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:z,mounted:fe,transitionStatus:pe,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:P_,triggerProps:P_,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:M_,setOpen:M_,handleScrollArrowVisibility:M_,onOpenChangeComplete:M_,listRef:ne,popupRef:B,scrollHandlerRef:ie,scrollArrowsMountedCountRef:ae,valueRef:oe,valuesRef:se,labelsRef:re,typingRef:ce,selectionRef:H,firstItemTextRef:le,selectedItemTextRef:V,alignItemWithTriggerActiveRef:ue,initialValueRef:de},QE)).current,_e=ge.useState(`activeIndex`),ve=ge.useState(`selectedIndex`),ye=ge.useState(`triggerElement`),be=ge.useState(`positionerElement`),xe=dE(me),Se=me??xe,Ce=W.useMemo(()=>y?``:YE(R,x),[y,R,x]),we=W.useMemo(()=>y&&Array.isArray(R)?R.map(e=>YE(e,x)):YE(R,x),[y,R,x]);kE(Zy(ye),F,R,Q(()=>we),!I,c);let Te=y?Array.isArray(R)&&R.length>0:R!=null&&Ce!==``;X(()=>{A(Te)},[Te,A]),X(function(){let e=BE(se.current,R,S,y);e===null&&(V.current=null),!z&&ge.set(`selectedIndex`,e)},[y,z,R,S,ge]),tD(R,()=>{T(L),E(IE(R,k.initialValue,S)),N.change(R)});let Ee=Q((e,t)=>{s?.(e,t),!t.isCanceled&&(te(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))}),De=Q(()=>{U(!1),ge.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});Cw({enabled:!h,open:z,ref:B,onComplete(){z||De()}}),W.useImperativeHandle(h,()=>({unmount:De}),[De]);let Oe=Q((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),ke=Q(e=>{let t=oD(e.scrollHeight,e.clientHeight),n=sD(e.scrollTop,t),r=n>0,i=n<t;ge.set(`scrollUpArrowVisible`,r),ge.set(`scrollDownArrowVisible`,i)}),Ae=qw({open:z,onOpenChange:Ee,elements:{reference:ye,floating:be}}),je=qS(Ae,{enabled:!I,event:`mousedown`}),Me=$S(Ae),Ne=pT(Ae,{enabled:!I,listRef:ne,activeIndex:_e,selectedIndex:ve,disabledIndices:N_,onNavigate(e){(e!==null||z)&&ge.set(`activeIndex`,e)},focusItemOnHover:C}),Pe=mT(Ae,{enabled:!I&&(z||!f&&!y),listRef:re,activeIndex:_e,selectedIndex:ve,disabledIndices:e=>pE(ne.current[e]),onMatch(e){z?ge.set(`activeIndex`,e):Oe(se.current[e],zy(Sy))},onTyping(e){ce.current=e}}),Fe=W.useMemo(()=>qx(Pe.reference,Ne.reference,Me.reference,je.reference,he),[je.reference,Pe.reference,Ne.reference,Me.reference,he]),Ie=W.useMemo(()=>qx(ww,Pe.floating,Ne.floating,Me.floating),[Pe.floating,Ne.floating,Me.floating]),Le=Ne.item??P_;ge.useContextCallback(`setValue`,Oe),ge.useContextCallback(`setOpen`,Ee),ge.useContextCallback(`handleScrollArrowVisibility`,ke),ge.useContextCallback(`onOpenChangeComplete`,_),fE(()=>{ge.update({popupProps:Ie,triggerProps:Fe})}),ge.useSyncedValues({id:F,modal:m,multiple:y,value:R,open:z,mounted:fe,transitionStatus:pe,popupProps:Ie,triggerProps:Fe,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Se});let Re=W.useMemo(()=>({disabled:I,readOnly:f,required:p,multiple:y,highlightItemOnHover:C,itemProps:Le}),[I,f,p,y,C,Le]),ze=Gy(g,N.inputRef),Be=y?void 0:L,Ve=W.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=YE(e,x);return(0,Z.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,Z.jsxs)(hE.Provider,{value:ge,children:[(0,Z.jsx)(gE.Provider,{value:Re,children:(0,Z.jsx)(_E.Provider,{value:Ae,children:w})}),(0,Z.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){ge.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=zy(Sy,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=se.current.findIndex(t=>YE(t,x).toLowerCase()===e||JE(t,b).toLowerCase()===e);r===-1&&(r=se.current.findIndex((t,n)=>{let r=re.current[n];return r!=null&&r.toLowerCase()===e}));let i=se.current[r];i!=null&&Oe(i,n)}ge.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&Be==null?`${F}-hidden-input`:void 0,form:l,name:Be,autoComplete:u,value:Ce,disabled:I,required:p&&!(y&&Te),readOnly:f,ref:ze,style:L?db:ub,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ve]})}function lD(e,t){return e??t}var uD=5;function dD(e,t){let n=fD(t);return e.clientX>=n.left-uD&&e.clientX<=n.right+uD&&e.clientY>=n.top-uD&&e.clientY<=n.bottom+uD}function fD(e){let t=e.getBoundingClientRect(),n=dv(e);if(nv)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var pD=W.createContext(void 0);function mD(e=!1){let t=W.useContext(pD);if(t===void 0&&!e)throw Error(I_(16));return t}function hD(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:W.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function gD(e,t,{detail:n=0}={}){e.dispatchEvent(new(dv(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function _D(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=W.useRef(null),s=mD(!0),c=a??s!==void 0,{props:l}=hD({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=W.useCallback(()=>{let e=o.current;vD(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:W.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return qx({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(iS(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=vD(r),s=!i&&yD(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),gD(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),gD(r,e)))},onKeyUp(e){if(!t){if(iS(e),a?.(e),e.target===e.currentTarget&&i&&c&&vD(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),gD(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Q(e=>{o.current=e,u()})}}function vD(e){return hv(e)&&e.tagName===`BUTTON`}function yD(e){return hv(e)&&e.tagName===`A`&&!!e.href}var bD=`data-popup-side`,xD=400,SD={...ay,...TE,popupSide:e=>e?{[bD]:e}:null,value:()=>null},CD=W.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,validation:f,state:p,disabled:m}=OE(),{labelId:h}=jE(),g=vE(),{readOnly:_,required:v,disabled:y}=yE(),b=m||y||a,x=g.useState(`open`),S=g.useState(`mounted`),C=g.useState(`value`),w=g.useState(`triggerProps`),T=g.useState(`positionerElement`),E=g.useState(`listElement`),D=g.useState(`popupSide`),O=g.useState(`id`),k=g.useState(`labelId`),A=g.useState(`hasSelectedValue`),j=S&&T?D:null,M=i??O,N=lD(h,k);ME({id:i});let P=Zy(T),F=W.useRef(null),{getButtonProps:I,buttonRef:L}=_D({disabled:b,native:o}),R=g.useStateSetter(`triggerElement`),ee=H_(),z=H_(),te=H_();W.useEffect(()=>{if(x)return te.start(xD,()=>{g.context.selectionRef.current.allowUnselectedMouseUp=!0,g.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{te.clear()};g.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},z.clear()},[x,g,z,te]);let ne=qx(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??gy(T)?.id:void 0,"aria-labelledby":N,"aria-readonly":_||void 0,"aria-required":v||void 0,tabIndex:b?-1:0,onFocus(e){u(!0),x&&g.context.alignItemWithTriggerActiveRef.current&&g.context.setOpen(!1,zy(Sy,e.nativeEvent)),ee.start(0,()=>{g.set(`forceMount`,!0)})},onBlur(e){Fv(T,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&f.commit(C))},onMouseDown(e){if(x)return;let t=cb(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;Fv(F.current,t)||Fv(P.current,t)||dD(e,F.current)||g.context.setOpen(!1,zy(Ny,e))}z.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),re=f.getValidationProps(b,ne);re.role=`combobox`;let B={...p,open:x,disabled:b,value:C,readOnly:_,popupSide:j,placeholder:!A};return sS(`button`,e,{ref:[t,F,L,R],state:B,stateAttributesMapping:SD,props:re})}),wD={value:()=>null},TD=W.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=vE(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?ZE(l,u,d):XE(l,u,d)),sS(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:wD})}),ED=W.forwardRef(function(e,t){let n=vE(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Z.jsx)(DS,{ref:t,...e}):null}),DD=W.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function OD(){return W.useContext(DD)}function kD(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Q(i),[,o]=W.useState(!1),s=w_(jD).current,c=w_(AD).current,l=W.useRef(0),u=W.useRef(!0),d=W.useRef(null),f=W.useRef(null),p=Q(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Q((e,t)=>{c.set(e,t),p()}),h=Q(e=>{c.delete(e),p()}),g=Q(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!PD(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&FD(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=ND(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Q(()=>{let[e,t]=MD(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Q(e=>(s.add(e),()=>{s.delete(e)})),b=W.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,Z.jsx)(DD.Provider,{value:b,children:t})}function AD(){return new Map}function jD(){return new Set}function MD(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>FD(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function ND(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function PD(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function FD(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var ID=W.createContext(void 0);function LD(){let e=W.useContext(ID);if(!e)throw Error(I_(59));return e}var RD=W.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Z.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function zD(e,t){e&&Object.assign(e.style,t)}var BD={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},VD={},HD={},UD=``;function WD(e,t){return _v(e)?e:t}function GD(e,t,n){return/hidden|clip/.test(e.getComputedStyle(WD(t,n)).overflowY)}function KD(e){if(typeof document>`u`)return!1;let t=cb(e);return dv(t).innerWidth-t.documentElement.clientWidth>0}function qD(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=cb(e),n=t.documentElement,r=t.body,i=WD(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function JD(e){let t=cb(e),n=t.documentElement,r=t.body,i=WD(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function YD(e){let t=cb(e),n=t.documentElement,r=t.body,i=dv(n),a=0,o=0,s=!1,c=ob.create();if(ev&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,VD={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},UD=n.style.scrollBehavior,HD={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=WD(n,r);if(s=qD(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,VD),Object.assign(r.style,HD),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=UD)}function d(){u(),c.request(l)}l();let f=Uy(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var XD=new class{lockCount=0;restore=null;timeoutLock=V_.create();timeoutUnlock=V_.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=cb(e),n=t.documentElement,r=t.body,i=dv(n);if(GD(i,n,r)){let t=new i.MutationObserver(()=>{GD(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Y_||!KD(e);this.restore=a?JD(e):YD(e)}};function ZD(e=!0,t=null){X(()=>{if(e)return XD.acquire(t)},[e,t])}var QD=20;function $D(e,t,n,r){let[i,a]=W.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=cb(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-QD)},[e,t,n]),ZD(e&&(!t||i),r)}var eO={position:`fixed`},tO=W.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=yS,style:_,...v}=e,y=vE(),b=bE(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),O=y.useState(`isItemEqualToValue`),k=y.useState(`transitionStatus`),A=W.useRef(null),j=W.useRef(null),[M,N]=W.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),W.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),$D((P||C)&&x,T===`touch`,E,D);let F=rE({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??P,collisionAvoidance:g,keepMounted:!0}),I=P?`none`:F.side,L=P?eO:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};X(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=sE(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),z=W.useRef(0),te=Q(e=>{if(y.context.valuesRef.current.length===0)return;let t=z.current;z.current=e.size;let n=zy(Sy);if(t!==0&&!y.state.multiple&&w!==null&&RE(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&RE(y.context.valuesRef.current,e,O)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>RE(y.context.valuesRef.current,e,O)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&P){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};zD(E,e),zD(y.context.popupRef.current,e)}}),ne=W.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,Z.jsx)(kD,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:te,children:(0,Z.jsxs)(ID.Provider,{value:ne,children:[S&&C&&(0,Z.jsx)(RD,{inert:uE(!x),cutout:D}),ee]})})}),nO=`base-ui-disable-scrollbar`,rO={className:nO,getElement(e){return(0,Z.jsx)(`style`,{nonce:e,href:nO,precedence:`base-ui:low`,children:`.${nO}{scrollbar-width:none}.${nO}::-webkit-scrollbar{display:none}`})}},iO=W.createContext(void 0);function aO(e){let t=W.useContext(iO);if(t===void 0&&!e)throw Error(I_(69));return t}var oO=`ArrowUp`,sO=`ArrowDown`,cO=`ArrowLeft`,lO=`ArrowRight`,uO=new Set([oO,sO,cO,lO,`Home`,`End`]),dO=[`Shift`,`Control`,`Alt`,`Meta`];function fO(e){return hv(e)&&e.tagName===`INPUT`}function pO(e){return!!(fO(e)&&e.selectionStart!=null||hv(e)&&e.tagName===`TEXTAREA`)}function mO(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=hO(e,t,`left`),a=gO(e),o=gO(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=hO(e,t,`top`),r=gO(e),i=gO(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function hO(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function gO(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var _O=W.createContext(void 0),vO={disableStyleElements:!1};function yO(){return W.useContext(_O)??vO}var bO=`--transform-origin`,xO={...oy,...qv},SO=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=vE(),{multiple:c,readOnly:l,highlightItemOnHover:u}=yE(),d=bE(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=LD(),_=aO(!0)!=null,v=UT(),{nonce:y,disableStyleElements:b}=yO(),x=s.useState(`id`),S=s.useState(`open`),C=s.useState(`openMethod`),w=s.useState(`mounted`),T=s.useState(`popupProps`),E=s.useState(`transitionStatus`),D=s.useState(`triggerElement`),O=s.useState(`positionerElement`),k=s.useState(`listElement`),A=W.useRef(!1),j=W.useRef(!1),M=W.useRef({}),N=sb(),P=Q(e=>{if(!O||!s.context.popupRef.current||!j.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(A.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=TO(O),i=EO(O.getBoundingClientRect().height,`y`,r),a=cb(O),o=dv(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=CO(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=wO(e),g=null,_=e=>{O.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=aD(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(A.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=aD(g,0,wO(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(A.current=!0),s.context.handleScrollArrowVisibility(e)});W.useImperativeHandle(s.context.scrollHandlerRef,()=>P,[P]),Cw({open:S,ref:s.context.popupRef,onComplete(){S&&s.context.onOpenChangeComplete(!0)}});let F={open:S,transitionStatus:E,side:f,align:p};X(()=>{O&&s.context.popupRef.current&&!Object.keys(M.current).length&&(M.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),X(()=>{S||m||(j.current=!1,A.current=!1,zD(O,M.current))},[S,m,O]),X(()=>{let e=s.context.popupRef.current;if(!S||!D||!O||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(j.current=!0,e.style.removeProperty(bO),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=kO(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=dv(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=cb(D),c=TO(D),l=DO(D.getBoundingClientRect(),c),d=DO(O.getBoundingClientRect(),c),f=l.height,p=k||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=CO(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,j=0;if(t&&n){let e=DO(n.getBoundingClientRect(),c);T=DO(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;j=T.top-d.top+T.height/2-r}let N=w+j+y+h,P=Math.min(S,N),F=S-_-y,I=N-P,L=C-5;O.style.left=`${aD(E,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${_}px`,O.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=wO(p),ee=I>=R-1;ee&&(P=Math.min(S,d.height)-(I-R));let z=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),te=(r.visualViewport?.scale??1)!==1&&ev;if(z||te){zD(O,M.current),g(!1);return}let ne=Math.max(b,P);if(ee){let e=Math.max(0,S-N);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=wO(p)}else O.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=aD(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(bO,`50% ${i}%`)}(ne===S||P>=x)&&(A.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,S,O,D,m,g,N,k,u,v,h]),W.useEffect(()=>{if(!m||!O||!S)return;let e=dv(O);function t(e){s.context.setOpen(!1,zy(Ry,e))}return Uy(e,`resize`,t)},[s,m,O,S]);let I={...k?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${x}-list`},onKeyDown(e){_&&uO.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:BD},className:!k&&m?rO.className:void 0},L=sS(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:xO,props:[T,I,oE(E),o]});return(0,Z.jsxs)(W.Fragment,{children:[!b&&rO.getElement(y),(0,Z.jsx)(KS,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:L})]})});function CO(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function wO(e){return oD(e.scrollHeight,e.clientHeight)}function TO(e){return IC.getScale(e)}function EO(e,t,n){return e/n[t]}function DO(e,t){return zb({x:EO(e.x,`x`,t),y:EO(e.y,`y`,t),width:EO(e.width,`x`,t),height:EO(e.height,`y`,t)})}var OO=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function kO(e){let{style:t}=e,n={};for(let[e,r]of OO)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of OO){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}function AO(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=OD(),u=W.useRef(-1),[d,f]=W.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=W.useRef(null),h=W.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var jO=W.createContext(void 0);function MO(){let e=W.useContext(jO);if(!e)throw Error(I_(57));return e}var NO=W.memo(W.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=W.useRef(null),d=AO({guess:!0,label:o,textRef:u}),f=vE(),{itemProps:p,multiple:m,disabled:h,readOnly:g}=yE(),_=h||s,v=f.useState(`isActive`,d.index),y=f.useState(`open`),b=f.useState(`isSelected`,a),x=f.useState(`isSelectedByFocus`,d.index),S=f.useState(`isItemEqualToValue`),C=d.index,w=W.useRef(null);X(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),X(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=VE(C,a,f.context.valuesRef.current,e,S,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&FE(a,e,S),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,S,f,a]);let T=W.useRef(`mouse`),E=W.useRef(!1),{getButtonProps:D,buttonRef:O}=_D({disabled:_,focusableWhenDisabled:!0,native:c,composite:!0}),k={disabled:_,selected:b,highlighted:v};function A(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=b?HE(n,a,S):[...n,a];f.context.setValue(r,zy(Dy,e))}else f.context.setValue(a,zy(Dy,e)),f.context.setOpen(!1,zy(Dy,e))}function j(){f.context.selectionRef.current.dragY=0}let M={role:`option`,"aria-selected":b,tabIndex:y&&v?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&av(e.nativeEvent)&&(n!==void 0||v),i=t&&!r&&!E.current;E.current=!1,!(_||i)&&A(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,j()},onMouseUp(){if(j(),_||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&b,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!b;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},N=sS(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=W.useMemo(()=>({selected:b,index:C,textRef:u,selectedByFocus:x}),[b,C,u,x]);return(0,Z.jsx)(jO.Provider,{value:P,children:N})})),PO=W.memo(W.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=MO(),a=vE(),{render:o,className:s,style:c,...l}=e;return sS(`div`,e,{ref:[W.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),FO=e=>Symbol.iterator in e,IO=e=>`entries`in e,LO=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},RO=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function zO(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:FO(e)&&FO(t)?IO(e)&&IO(t)?LO(e,t):RO(e,t):LO({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function BO(e){let t=W.useRef(void 0);return n=>{let r=e(n);return zO(t.current,r)?t.current:t.current=r}}function VO(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=VO(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function HO(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=VO(e))&&(r&&(r+=` `),r+=t);return r}var UO=W.createContext(void 0);function WO(){return W.useContext(UO)}function GO(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=mD(),{ref:i,index:a}=AO(e),o=n===a,s=W.useRef(null),c=Gy(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function KO(e){let{render:t,className:n,style:r,state:i=P_,props:a=N_,refs:o=N_,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=GO({metadata:s});return sS(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var qO=W.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=kT(u||void 0),h=WO(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=mE({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=_D({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=zy(Sy,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=sS(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=W.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,Z.jsx)(KO,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T});function JO(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=N_}=e,[p,m]=W.useState(0),h=r!=null,g=W.useRef(null),_=Gy(g,c),v=W.useRef([]),y=W.useRef(!1),b=W.useRef(null),x=o??p,S=Q((e,t=!1)=>{if(b.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];mO(g.current,t,a,n)}}),C=Q(e=>{if(e.size===0)return;if(y.current){let e=v.current,t=e.indexOf(b.current);if(t===-1){let t=e[x];!t||Wb(e,x,d)?S(YO(e,d)):b.current=t}else t!==x&&S(t);return}y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)S(i);else if(Wb(t,x,d)){let e=Ub(t,{disabledIndices:d});Bb(t,e)||S(e)}mO(g.current,r,a,n)});X(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(Wb(e,x,d)){let t=Ub(e,{disabledIndices:d});Bb(e,t)||S(t)}},[d,o,x,v,S]);let w=Q((e,t,n)=>i?i(e,t,n,v):n),T=Q(e=>{let o=e.key===`Home`||e.key===`End`;if(!uO.has(e.key)||!l&&o||XO(e,f)||!g.current)return;let s=a===`rtl`,c=s?cO:lO,p=s?lO:cO,m=n===`vertical`?sO:c,_=n===`vertical`?oO:p,y=Iv(e.nativeEvent);if(y!=null&&pO(y)&&!pE(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=x,C=Vb(v,d),T=Hb(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:x,loopFocus:t,maxIndex:T,minIndex:C,onLoop:w,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=C:e.key===`End`&&(b=T)),b===x&&(E||D)&&(t&&b===T&&E?(b=C,i&&(b=i(e,x,b,v))):t&&b===C&&D?(b=T,i&&(b=i(e,x,b,v))):b=Ub(v.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==x&&!Bb(v.current,b)&&(u&&e.stopPropagation(),(h||o||E||D)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Iv(e.nativeEvent);t&&n!=null&&pO(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:v,onMapChange:C,relayKeyboardEvent:T}}function YO(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!Wb(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function XO(e,t){for(let n of dO)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ZO(e){let{render:t,className:n,style:r,refs:i=N_,props:a=N_,state:o=P_,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=JO({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:UT(),disabledIndices:v,modifierKeys:y}),k=sS(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=W.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,Z.jsx)(pD.Provider,{value:A,children:(0,Z.jsx)(kD,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var QO=W.createContext(void 0);function $O(){return W.useContext(QO)}var ek=W.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=aO(!0),m=$O(),h=n??N_,g=c!==void 0||n!==void 0,_=(p?.disabled??!1)||(m?.disabled??!1)||r,[v,y]=mE({controlled:c,default:h,name:`ToggleGroup`,state:`value`}),b=Q((e,t,n)=>{let r;s?(r=v.slice(),t?r.push(e):r.splice(v.indexOf(e),1)):r=t?[e]:[],a?.(r,n),!n.isCanceled&&y(r)}),x={disabled:_,multiple:s,orientation:o},S=W.useMemo(()=>({disabled:_,setGroupValue:b,value:v,isValueInitialized:g}),[_,b,v,g]),C={role:`group`},w=sS(`div`,e,{enabled:!!p,state:x,ref:t,props:[C,f]});return(0,Z.jsx)(UO.Provider,{value:S,children:p?w:(0,Z.jsx)(ZO,{render:u,className:l,style:d,state:x,refs:[t],props:[C,f],loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})});function tk(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=mE({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=yw(a,!0,!0),u=kT(),[d,f]=W.useState(),p=d===null?void 0:d??u,m=Q(e=>{let t=!a,n=zy(Cy,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return W.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var nk=W.createContext(void 0);function rk(){let e=W.useContext(nk);if(e===void 0)throw Error(I_(15));return e}var ik=`data-open`,ak=`data-closed`,ok=Uv,sk=`data-panel-open`,ck={[ik]:``},lk={[ak]:``},uk={open(e){return e?{[sk]:``}:null}},dk={open(e){return e?ck:lk},...qv},fk=W.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=Q(o),d=tk({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=W.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=W.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=sS(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:dk});return(0,Z.jsx)(nk.Provider,{value:p,children:m})}),pk={...uk,...qv},mk=W.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=rk(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=_D({disabled:c,focusableWhenDisabled:!0,native:u});return sS(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:pk})}),hk={height:void 0,width:void 0};function gk(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=W.useRef(null),f=W.useRef(null),[p,m]=W.useState(hk),h=W.useRef(hk),g=W.useRef(!1),_=W.useRef(s),v=W.useRef(!1),[y,b]=W.useState(!1),x=W.useRef(null),S=Gy(t,d),C=Zy(s),w=Sw(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),O=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,k=n&&T&&f.current!==`css-animation`,A=Q((e,t=!0)=>{t&&(h.current=e),m(e)}),j=Q(()=>{x.current?.(),x.current=null}),M=Q(e=>{j(),x.current=()=>{x.current=null,e()}}),N=Q(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});X(()=>{y&&u!==`starting`&&b(!1)},[y,u]),W.useEffect(()=>()=>{N(),j()},[N,j]),X(()=>{let e=d.current;if(!e)return;!s&&x.current&&j();let t=vk(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=_k(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){A(_k(e)),b(!0);return}if(t===`css-transition`){let t=xk(e);if(A(_k(e)),!n)return t;let r=bk(e,`transition-duration`,`0s`);return M(r),b(!0),t}A(_k(e));let r=bk(e,`animation-name`,`none`);if(!n){r();return}let i=bk(e,`animation-duration`,`0s`);r(),M(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(_.current=!1,v.current=!1,t===`none`){A(hk,!1),c(!1);return}A(_k(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=_k(e);if(!(n.height>0||n.width>0)){c(!1);return}A(n),t===`css-animation`&&bk(e,`animation-name`,`none`)()},[a,s,j,A,c,M,D,u]),Cw({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&A(hk,!1)}}),W.useEffect(()=>{if(s||!a||E!==`ending`||!d.current)return;let e=new AbortController,t=-1;function n(){C.current||(c(!1),A(hk,!1))}return t=ob.request(()=>{w(n,e.signal)}),()=>{ob.cancel(t),e.abort()}},[C,a,s,E,w,A,c]),X(()=>{let e=d.current;e&&n&&T&&e.setAttribute(`hidden`,`until-found`)},[T,n]),W.useEffect(function(){let e=d.current;if(!e)return;function t(e){let t=zy(Sy,e);o(!0,t),!t.isCanceled&&(g.current=!0,l(!0))}return Uy(e,`beforematch`,t)},[o,l]);let P=i||n||a||s;return{height:O.height,props:{...k?{[ok]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:P,transitionStatus:E,width:O.width}}function _k(e){return{height:e.scrollHeight,width:e.scrollWidth}}function vk(e,t){let n=dv(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&yk(n.animationDuration),i=yk(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function yk(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function bk(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function xk(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=ob.request(n);return()=>{ob.cancel(r),n()}}var Sk=`--collapsible-panel-height`,Ck=`--collapsible-panel-width`,wk=W.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=rk(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;X(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=gk({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=Gx(s,k),j=sS(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[Sk]:S===void 0?`auto`:`${S}px`,[Ck]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:dk});return E?j:null}),Tk=W.createContext(void 0);function Ek(e=!0){let t=W.useContext(Tk);if(t===void 0&&!e)throw Error(I_(25));return t}var Dk=W.createContext(void 0);function Ok(e){let t=W.useContext(Dk);if(t===void 0&&!e)throw Error(I_(33));return t}var kk=W.createContext(void 0);function Ak(e){let t=W.useContext(kk);if(t===void 0&&!e)throw Error(I_(36));return t}function jk(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=Ek(!0),f=d!==void 0;return W.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:Dy})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!Q_&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&gD(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var Mk={type:`regular-item`};function Nk(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=W.useRef(null),{getButtonProps:d,buttonRef:f}=_D({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=jk({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=W.useCallback(e=>qx(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=Gy(u,f);return W.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Pk=W.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=AO({guess:!0,label:a}),f=Ok(!0),p=kT(i),{store:m}=Ak(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Nk({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:Mk});return sS(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),Fk=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Ak(),{side:c,align:l}=Ok(),u=aO(!0)!=null,d=s.useState(`open`),f=s.useState(`transitionStatus`),p=s.useState(`popupProps`),m=s.useState(`mounted`),h=s.useState(`instantType`),g=s.useState(`activeTriggerElement`),_=s.useState(`parent`),v=s.useState(`lastOpenChangeReason`),y=s.useState(`rootId`),b=s.useState(`floatingRootContext`),x=s.useState(`floatingTreeRoot`),S=s.useState(`closeDelay`),C=s.useState(`hoverEnabled`),w=s.useState(`disabled`),T=s.useState(`openMethod`),E=_.type===`context-menu`;Cw({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),W.useEffect(()=>{function e(e){s.setOpen(!1,zy(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),rT(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),O=sS(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:sy,props:[p,{onKeyDown(e){u&&uO.has(e.key)&&e.stopPropagation()}},oE(f),o,{"data-rootownerid":y}]}),k=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(k=!0),(0,Z.jsx)(KS,{context:b,openInteractionType:T,modal:E,disabled:!m,returnFocus:a===void 0?k:a,initialFocus:_.type!==`menu`,restoreFocus:!0,externalTree:_.type===`menubar`?void 0:x,previousFocusableElement:g,nextFocusableElement:_.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:O})}),Ik=W.createContext(void 0);function Lk(){let e=W.useContext(Ik);if(e===void 0)throw Error(I_(32));return e}var Rk=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Ak();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Z.jsx)(Ik.Provider,{value:n,children:(0,Z.jsx)(DS,{ref:t,...r,portalOwnerRole:o})})}),zk=W.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=yS,style:g,..._}=e,{store:v}=Ak(),y=Lk(),b=Ek(!0),x=v.useState(`parent`),S=v.useState(`floatingRootContext`),C=v.useState(`floatingTreeRoot`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`activeTriggerElement`),k=v.useState(`transitionStatus`),A=v.useState(`positionerElement`),j=v.useState(`instantType`),M=v.useState(`adaptiveOrigin`),N=v.useState(`lastOpenChangeReason`),P=v.useState(`floatingNodeId`),F=v.useState(`floatingParentNodeId`),I=S.useState(`domReferenceElement`),L=W.useRef(null),R=Sw(A),ee=n,z=c,te=l,ne=s,re=h;x.type===`context-menu`&&(ee=n??x.context?.anchor,ne??=`start`,!o&&ne!==`center`&&(te=e.alignOffset??2,z=e.sideOffset??-5));let B=o,ie=ne;x.type===`menu`?(B??=`inline-end`,ie??=`start`,re=e.collisionAvoidance??bS):x.type===`menubar`&&(B??=x.context.orientation===`vertical`?`inline-end`:`bottom`,ie??=`start`);let ae=x.type===`context-menu`,oe=rE({anchor:ee,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:B,sideOffset:z,align:ie,alignOffset:te,arrowPadding:ae?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:P,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:re,shift:ae?{crossAxis:!(`side`in re&&re.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:M});W.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===P&&v.set(`hoverEnabled`,!1),e.nodeId!==P&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,zy(Py)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,P]),W.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,zy(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let se=H_();W.useEffect(()=>{T||se.clear()},[T,se]),W.useEffect(()=>{function e(e){if(T&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&O&&O!==e.target){let e=v.select(`closeDelay`);e>0?se.isStarted()||se.start(e,()=>{v.setOpen(!1,zy(Py))}):v.setOpen(!1,zy(Py))}else se.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,O,v,se]),W.useEffect(()=>{let e={open:T,nodeId:P,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,P,F]),X(()=>{let e=I,t=L.current;if(e&&(L.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return R(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,R,v]);let ce={open:T,side:oe.side,align:oe.align,anchorHidden:oe.anchorHidden,nested:x.type===`menu`,instant:j},le=x.type===`menubar`&&x.context.modal;$D(T&&(le||E&&N!==`trigger-hover`),D===`touch`,A,O);let V=sE(e,ce,{styles:oe.positionerStyles,transitionStatus:k,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),H=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&N!==`trigger-hover`||x.type===`menubar`&&x.context.modal),ue=null;return x.type===`menubar`?ue=x.context.contentElement:x.type===void 0&&(ue=O),(0,Z.jsxs)(Dk.Provider,{value:oe,children:[H&&(0,Z.jsx)(RD,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:uE(!T),cutout:ue}),(0,Z.jsx)(FS,{id:P,children:(0,Z.jsx)(kD,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:V})})]})}),Bk=W.createContext(null);function Vk(e){let t=W.useContext(Bk);if(t===null&&!e)throw Error(I_(5));return t}var Hk={...Gw,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Uk=class extends hw{constructor(e,t,n=!1){let r=new Rw,i=Gk(r,t,n,e);super(i,Wk(r),Hk),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function Wk(e){return{positionerRef:W.createRef(),popupRef:W.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:W.createRef(),beforeContentFocusGuardRef:W.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Gk(e,t,n=!1,r){return{...zw(e,t,n),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new kS,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:P_,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Kk=W.createContext(void 0);function qk(){return W.useContext(Kk)}var Jk=k_(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:l=`vertical`,actionsRef:u,closeParentOnEsc:d=!1,handle:f,triggerId:p,defaultTriggerId:m=null,highlightItemOnHover:h=!0}=e,g=Ek(!0),_=Ak(!0),v=Vk(!0),y=qk(),b=W.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=Rx(),S=Rx(),C=MS(),w=b.type===`menu`?b.store:void 0,T=(n??a)&&w?.state.transitionStatus===`starting`,E=w_(()=>T?w?.state.instantType:void 0).current,D=Yk({open:a,openProp:n,activeTriggerId:m,triggerIdProp:p,parent:b,disabled:o,highlightItemOnHover:h,modal:b.type===void 0?s:void 0,rootId:x,instantType:E},S,C!=null);D.useControlledProp(`openProp`,n),D.useControlledProp(`triggerIdProp`,p),D.useContextCallback(`onOpenChangeComplete`,i);let O=D.useState(`floatingTreeRoot`),k=PS(O),A=D.useState(`open`),j=D.useState(`activeTriggerElement`),M=D.useState(`positionerElement`),N=D.useState(`hoverEnabled`),P=D.useState(`disabled`),F=D.useState(`lastOpenChangeReason`),I=D.useState(`parent`),L=D.useState(`activeIndex`),R=D.useState(`payload`),ee=D.useState(`floatingParentNodeId`),z=W.useRef(null),te=W.useRef(I.type!==`context-menu`),ne=H_(),re=W.useRef(!0),B=H_(),ie=ee!=null,{openMethod:ae,triggerProps:oe}=iD(A);D.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:I.type===void 0?s:void 0,openMethod:ae,rootId:x}),Pw(D);let{forceUnmount:se,transitionStatus:ce}=Fw(A,D,()=>{D.set(`allowMouseEnter`,!1)},T),le=Sw(D.context.popupRef);W.useEffect(()=>{if(E===void 0)return;let e=()=>{D.state.instantType===E&&D.set(`instantType`,void 0)};if(!A){e();return}if(ce!==void 0)return;if(D.context.popupRef.current==null){e();return}let t=new AbortController;return le(e,t.signal),()=>{t.abort()}},[E,A,ce,le,D]),X(()=>{g&&!_?D.update({parent:{type:`context-menu`,context:g},floatingNodeId:k,floatingParentNodeId:C}):_&&D.update({floatingNodeId:k,floatingParentNodeId:C})},[g,_,k,C,D]),W.useEffect(()=>{if(A||(z.current=null),I.type===`context-menu`){if(!A){ne.clear(),te.current=!1;return}ne.start(500,()=>{te.current=!0})}},[ne,A,I.type]),X(()=>{!A&&!N&&D.set(`hoverEnabled`,!0)},[A,N,D]);let V=Q((e,t)=>{let n=t.reason;if(!e&&!D.select(`open`)||A===e&&t.trigger===j&&F===n)return;let i=jw(t);if(!e&&t.trigger==null&&(t.trigger=j??void 0),r?.(e,t),t.isCanceled)return;D.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!re.current)return;e&&n===`trigger-focus`?(re.current=!1,B.start(300,()=>{re.current=!0})):(re.current=!0,B.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);z.current=t.event;let c=Aw(D.state,e,t.trigger,i());c.openChangeReason=n,c.instantType=I.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:o||s?o?`click`:`dismiss`:void 0,D.update(c)}),H=vw({popupStore:D,floatingRootContext:D.state.floatingRootContext,floatingId:S,nested:C!=null,onOpenChange:V}),ue=H.context.events;X(()=>{let e=({open:e,eventDetails:t})=>V(e,t);return ue.on(`setOpen`,e),()=>{ue?.off(`setOpen`,e)}},[ue,V]);let de=W.useCallback(()=>{D.setOpen(!1,zy(Iy))},[D]);W.useImperativeHandle(u,()=>({unmount:se,close:de}),[se,de]);let fe;I.type===`context-menu`&&(fe=I.context),W.useImperativeHandle(fe?.positionerRef,()=>M,[M]),W.useImperativeHandle(fe?.actionsRef,()=>({setOpen:V}),[V]);let U=$S(H,{enabled:!P,bubbles:{escapeKey:d&&I.type===`menu`},outsidePress(){return I.type!==`context-menu`||z.current?.type===`contextmenu`||te.current},externalTree:ie?O:void 0}),pe=UT(),me=W.useCallback(e=>{D.select(`activeIndex`)!==e&&D.set(`activeIndex`,e)},[D]),he=pT(H,{enabled:!P,listRef:D.context.itemDomElements,activeIndex:L,nested:I.type!==void 0,loopFocus:c,orientation:l,parentOrientation:I.type===`menubar`?I.context.orientation:void 0,rtl:pe===`rtl`,disabledIndices:N_,onNavigate:me,openOnArrowKeyDown:I.type!==`context-menu`,externalTree:ie?O:void 0,focusItemOnHover:h}),ge=W.useCallback(e=>{D.context.typingRef.current=e},[D]),_e=mT(H,{enabled:!P,listRef:D.context.itemLabels,elementsRef:D.context.itemDomElements,activeIndex:L,resetMs:500,onMatch:e=>{A&&e!==L&&D.set(`activeIndex`,e)},onTyping:ge}),ve=W.useMemo(()=>{let e=qx(_e.reference,he.reference,U.reference,{onMouseMove(){D.set(`allowMouseEnter`,!0)}},oe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=A,e},[D,_e.reference,he.reference,U.reference,oe,A]),ye=W.useMemo(()=>{let e=qx(he.trigger,U.trigger,oe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[he.trigger,U.trigger,oe]);w_(()=>(D.update({inactiveTriggerProps:ye}),null)),Iw(D,{floatingRootContext:H,activeTriggerProps:ve,inactiveTriggerProps:ye,popupProps:W.useMemo(()=>qx(ww,{id:S,role:`menu`,"aria-orientation":l===`horizontal`?`horizontal`:void 0,"aria-labelledby":j?.id,onMouseMove(){D.set(`allowMouseEnter`,!0),I.type===`menu`&&D.set(`hoverEnabled`,!1)},onClick(){D.select(`hoverEnabled`)&&D.set(`hoverEnabled`,!1)},onKeyDown(e){let t=D.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},_e.floating,he.floating,U.floating),[j,S,l,I.type,D,_e.floating,he.floating,U.floating]),itemProps:he.item??P_});let be=W.useMemo(()=>({store:D,parent:b}),[D,b]),xe=(0,Z.jsxs)(kk.Provider,{value:be,children:[f&&(0,Z.jsx)(Dw,{handle:f,store:D}),typeof t==`function`?t({payload:R}):t]});return I.type===void 0||I.type===`context-menu`?(0,Z.jsx)(IS,{externalTree:O,children:xe}):xe});function Yk(e,t,n){return w_(()=>new Uk(e,t,n)).current}function Xk(e){if(hv(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Dv(e))return Xk(Av(e))}function Zk(e,t){let n=W.useRef(null);function r(t){SS.flushSync(()=>{e.setOpen(!1,zy(ky,t.nativeEvent,t.currentTarget))}),mx(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&hx(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{SS.flushSync(()=>{e.setOpen(!1,zy(ky,n.nativeEvent,n.currentTarget))});let i=px(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Fv(r,i);){let e=i;if(i=ux(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Qk(e){let[t,n]=W.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=W.useRef(null),i=W.useRef(null),a=W.useRef(null),o=W.useRef(null),s=W.useRef(!0),c=W.useRef(null),l=Rx(),u=W.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,Z.jsx)(Tk.Provider,{value:u,children:(0,Z.jsx)(kk.Provider,{value:void 0,children:(0,Z.jsx)(Jk,{...e})})})}var $k=500,eA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=Ek(!1),{store:m}=Ak(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=W.useRef(null),v=W.useRef(null),y=H_(),b=H_(),x=W.useRef(!1),S=W.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,zy(Cy,n)),b.start($k,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,rv(e),C(e.clientX,e.clientY,e.nativeEvent);let t=cb(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=Iv(e);Fv(u.current,t)||p&&t&&Xk(t)===p||s.current?.setOpen(!1,zy(Ny,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start($k,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return W.useEffect(()=>()=>{S.current?.abort()},[]),W.useEffect(()=>{function e(e){if(g)return;let t=Iv(e);(Fv(_.current,t)||Fv(c.current,t)||Fv(l.current,t))&&e.preventDefault()}return Uy(cb(_.current),`contextmenu`,e)},[l,g,c]),sS(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:ay})}),tA=zk,nA=W.createContext(void 0);function rA(){let e=W.useContext(nA);if(e===void 0)throw Error(I_(53));return e}function iA(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var aA=`data-has-overflow-x`,oA=`data-has-overflow-y`,sA=`data-overflow-x-start`,cA=`data-overflow-x-end`,lA=`data-overflow-y-start`,uA=`data-overflow-y-end`,dA=e=>t=>t?{[e]:``}:null,fA={hasOverflowX:dA(aA),hasOverflowY:dA(oA),overflowXStart:dA(sA),overflowXEnd:dA(cA),overflowYStart:dA(lA),overflowYEnd:dA(uA),cornerHidden:()=>null},pA=`--scroll-area-corner-height`,mA=`--scroll-area-corner-width`,hA=`data-orientation`,gA={x:0,y:0},_A={width:0,height:0},vA={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},yA={x:!0,y:!0,corner:!0},bA=W.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=xA(i),d=kT(),f=H_(),p=H_(),{nonce:m,disableStyleElements:h}=yO(),[g,_]=W.useState(!1),[v,y]=W.useState(!1),[b,x]=W.useState(!1),[S,C]=W.useState(!1),[w,T]=W.useState(!1),[E,D]=W.useState(_A),[O,k]=W.useState(_A),[A,j]=W.useState(vA),[M,N]=W.useState(yA),P=W.useRef(null),F=W.useRef(null),I=W.useRef(null),L=W.useRef(null),R=W.useRef(null),ee=W.useRef(null),z=W.useRef(null),te=W.useRef(null),ne=W.useRef(0),re=W.useRef(0),B=W.useRef(0),ie=W.useRef(0),ae=W.useRef(`vertical`),oe=W.useRef(gA),se=W.useRef(null);function ce(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let le=Q(e=>{let t=e.x-oe.current.x,n=e.y-oe.current.y;oe.current=e,n!==0&&ce(!0),t!==0&&ce(!1)}),V=Q(()=>{let e=F.current;e&&se.current===null&&(se.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),H=Q(e=>{if(e.button!==0||te.current!==null&&(ae.current===`vertical`?R.current:ee.current)?.hasPointerCapture(te.current))return;te.current=e.pointerId,ne.current=e.clientY,re.current=e.clientX,ae.current=e.currentTarget.getAttribute(hA);let t=F.current;t&&(B.current=t.scrollTop,ie.current=t.scrollLeft,V()),(ae.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),ue=Q(e=>{if(e.pointerId!==te.current)return;te.current=null,(ae.current===`vertical`?x:y)(!1),se.current!==null&&(F.current&&(F.current.style.scrollSnapType=se.current),se.current=null);let t=ae.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),de=Q(e=>{if(e.pointerId!==te.current)return;if(e.buttons%2==0){ue(e);return}let t=F.current;if(!t)return;let n=ae.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=iA(i,`padding`,a),s=iA(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-ne.current:e.clientX-re.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?B.current:ie.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ce(n)});function fe(e){C(e.pointerType===`touch`)}function U(e){if(fe(e),e.pointerType!==`touch`){let t=Fv(P.current,e.target);_(t)}}let pe=W.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),me={role:`presentation`,onPointerEnter:U,onPointerMove:U,onPointerDown:fe,onPointerLeave(){_(!1)},style:{position:`relative`,[pA]:`${E.height}px`,[mA]:`${E.width}px`}},he=sS(`div`,e,{state:pe,ref:[t,P],props:[me,o],stateAttributesMapping:fA}),ge=W.useMemo(()=>({handlePointerDown:H,handlePointerMove:de,handlePointerUp:ue,handleScroll:le,disableViewportSnap:V,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:z,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:ee,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:pe,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[H,de,ue,le,V,E,O,w,S,v,b,g,d,M,A,pe,s,c,l,u]);return(0,Z.jsxs)(nA.Provider,{value:ge,children:[!h&&rO.getElement(m),he]})});function xA(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}var SA=W.createContext(void 0),CA=`--scroll-area-overflow-x-start`,wA=`--scroll-area-overflow-x-end`,TA=`--scroll-area-overflow-y-start`,EA=`--scroll-area-overflow-y-end`,DA=`--scroll-area-thumb-height`,OA=`--scroll-area-thumb-width`,kA=[CA,wA,TA,EA],AA=!1;function jA(){AA||ev||(typeof CSS<`u`&&`registerProperty`in CSS&&kA.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),AA=!0)}var MA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=rA(),T=UT(),E=W.useRef(!0),D=W.useRef([NaN,NaN,NaN,NaN]),O=H_(),k=H_(),A=Q(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=NA(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=sD(T===`rtl`?-w:w,P),L=P-I);let R=A?0:sD(x,F),ee=A?0:F-R,z=j?0:b,te=A?0:y,ne=0,re=0;!j&&!A&&(ne=t?.offsetWidth||0,re=n?.offsetHeight||0);let B=f.width===0&&f.height===0,ie=B?ne:0,ae=B?re:0,oe=iA(n,`padding`,`x`),se=iA(t,`padding`,`y`),ce=iA(i,`margin`,`x`),le=iA(r,`margin`,`y`),V=z-oe-ce,H=te-se-le,ue=n?Math.min(n.offsetWidth-ie,V):V,de=t?Math.min(t.offsetHeight-ae,H):H,fe=Math.max(16,ue*M),U=Math.max(16,de*N);if(m(e=>PA(e,{width:fe,height:U})),t&&r){let e=FA(r,DA,x,F,h,U,t.offsetHeight-U-se-le);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-fe-oe-ce,t=FA(i,OA,T===`rtl`?-w:w,P,_,fe,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let pe=[I,L,R,ee];kA.forEach((t,n)=>{e.style.setProperty(t,`${pe[n]}px`)}),a&&p(e=>PA(e,{width:ne,height:re})),g(e=>PA(e,k));let me={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>PA(e,me))});X(()=>{jA()},[]),X(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),X(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),X(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=e.getAnimations({subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished)).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={role:`presentation`,...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:rO.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=sS(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:fA}),P=W.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,Z.jsx)(SA.Provider,{value:P,children:N})});function NA(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function PA(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function FA(e,t,n,r,i,a,o){let s=aD(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var IA=W.createContext(void 0);function LA(){let e=W.useContext(IA);if(e===void 0)throw Error(I_(54));return e}var RA=W.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=rA(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=UT(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;W.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return Uy(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=Iv(e.nativeEvent),n=T?h.current:g.current;if(n&&Fv(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=iA(n,`margin`,a),s=iA(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onMouseDown(e){e.preventDefault()},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(${pA})`,insetInlineEnd:0,[DA]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${mA})`,bottom:0,[OA]:`${S.width}px`}}},M=sS(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:fA});return A?(0,Z.jsx)(IA.Provider,{value:i,children:M}):null}),zA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=rA(),m=LA(),h=m===`vertical`;return sS(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),BA=W.createContext(void 0);function VA(e){let t=W.useContext(BA);if(!e&&t===void 0)throw Error(I_(27));return t}var HA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=VA(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return sS(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:sy,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),UA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=VA(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=_D({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,zy(Oy,e.nativeEvent))}return sS(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),WA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=VA(),c=kT(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),sS(`p`,e,{ref:t,props:[{id:c},o]})}),GA=W.createContext(void 0);function KA(){let e=W.useContext(GA);if(e===void 0)throw Error(I_(26));return e}var qA=`--nested-dialogs`,JA=`data-nested-dialog-open`,YA={...oy,...qv,nestedDialogOpen(e){return e?{[JA]:``}:null}},XA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=VA(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);KA(),Cw({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Tw(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=sS(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...ww,hidden:!m,onKeyDown(e){uO.has(e.key)&&e.stopPropagation()},style:{[qA]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:YA});return(0,Z.jsx)(KS,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),ZA=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=VA(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Z.jsx)(GA.Provider,{value:n,children:(0,Z.jsxs)(DS,{ref:t,...r,children:[a&&o===!0&&(0,Z.jsx)(RD,{ref:i.context.internalBackdropRef,inert:uE(!s)}),e.children]})}):null});function QA({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=W.useState(0),[u,d]=W.useState(0),f=c===0,p=$S(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Iv(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Fv(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return ZD(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),X(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),Iw(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var $A={...Gw,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},ej=class extends hw{constructor(e,t,n){let r=new Rw,i=tj(e,r,t,n);super(i,nj(r),$A)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(Aw(this.state,e,t.trigger)))}};function tj(e,t,n,r=!1){return{...zw(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function nj(e){return{popupRef:W.createRef(),backdropRef:W.createRef(),internalBackdropRef:W.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function rj(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=VA(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Ew((e,t)=>new ej({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);Lw(b,x),Pw(b);let{forceUnmount:w}=Fw(x,b);W.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,zy(Iy))}),[w,b]);let T=x||S;return(0,Z.jsxs)(BA.Provider,{value:b,children:[u&&(0,Z.jsx)(Dw,{handle:u,store:b}),T&&(0,Z.jsx)(QA,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var ij=k_(function(e){return rj(`dialog`,e)}),aj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=KA(),c=VA(),l=c.useState(`open`),u=c.useState(`nested`),d=c.useState(`transitionStatus`),f=c.useState(`nestedOpenDialogCount`),p=c.useState(`mounted`),m=c.useStateSetter(`viewportElement`);return sS(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:YA,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),oj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=VA(),c=kT(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),sS(`h2`,e,{ref:t,props:[{id:c},o]})}),sj=A_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=VA(!0),f=Kw(l)??d;if(!f)throw Error(I_(79));let p=kT(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=W.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=Nw(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=_D({disabled:a,native:o}),S=qS(m),C=rD(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return sS(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[hS]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:iy})}),cj=`--nested-drawers`,lj=`--drawer-height`,uj=`--drawer-frontmost-height`,dj=`--drawer-swipe-movement-x`,fj=`--drawer-swipe-movement-y`,pj=`--drawer-snap-point-offset`,mj=`--drawer-swipe-strength`,hj=`--drawer-swipe-progress`,gj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=VA(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return sS(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:sy,props:[{role:`presentation`,hidden:!u,style:{pointerEvents:c?void 0:`none`,userSelect:`none`,WebkitUserSelect:`none`,[hj]:`0`,[mj]:`1`}},o],enabled:a||!l})}),_j=UA,vj=`data-drawer-content`,yj=WA,bj=W.createContext(void 0);function xj(){return W.useContext(bj)}var Sj=`data-expanded`,Cj=`data-nested-drawer-open`,wj=`data-nested-drawer-swiping`,Tj=`data-swipe-dismiss`,Ej=`data-swipe-direction`,Dj=`data-swiping`,Oj=W.createContext(void 0);function kj(e){let t=W.useContext(Oj);if(e!==!0&&t===void 0)throw Error(I_(90));return t}function Aj(e,t){let n=e+t;return n>=0?t:-Math.sqrt(-n)-e}function jj(e,t,n){if(!Number.isFinite(t)||t<=0)return null;if(typeof e==`number`)return Number.isFinite(e)?e<=1?aD(e,0,1)*t:e:null;let r=e.trim();if(r.endsWith(`px`)){let e=Number.parseFloat(r);return Number.isFinite(e)?e:null}if(r.endsWith(`rem`)){let e=Number.parseFloat(r);return Number.isFinite(e)?e*n:null}return null}function Mj(e,t){let n=-1,r=1/0;for(let i=0;i<e.length;i+=1){let a=Math.abs(e[i]-t);a<r&&(r=a,n=i)}return n}function Nj(){let e=VA(),{snapPoints:t,activeSnapPoint:n,setActiveSnapPoint:r,popupHeight:i}=kj(),a=e.useState(`viewportElement`),[o,s]=W.useState(0),[c,l]=W.useState(16),u=Q(()=>{let e=cb(a).documentElement;s(a?a.offsetHeight:e.clientHeight);let t=parseFloat(getComputedStyle(e).fontSize);Number.isFinite(t)&&l(t)});X(()=>{if(u(),!a||typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(u);return e.observe(a),()=>{e.disconnect()}},[u,a]);let d=W.useMemo(()=>{if(!t||t.length===0||o<=0||i<=0)return[];let e=Math.min(i,o),n=t.map(t=>{let n=jj(t,o,c);if(n===null)return null;let r=aD(n,0,e);return{value:t,height:r,offset:Math.max(0,i-r)}}).filter(e=>!!e);if(n.length<=1)return n;let r=[],a=[];for(let e=n.length-1;e>=0;--e){let t=n[e];a.some(e=>Math.abs(e-t.height)<=1)||(a.push(t.height),r.push(t))}return r.reverse(),r},[i,c,t,o]);return{snapPoints:t,activeSnapPoint:n,setActiveSnapPoint:r,popupHeight:i,viewportHeight:o,resolvedSnapPoints:d,activeSnapPointOffset:W.useMemo(()=>{if(n===null)return;let e=d.find(e=>Object.is(e.value,n));if(e)return e;let t=Math.min(i,o),r=jj(n,o,c);if(r===null)return;let a=aD(r,0,t);return d[Mj(d.map(e=>e.height),a)]},[n,i,d,c,o])?.offset??null}}var Pj=W.createContext(null);function Fj(){return W.useContext(Pj)}var Ij=!1;function Lj(){Ij||=(typeof CSS<`u`&&`registerProperty`in CSS&&([dj,fj,pj].forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),[{name:hj,initialValue:`0`},{name:mj,initialValue:`1`}].forEach(({name:e,initialValue:t})=>{try{CSS.registerProperty({name:e,syntax:`<number>`,inherits:!1,initialValue:t})}catch{}})),!0)}var Rj={...sy,expanded(e){return e?{[Sj]:``}:null},nestedDrawerOpen(e){return e?{[Cj]:``}:null},nestedDrawerSwiping(e){return e?{[wj]:``}:null},swipeDirection(e){return{[Ej]:e}},swiping(e){return e?{[Dj]:``}:null}},zj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=VA(),l=c.context.popupRef,{swipeDirection:u,frontmostHeight:d,hasNestedDrawer:f,nestedSwiping:p,nestedSwipeProgressStore:m,onPopupHeightChange:h,notifyParentFrontmostHeight:g,notifyParentHasNestedDrawer:_}=kj(),v=c.useState(`descriptionElementId`),y=c.useState(`disablePointerDismissal`),b=c.useState(`floatingRootContext`),x=c.useState(`popupProps`),S=c.useState(`modal`),C=c.useState(`mounted`),w=c.useState(`nested`),T=c.useState(`nestedOpenDrawerCount`),E=c.useState(`transitionStatus`),D=c.useState(`open`),O=c.useState(`openMethod`),k=c.useState(`titleElementId`),A=c.useState(`role`),j=b.useState(`floatingId`),M=s.id??j,N=Fj();KA();let{snapPoints:P,activeSnapPoint:F,activeSnapPointOffset:I}=Nj(),L=T>0,R=N?.swiping??!1,ee=N?.swipeStrength??null,[z,te]=W.useState(0),ne=W.useRef(0),re=Q(()=>{let e=l.current;if(!e)return;let t=e.offsetHeight;if(ne.current>0&&d>ne.current&&t>ne.current)return;if(ne.current>0&&f){let e=ne.current;te(e),h(e);return}let n=t;n!==ne.current&&(ne.current=n,te(n),h(n))});X(()=>{if(!C){ne.current=0,te(0),h(0);return}let e=l.current;if(!e||(Lj(),re(),typeof ResizeObserver!=`function`))return;let t=new ResizeObserver(re);return t.observe(e),()=>{t.disconnect()}},[re,C,L,h,l]),X(()=>{let e=()=>{let e=l.current;if(!e)return;let t=m.getSnapshot();t>0?e.style.setProperty(hj,`${t}`):e.style.setProperty(hj,`0`)};e();let t=m.subscribe(e),n=l.current;return()=>{t(),n&&n.style.setProperty(hj,`0`)}},[m,l]),X(()=>{if(D)return g?.(d),()=>{g?.(0)}},[d,D,g]),X(()=>{if(_)return _(D||E===`ending`),()=>{_(!1)}},[_,D,E]),Cw({open:D,ref:l,onComplete(){D&&c.context.onOpenChangeComplete?.(!0)}});let B=o===void 0?l:o,ie=c.useStateSetter(`popupElement`),ae={open:D,nested:w,transitionStatus:E,expanded:F===1,nestedDrawerOpen:L,nestedDrawerSwiping:p,swipeDirection:u,swiping:R},oe;z&&(f||E===`ending`)&&(oe=`${z}px`);let se=P&&P.length>0&&(u===`down`||u===`up`),ce=null;se&&I!==null&&(ce=u===`up`?-I:I);let le=N?N.getDragStyles():P_;if(se&&u===`down`){let e=I??0,t=Number.parseFloat(String(le[fj]));le=R&&Number.isFinite(t)?{...le,transform:void 0,[fj]:`${Aj(e,t)}px`}:{...le,transform:void 0}}let V=sS(`div`,e,{state:ae,props:[x,{id:M,"aria-labelledby":k,"aria-describedby":v,role:A,...ww,hidden:!C,onKeyDown(e){uO.has(e.key)&&e.stopPropagation()},style:{...le,[hj]:`0`,[cj]:T,[lj]:oe,[pj]:typeof ce==`number`?`${ce}px`:`0px`,[uj]:d?`${d}px`:void 0,[mj]:typeof ee==`number`&&Number.isFinite(ee)&&ee>0?`${ee}`:`1`}},s],ref:[t,l,ie],stateAttributesMapping:Rj});return(0,Z.jsx)(KS,{context:b,openInteractionType:O,disabled:!C,closeOnFocusOut:!y,initialFocus:B,returnFocus:a,modal:S!==!1,restoreFocus:`popup`,children:V})}),Bj=ZA,Vj,Hj;function Uj(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null,swipeDirection:f=`down`,snapToSequentialPoints:p=!1,snapPoints:m,snapPoint:h,defaultSnapPoint:g,onSnapPointChange:_}=e,v=kj(!0),y=v?.onNestedSwipeProgressChange,b=v?.onNestedFrontmostHeightChange,x=v?.onNestedSwipingChange,S=v?.onNestedDrawerPresenceChange,[C,w]=W.useState(0),[T,E]=W.useState(0),[D,O]=W.useState(!1),[k,A]=W.useState(!1),[j]=W.useState(Wj),M=g===void 0?m?.[0]??null:g,N=h!==void 0,[P,F]=mE({controlled:h,default:M,name:`Drawer`,state:`snapPoint`}),I=W.useRef(!1),L=W.useRef(!1),R=Q((e,t)=>{let n=t??zy(`none`);_?.(e,n),!n.isCanceled&&F(e)}),ee=W.useMemo(()=>N||!m||m.length===0?P:P===null||!m.some(e=>Object.is(e,P))?M:P,[P,N,M,m]),z=Q(e=>{w(e),!I.current&&e>0&&E(e)}),te=Q(e=>{if(e>0){I.current=!0,E(e);return}I.current=!1,C>0&&E(C)}),ne=Q(e=>{O(e)}),re=Q(e=>{j.set(e),y?.(e)}),B=Q(e=>{A(e),x?.(e)}),ie=Q((e,t)=>{i?.(e,t),!t.isCanceled&&!e&&m&&m.length>0&&R(M,zy(t.reason,t.event,t.trigger))}),ae=W.useMemo(()=>({swipeDirection:f,swipeAreaActiveRef:L,snapToSequentialPoints:p,snapPoints:m,activeSnapPoint:ee,setActiveSnapPoint:R,frontmostHeight:T,popupHeight:C,hasNestedDrawer:D,nestedSwiping:k,nestedSwipeProgressStore:j,onNestedDrawerPresenceChange:ne,onPopupHeightChange:z,onNestedFrontmostHeightChange:te,onNestedSwipingChange:B,onNestedSwipeProgressChange:re,notifyParentFrontmostHeight:b,notifyParentSwipingChange:x,notifyParentSwipeProgressChange:y,notifyParentHasNestedDrawer:S}),[ee,T,D,k,j,S,y,x,b,ne,te,re,B,z,C,R,m,p,L,f]),oe=rj(`drawer`,{open:n,defaultOpen:r,onOpenChange:ie,onOpenChangeComplete:a,disablePointerDismissal:o,modal:s,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d,children:typeof t==`function`?e=>(0,Z.jsxs)(W.Fragment,{children:[Vj||=(0,Z.jsx)(Gj,{}),t(e)]}):(0,Z.jsxs)(W.Fragment,{children:[Hj||=(0,Z.jsx)(Gj,{}),t]})});return(0,Z.jsx)(Oj.Provider,{value:ae,children:oe})}function Wj(){let e=0,t=new Set;return{getSnapshot:()=>e,set(n){let r=Number.isFinite(n)?n:0;r!==e&&(e=r,t.forEach(e=>{e()}))},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function Gj(){let e=xj(),t=VA(!1),n=e?.setDrawerOpen,r=e?.removeDrawer,i=t.useState(`open`),a=t.useState(`nestedOpenDialogCount`),o=t.useState(`popupElement`),s=a===0;return X(()=>{if(r)return()=>{r(t)}},[r,t]),X(()=>{n?.(t,i)},[i,n,t]),W.useEffect(()=>{if(!i||!s||!Z_)return;let e=dv(o).CloseWatcher;if(!e)return;function n(e){t.select(`open`)&&t.setOpen(!1,zy(jy,e))}let r=new e,a=Uy(r,`close`,n);return()=>{a(),r.destroy()}},[t,s,i,o]),null}function Kj(e,t=!1){let{overflowY:n}=Ov(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function qj(e,t=!1){let{overflowX:n}=Ov(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientWidth>0:e.scrollWidth>e.clientWidth}function Jj(e,t,n=!1){return t===`vertical`?Kj(e,n):qj(e,n)}function Yj(e,t,n){let r=e;for(;hv(r)&&r!==t&&!Dv(r);){for(let e of n)if(Jj(r,e))return!0;r=Av(r)}return!1}function Xj(e,t,n=`vertical`,r=!1){let i=hv(e)?e:null;for(;hv(i)&&i!==t&&!Dv(i);){if(Jj(i,n,r))return i;i=Av(i)}return Jj(t,n,r)?t:null}function Zj(e,t,n){return typeof e?.elementFromPoint==`function`?e.elementFromPoint(t,n):null}function Qj(e,t){let n=(t??dv(e).getComputedStyle(e)).transform,r=0,i=0,a=1;if(n&&n!==`none`){let e=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(r=t[4],i=t[5],a=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(r=t[12],i=t[13],a=t[0])}}return{x:r,y:i,scale:a}}var $j=40,eM=10,tM=1,nM=50,rM=16,iM=80,aM=`button,a,input,select,textarea,label,[role="button"]`;function oM(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function sM(e){return Number.isFinite(e)&&e>0?e:null}function cM(e,t){return`translate3d(${e.x}px,${e.y}px,0) scale(${t})`}function lM(e){return e%2==1}function uM(e,t,n){let r=e[n];if(typeof r==`function`)try{r.call(e,t)}catch(e){if(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`)return;throw e}}function dM(e){let{enabled:t,directions:n,elementRef:r,movementCssVars:i,canStart:a,ignoreSelectorWhenTouch:o=!0,ignoreScrollableAncestors:s=!1,swipeThreshold:c,onDismiss:l,onProgress:u,onCancel:d,onSwipeStart:f,onRelease:p,onSwipingChange:m,trackDrag:h=!0}=e,g=aM,_=n.length===1?n[0]:void 0,v=Math.max(0,typeof c==`number`?c:$j),y=n.includes(`left`),b=n.includes(`right`),x=n.includes(`up`),S=n.includes(`down`),C=y||b,w=x||S,T=W.useMemo(()=>{let e=[];return w&&e.push(`vertical`),C&&e.push(`horizontal`),e},[C,w]),[E,D]=W.useState(void 0),[O,k]=W.useState(!1),[A,j]=W.useState(!1),M=W.useRef({x:0,y:0}),N=W.useRef({x:0,y:0}),P=W.useRef(null),F=W.useRef({x:0,y:0,scale:1}),I=W.useRef(void 0),L=W.useRef(0),R=W.useRef(!1),ee=W.useRef({x:0,y:0}),z=W.useRef(null),te=W.useRef(!1),ne=W.useRef(!1),re=W.useRef(null),B=W.useRef(!1),ie=W.useRef(!1),ae=W.useRef({width:0,height:0}),oe=W.useRef(0),se=W.useRef(v),ce=W.useRef(null),le=W.useRef(null),V=W.useRef(null),H=W.useRef({x:0,y:0}),ue=W.useRef(null),de=W.useRef(!1),fe=W.useRef(null),U=Q(e=>{de.current!==e&&(de.current=e,k(e),m?.(e))});function pe(e){if(!e)return;let t=r.current,n=ce.current;if(!t||!n)return;let i=n({element:t,direction:e});se.current=Math.max(0,i)}let me=Q((e,t)=>{let n=Number.isFinite(e)?aD(e,0,1):0,r=n!==oe.current,i=!1;if(t){let e=ue.current;i=!e||e.deltaX!==t.deltaX||e.deltaY!==t.deltaY||e.direction!==t.direction}(r||i)&&(oe.current=n,t?ue.current=t:r&&(ue.current=null),u?.(n,t))}),he=Q(e=>{let t=r.current;if(!h||!t){e||(fe.current=null);return}let n=t.style,a=fe.current;e?(a||(fe.current=[n.transition,n.transform]),n.transition=`none`):a&&([n.transition,n.transform]=a,fe.current=null);let o=N.current,s=F.current,c=o.x-s.x,l=o.y-s.y;e&&(n.transform=cM(o,s.scale)),n.setProperty(i.x,`${c}px`),n.setProperty(i.y,`${l}px`)});function ge(e,t){if(t===null)return;let n=V.current;if(n&&t>n.time){let r=Math.max(t-n.time,rM);H.current={x:(e.x-n.x)/r,y:(e.y-n.y)/r}}V.current={x:e.x,y:e.y,time:t}}let _e=W.useCallback(()=>{D(void 0),U(!1),j(!1),me(0),se.current=v,ce.current=null,M.current={x:0,y:0},N.current={x:0,y:0},F.current={x:0,y:0,scale:1},I.current=void 0,L.current=0,R.current=!1,ee.current={x:0,y:0},z.current=null,te.current=!1,P.current=null,ne.current=!1,re.current=null,B.current=!1,ie.current=!1,ae.current={width:0,height:0},le.current=null,V.current=null,H.current={x:0,y:0},ue.current=null,he(!1)},[U,v,he,me]);function ve(e){if(`touches`in e){let t=e.touches[0];return t?{x:t.clientX,y:t.clientY}:null}return{x:e.clientX,y:e.clientY}}function ye(e){return`touches`in e||e.pointerType===`touch`}function be(e,t){let n=r.current?.getRootNode();return Zj(n,e.x,e.y)??Iv(t)}function xe(e,t){let n=n=>{let r=Xj(e,t,n),i=cb(r);return r===i.body||r===i.documentElement?null:r};return C&&!w?n(`horizontal`):w&&!C?n(`vertical`):n(`vertical`)??n(`horizontal`)}function Se(e,t,n){B.current=!1;let i=ye(e),a=be(t,e.nativeEvent),l=cb(r.current).body,u=i&&l?xe(a,l):null,d=n?.ignoreScrollableTarget??!1;if(u&&!d||(B.current=!!(u&&d),a&&a.closest(g)&&(!i||o)))return!1;let p=r.current;if(s&&p&&a&&T.length>0&&!(n?.ignoreScrollableAncestors??!1)&&Yj(a,p,T))return!1;if(R.current=!1,I.current=void 0,L.current=0,M.current=t,le.current=sM(e.timeStamp),ee.current=t,P.current=t,se.current=v,ce.current=typeof c==`function`?c:null,p){ae.current={width:p.offsetWidth,height:p.offsetHeight},pe(_);let t=Qj(p);F.current=t,N.current={x:t.x,y:t.y},ge({x:t.x,y:t.y},le.current),`touches`in e||uM(p,e.pointerId,`setPointerCapture`)}return f?.(e.nativeEvent),U(!0),z.current=null,te.current=!0,me(0),he(!0),!0}function Ce(){we(),B.current=!1,P.current=null}function we(){ne.current=!1,re.current=null}function Te(e){if(Ce(),!de.current)return;U(!1),z.current=null;let t=F.current;N.current={x:t.x,y:t.y},D(void 0),ie.current=!1,he(!1);let n=r.current;n&&uM(n,e.pointerId,`releasePointerCapture`),me(0,{deltaX:0,deltaY:0,direction:void 0}),d?.(e.nativeEvent)}function Ee(e,t){let n=e=>Math.sign(e)*Math.abs(e)**.5,r=(e,t,r)=>!t&&e<0||!r&&e>0?n(e):e;return{x:C?r(e,y,b):n(e),y:w?r(t,x,S):n(t)}}function De(e,t,n){let r=(e,t,n,r,i)=>e>0&&t<=0&&r||e<0&&t>=Math.max(0,n)&&i,i=Math.abs(t),a=Math.abs(n);return w&&n!==0&&(!C||a>=i)?r(n,e.scrollTop,e.scrollHeight-e.clientHeight,S,x):C&&t!==0&&(!w||i>a)?r(t,e.scrollLeft,e.scrollWidth-e.clientWidth,b,y):null}let Oe=Q(e=>{if(!t||e.defaultPrevented||e.nativeEvent.defaultPrevented||!(`touches`in e)&&e.button!==0)return;let n=ve(e);n&&(ne.current=!0,re.current=n,B.current=!1,ie.current=!(`touches`in e),(!a||a(n,{nativeEvent:e.nativeEvent,direction:_}))&&Se(e,n)&&we())});function ke(e,n,r){if(!t||!de.current)return;let i=Iv(e.nativeEvent);if(ye(e)&&!B.current){let t=e.currentTarget;if(xe(i,t))return}if(`touches`in e||e.preventDefault(),te.current&&(te.current=!1,h)){M.current=n;let t=sM(e.timeStamp);t!==null&&(le.current=t)}let a=n.x,o=n.y,s=r.x,c=r.y;(c<0&&o>ee.current.y||c>0&&o<ee.current.y)&&(ee.current={x:ee.current.x,y:o}),(s<0&&a>ee.current.x||s>0&&a<ee.current.x)&&(ee.current={x:a,y:ee.current.y});let l=a-M.current.x,u=o-M.current.y,d=o-ee.current.y,f=a-ee.current.x,p=z.current;p===null&&C&&w&&Math.sqrt(l*l+u*u)>=tM&&(p=Math.abs(l)>Math.abs(u)?`horizontal`:`vertical`,z.current=p);let m;if(!I.current)p===`vertical`?u>0?m=`down`:u<0&&(m=`up`):p===`horizontal`?l>0?m=`right`:l<0&&(m=`left`):m=Math.abs(l)>=Math.abs(u)?l>0?`right`:`left`:u>0?`down`:`up`,m&&(m===`left`&&y||m===`right`&&b||m===`up`&&x||m===`down`&&S)&&(I.current=m,L.current=oM(m,l,u),D(m),pe(m));else{let e=I.current,t=oM(e,f,d);t>se.current?(R.current=!1,D(e)):!(y&&b)&&!(x&&S)&&L.current-t>=eM&&(R.current=!0)}let g=Ee(l,u),v=F.current.x,T=F.current.y;p===`horizontal`?C&&(v+=g.x):(p===`vertical`||C&&(v+=g.x),w&&(T+=g.y));let E=N.current,O=v!==E.x||T!==E.y;N.current={x:v,y:T},O&&he(!0),ge({x:v,y:T},sM(e.timeStamp));let k=v-F.current.x,A=T-F.current.y,j={deltaX:k,deltaY:A,direction:I.current},P=0,ne=_??I.current;if(ne){let e=ne===`left`||ne===`right`?ae.current.width:ae.current.height,t=F.current.scale||1,n=oM(ne,k,A);e>0&&t>0&&n>0&&(P=n/(e*t))}me(P,j)}let Ae=Q(e=>{if(!t)return;let i=N.current,a=F.current,o=i.x-a.x,s=i.y-a.y,c={deltaX:o,deltaY:s,direction:I.current};if(!de.current){Ce(),me(0,c);return}U(!1),z.current=null,Ce(),ie.current=!1;let u=r.current;u&&(`touches`in e||uM(u,e.pointerId,`releasePointerCapture`));let d=o,f=s,m=le.current,h=sM(e.timeStamp),g=m!==null&&h!==null&&h>m?h-m:0,v=g>0?Math.max(g,nM):0,y=v>0?d/v:0,b=v>0?f/v:0,x=H.current.x,S=H.current.y,C=V.current;if(C&&h!==null&&h>=C.time){let e=h-C.time;if(e<=iM){let t=Math.max(e,rM),n=i.x-C.x,r=i.y-C.y,a=n/t,o=r/t;a!==0&&(x=a),o!==0&&(S=o)}else x=0,S=0}let w=p?.({event:e.nativeEvent,direction:I.current,deltaX:d,deltaY:f,velocityX:y,velocityY:b,releaseVelocityX:x,releaseVelocityY:S}),T=typeof w==`boolean`;if(R.current&&!T){N.current={x:a.x,y:a.y},D(void 0),he(!1),me(0,c);return}let E=!1,O;if(T)E=w,O=I.current??_;else for(let e of n)if(oM(e,d,f)>se.current){E=!0,O=e;break}E&&O?(D(O),j(!0),he(!1),l?.(e.nativeEvent,{direction:O})):(N.current={x:a.x,y:a.y},D(void 0),he(!1),me(0,c))}),je=Q(e=>{let t=ve(e);if(!t)return;let n=!1;if(!(`touches`in e)){let t=lM(e.buttons);if(t&&(ie.current=!0),e.buttons!==0&&!t){Te(e);return}if(e.buttons===0&&ie.current){if(!de.current){Ae(e);return}n=!0}}if(!O&&ne.current){if(!ye(e)&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)){Ce();return}if(!a||a(t,{nativeEvent:e.nativeEvent,direction:_})){let n=re.current,i=!1;if(ye(e)){let a=r.current;if(n&&a){let r=be(t,e.nativeEvent),o=cb(a).body,s=o?xe(r,o):null;if(s&&(Fv(a,s)||Fv(s,a))){let e=De(s,t.x-n.x,t.y-n.y);if(e===!1)return;e===!0&&(i=!0)}}}Se(e,t,{ignoreScrollableTarget:i,ignoreScrollableAncestors:i})&&(n&&i?(we(),M.current=n,ee.current=n,P.current=n,te.current=!1):(we(),B.current=!1))}}let i=P.current,o=i===null?{x:0,y:0}:{x:t.x-i.x,y:t.y-i.y};P.current=t,ke(e,t,o),n&&!(`touches`in e)&&Ae(e)}),Me=Q((e,t)=>{je({touches:e.touches,currentTarget:t,nativeEvent:e,defaultPrevented:e.defaultPrevented,timeStamp:e.timeStamp})}),Ne=W.useCallback(()=>{let e=de.current,t=N.current,n=F.current,r=t.x-n.x,a=t.y-n.y;return!e&&r===0&&a===0&&!A?{[i.x]:`0px`,[i.y]:`0px`}:{transition:e?`none`:void 0,transform:e?cM(t,n.scale):void 0,[i.x]:`${r}px`,[i.y]:`${a}px`}},[A,i]);return{swiping:O,swipeDirection:E,dragDismissed:A,getPointerProps:W.useCallback(()=>t?{onPointerDown:Oe,onPointerMove:je,onPointerUp:Ae,onPointerCancel:Ae}:{},[t,Ae,je,Oe]),getTouchProps:W.useCallback(()=>t?{onTouchStart:Oe,onTouchMove:je,onTouchEnd:Ae,onTouchCancel:Ae}:{},[t,Ae,je,Oe]),moveNative:Me,getDragStyles:Ne,reset:_e}}var fM=oj,pM=`data-nested-dialog-open`,mM=W.createContext(void 0);function hM(){return W.useContext(mM)}var gM=10,_M=.5,vM=.5,yM=300,bM=4,xM=.2,SM=4,CM=80,wM=360,TM=.1,EM=6,DM=2,OM=`[${vj}]`,kM=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=VA(),c=s.context.popupRef,l=s.context.backdropRef,{swipeDirection:u,notifyParentSwipingChange:d,notifyParentSwipeProgressChange:f,frontmostHeight:p,snapToSequentialPoints:m,swipeAreaActiveRef:h}=kj(),g=xj(),{snapPoints:_,resolvedSnapPoints:v,activeSnapPoint:y,activeSnapPointOffset:b,setActiveSnapPoint:x,popupHeight:S}=Nj(),C=s.useState(`open`),w=s.useState(`mounted`),T=s.useState(`nested`),E=s.useState(`nestedOpenDrawerCount`),D=s.useState(`viewportElement`),O=s.useState(`popupElement`),k=g?.visualStateStore,A=E>0,j=u===`left`||u===`right`?`horizontal`:`vertical`,M=j===`vertical`,N=M?`horizontal`:`vertical`,[P,F]=W.useState(null),I=W.useRef(void 0),L=W.useRef(null),R=sb(),ee=W.useRef(!1),z=W.useRef(!1),te=W.useRef(``),ne=W.useRef(!1),re=W.useRef(!1),B=W.useRef(null),ie=hM(),ae=W.useMemo(()=>{if(!_||_.length<2||v.length<2||u!==`down`&&u!==`up`)return null;let e=v.map(e=>e.offset).sort((e,t)=>e-t),t=e[0];return{minOffset:t,range:e[1]-t}},[v,_,u]),oe=W.useMemo(()=>!ae||b===null?null:aD((b-ae.minOffset)/ae.range,0,1),[b,ae]),se=W.useMemo(()=>_&&_.length>0&&(u===`down`||u===`up`)?u===`down`?[`down`,`up`]:[`up`,`down`]:[u],[_,u]),ce=Q(e=>{c.current?.toggleAttribute(Tj,e),l.current?.toggleAttribute(Tj,e)}),le=Q(()=>{ce(!1),c.current?.removeAttribute(Wv),F(null)}),V=Q(()=>{z.current&&(z.current=!1,d?.(!1))}),H=Q((e,t,n)=>{let r=C&&!T&&t,i=r?e:0,a=C&&t?e:0;n&&f&&(f(a),a<=0&&V()),k?.set({swipeProgress:i,frontmostHeight:i>0?p:0});let o=l.current;if(!o)return;let s=r&&i>0;o.style.setProperty(hj,s?`${i}`:`0`),s&&p>0?o.style.setProperty(lj,`${p}px`):o.style.removeProperty(lj)});function ue(e,t,n,r,i,a,o,s){let c=NM(e,t);if(c<=0)return null;let l=((t===`down`||t===`up`)&&_&&_.length>0?b??0:0)+oM(t,n,r),u=Math.max(0,c-l);if(u<=0)return null;let d=oM(t,o,s),f=Math.abs(d)>0?d:oM(t,i,a);return f<=xM?null:TM+(aD(u/aD(f,xM,SM),CM,wM)-CM)/280*.9}function de(e){if(z.current||!e)return;let t=oM(e.direction??u,e.deltaX,e.deltaY);Math.abs(t)<gM||(z.current=!0,d?.(!0))}let fe=dM({enabled:w&&!A,directions:se,elementRef:s.context.popupRef,ignoreSelectorWhenTouch:!1,ignoreScrollableAncestors:!0,movementCssVars:{x:dj,y:fj},onSwipeStart(e){if(`touches`in e||e.pointerType===`touch`)return;let t=c.current,n=cb(t).getSelection?.();if(!n||n.isCollapsed)return;let r=mv(n.anchorNode)?n.anchorNode:n.anchorNode?.parentElement,i=mv(n.focusNode)?n.focusNode:n.focusNode?.parentElement;(Fv(t,r)||Fv(t,i))&&n.removeAllRanges()},onSwipingChange(e){ee.current=e,AM(s.context.backdropRef.current,e),!e&&!f&&V()},swipeThreshold({element:e,direction:t}){return PM(e,t)},canStart(e,t){let n=s.context.popupRef.current;if(!n)return!1;let r=n.ownerDocument,i=Zj(n.getRootNode(),e.x,e.y);if(!i||!Fv(n,i))return!1;let a=t.nativeEvent;return!((`touches`in a||a.pointerType===`touch`)&&RM(r,n))},onProgress(e,t){let n=ee.current;n&&de(t);let r=!!(_&&_.length>0);if(n&&u===`down`&&r&&t){let e=s.context.popupRef.current;e&&(e.style.removeProperty(`transform`),e.style.setProperty(fj,`${Aj(b??0,t.deltaY)}px`))}let i=e;if(ae&&S>0){let e=b??ae.minOffset;n&&t&&Number.isFinite(t.deltaY)?i=(e=>aD((e-ae.minOffset)/ae.range,0,1))(aD(e+t.deltaY,0,S)):oe!==null&&(i=oe)}n||(f?.(0),V()),H(i,!0,n)},onRelease({event:e,deltaX:t,deltaY:n,direction:r,velocityX:i,velocityY:a,releaseVelocityX:o,releaseVelocityY:c}){let l=s.context.popupRef.current;if(!l){le();return}let d=l;function f(e){V(),ce(!0),d.style.removeProperty(`transition`),d.setAttribute(Wv,``),SS.flushSync(()=>{F(ue(d,e,t,n,i,a,o,c))})}if(!_||_.length===0){if(!r){le();return}let e=oM(r,t,n);if(e<=0)return le(),!1;if(oM(r,i,a)>=_M)return f(r),!0;let o=e>PM(d,r);return o?f(r):le(),o}if(u!==`down`&&u!==`up`){le();return}if(!S)return le(),!1;if(v.length===0){le();return}let p=u===`down`?n:-n,h=Math.sign(p),g=u===`down`?c:-c,C=u===`down`?a:-a,w=g;if(h!==0&&Math.abs(p)>=gM){let e=Math.sign(w);e!==0&&e!==h&&(w=C)}let T=b??0,E=aD(T+p,0,S),D=Math.abs(w)>=vM?aD(w,-4,bM)*yM:0,O=m?E:aD(E+D,0,S),k=zy(Ly,e),A=()=>(H(0,!0,!0),le(),!1),j=e=>(x(e.value,k),A()),M=e=>r?(x(null,k),k.isCanceled?A():(I.current=y,f(u),!0)):j(e);if(m){let e=[...v].sort((e,t)=>e.offset-t.offset),t=e.map(e=>e.offset),n=Mj(t,T),r=e[Mj(t,O)],i=Math.sign(w),a=h!==0&&i!==0&&i===h&&Math.abs(w)>=vM,o=O;if(a){let t=aD(n+h,0,e.length-1);if(t!==n){let n=e[t];(h>0?O<n.offset:O>n.offset)&&(r=n,o=n.offset)}else if(h>0)return M(r)}return Math.abs(o-S)<Math.abs(o-r.offset)?M(r):j(r)}let N=v[Mj(v.map(e=>e.offset),O)];return w>=_M&&p>0||Math.abs(O-S)<Math.abs(O-N.offset)?M(N):j(N)},onDismiss(e){k?.set({swipeProgress:0,frontmostHeight:0});let t=s.context.backdropRef.current;t&&(t.style.setProperty(hj,`0`),t.style.removeProperty(lj));let n=zy(Ly,e);if(s.setOpen(!1,n),n.isCanceled){let t=I.current;t!==void 0&&x(t,zy(Ly,e)),I.current=void 0,L.current?.(),le();return}if(s.select(`open`)){let t=e;R.request(()=>{if(s.select(`open`)){let e=I.current;e!==void 0&&x(e,zy(Ly,t)),I.current=void 0,le(),L.current?.()}else I.current=void 0});return}I.current=void 0,ce(!0)}}),U=fe.getPointerProps(),pe=fe.getTouchProps(),{moveNative:me,reset:he}=fe;L.current=he,W.useEffect(()=>{let e=D??O;if(!e)return;let t=e,n=cb(t);function r(e,r,i){let a=M?i.clientY-r.lastY:i.clientX-r.lastX;if(e.touches.length===2||RM(n,t)||!C||!w||A||HM(r,e,i,M))return;let o=r.scrollTarget;if(!o||o===n.documentElement||o===n.body){e.cancelable&&e.preventDefault(),e.stopPropagation(),me(e,t);return}if(!UM(o,j)){e.cancelable&&e.preventDefault(),e.stopPropagation();return}if(a!==0){let t=KM(o,j,u,a);r.allowSwipe?e.cancelable&&e.preventDefault():e.cancelable&&t?(r.allowSwipe=!0,e.preventDefault()):r.allowSwipe=!1}r.allowSwipe===!0&&(e.stopPropagation(),me(e,t))}function i(e){if(ie?.onTouchMove(e),re.current)return;let t=B.current,n=e.touches[0];n&&t&&(r(e,t,n),VM(t,n))}return Uy(n,`touchmove`,i,{passive:!1,capture:!0})},[w,A,C,O,M,j,u,me,D,ie]),X(()=>{ae&&!fe.swiping&&H(!C||T?0:oe??0,!0,!1)},[H,p,T,f,C,oe,ae,fe.swiping,s,k]),X(()=>{if(f)return C||f(0),()=>{f(0)}},[f,C]),X(()=>{C&&(h.current||he(),le())},[le,C,he,h]),X(()=>{let e=l.current;return()=>{k?.set({swipeProgress:0,frontmostHeight:0}),AM(e,!1);let t=l.current;t!==e&&AM(t,!1),V()}},[l,V,k]);let ge=W.useMemo(()=>({swiping:fe.swiping,getDragStyles:fe.getDragStyles,swipeStrength:P??null,setSwipeDismissed:ce}),[ce,fe.getDragStyles,fe.swiping,P]);function _e(e){re.current=e,B.current=null}function ve(){_e(!1),te.current=``,ne.current=!1}function ye(e){return te.current=``,e.pointerType!==`touch`}return(0,Z.jsx)(aj,{ref:t,className:r,style:i,render:n,...qx(o,{onPointerDown(e){if(te.current=e.pointerType,ne.current=e.pointerType===`pen`,!C||!w||A)return;let t=Zj(e.currentTarget.getRootNode(),e.clientX,e.clientY);jM(t)||MM(t)||e.pointerType!==`touch`&&U.onPointerDown?.(e)},onPointerMove(e){e.pointerType!==`touch`&&U.onPointerMove?.(e)},onPointerUp(e){ye(e)&&U.onPointerUp?.(e)},onPointerCancel(e){ye(e)&&U.onPointerCancel?.(e)},onTouchStart(e){if(te.current===`pen`&&ne.current){ne.current=!1,_e(!1);return}if(!C||!w||A){_e(!1);return}let t=e.touches[0];if(!t)return;if(BM(e)){_e(!1);return}let n=e.currentTarget,r=Zj(n.getRootNode(),t.clientX,t.clientY),i=Iv(e.nativeEvent),a=mv(i)?i:n;if(!Fv(n,a)){_e(!0);return}if(ie?.onTouchStart(e),jM(r)){_e(!0);return}re.current=!1;let o=Xj(a,n,j),s=Xj(a,n,N)!=null,c=null;o&&(c=GM(o,j,u)?null:!1),B.current={startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,scrollTarget:o,hasCrossAxisScrollableContent:s,allowSwipe:c,preserveNativeCrossAxisScroll:!1,drawerAxisAttributed:!1},pe.onTouchStart?.(e)},onTouchEnd(e){ie?.onTouchEnd(e),ve(),pe.onTouchEnd?.(e)},onTouchCancel(e){ie?.onTouchCancel(),ve(),pe.onTouchCancel?.(e)},[pM]:void 0}),children:(0,Z.jsx)(Pj.Provider,{value:ge,children:a})})});function AM(e,t){e?.toggleAttribute(Dj,t)}function jM(e){return!!e?.closest(vS)}function MM(e){return!!e?.closest(OM)}function NM(e,t){return t===`left`||t===`right`?e.offsetWidth:e.offsetHeight}function PM(e,t){return Math.max(NM(e,t)*.5,gM)}function FM(e,t){return e instanceof t.HTMLInputElement&&e.type===`range`}function IM(e){return e.tagName===`INPUT`||e.tagName===`TEXTAREA`}function LM(e,t){let n=mv(e.anchorNode)?e.anchorNode:e.anchorNode?.parentElement,r=mv(e.focusNode)?e.focusNode:e.focusNode?.parentElement;return e.containsNode(t,!0)||Fv(t,n)||Fv(t,r)}function RM(e,t){let n=Pv(e);if(n&&Fv(t,n)&&IM(n)){let{selectionStart:e,selectionEnd:t}=n;if(e!=null&&t!=null&&e<t)return!0}let r=e.getSelection?.();return!r||r.isCollapsed?!1:LM(r,t)}function zM(e,t){return e.composedPath().some(e=>FM(e,t))}function BM(e){return zM(e.nativeEvent,dv(e.currentTarget))}function VM(e,t){e.lastX=t.clientX,e.lastY=t.clientY}function HM(e,t,n,r){if(e.preserveNativeCrossAxisScroll)return!0;if(e.drawerAxisAttributed||e.allowSwipe===!0||!e.hasCrossAxisScrollableContent)return!1;if(!t.cancelable)return e.preserveNativeCrossAxisScroll=!0,!0;let i=r?n.clientY-e.startY:n.clientX-e.startX,a=r?n.clientX-e.startX:n.clientY-e.startY,o=Math.abs(i),s=Math.abs(a);return s>=EM&&s>o+DM?(e.preserveNativeCrossAxisScroll=!0,!0):o>=EM?(e.drawerAxisAttributed=!0,!1):!0}function UM(e,t){return WM(e,t).max>0}function WM(e,t){if(t===`vertical`){let t=Math.max(0,e.scrollHeight-e.clientHeight);return{offset:e.scrollTop,max:t}}let n=Math.max(0,e.scrollWidth-e.clientWidth);return{offset:e.scrollLeft,max:n}}function GM(e,t,n){let r=qM(n,t),{offset:i,max:a}=WM(e,t);return r?i<=0:i>=a}function KM(e,t,n,r){return(qM(n,t)?r>0:r<0)&&GM(e,t,n)}function qM(e,t){return t===`vertical`?e===`down`:e===`right`}var JM=W.createContext(void 0);function YM(e){let t=W.useContext(JM);if(t===void 0&&!e)throw Error(I_(47));return t}var XM={...Gw,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},ZM=class extends hw{constructor(e,t,n){let r=new Rw;super(QM(e,r,t,n),$M(r),XM)}setOpen=(e,t)=>{let n=t.reason===wy,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=jw(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Aw(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),SS.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function QM(e,t,n,r=!1){let i={...zw(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function $M(e){return{popupRef:W.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:W.createRef(),beforeContentFocusGuardRef:W.createRef(),stickIfOpenTimeout:new V_,triggerElements:e}}var eN=k_(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=nN(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Lw(u,d),Pw(u);let{forceUnmount:m}=Fw(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),W.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),W.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,zy(Iy))}),[m,u]);let h=d||f;return(0,Z.jsxs)(JM.Provider,{value:u,children:[s&&(0,Z.jsx)(Dw,{handle:s,store:u}),h&&(0,Z.jsx)(rN,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function tN(e){return YM(!0)?(0,Z.jsx)(eN,{props:e}):(0,Z.jsx)(IS,{children:(0,Z.jsx)(eN,{props:e})})}function nN(e,t){let n=Ew((e,n)=>new ZM(t,e,n));return W.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function rN({store:e,modal:t}){let n=$S(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Iw(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var iN=A_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=YM(!0),h=Kw(s)??m;if(!h)throw Error(I_(74));let g=kT(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=W.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Nw(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),O=aT(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:ST(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=qS(v,{stickIfOpen:T}),A=rD(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:N}=_D({disabled:a,native:o}),P={open(e){return e&&w===`trigger-press`?ay.open(e):iy.open(e)}},{preFocusGuardRef:F,handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=Zk(h,x),R=sS(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,O,j,A,{[hS]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:P}),ee=(0,Z.jsx)(W.Fragment,{children:R},g);return C&&!D?(0,Z.jsxs)(W.Fragment,{children:[(0,Z.jsx)(fb,{ref:F,onFocus:I}),ee,(0,Z.jsx)(fb,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):ee}),aN=W.createContext(void 0);function oN(){let e=W.useContext(aN);if(e===void 0)throw Error(I_(45));return e}var sN=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return YM().useState(`mounted`)||n?(0,Z.jsx)(aN.Provider,{value:n,children:(0,Z.jsx)(DS,{ref:t,...r})}):null}),cN=W.createContext(void 0);function lN(){let e=W.useContext(cN);if(!e)throw Error(I_(46));return e}var uN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=bS,..._}=e,v=YM(),y=oN(),b=PS(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=W.useRef(null),N=Sw(O),P=rE({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),F=x.useState(`domReferenceElement`);X(()=>{let e=F,t=M.current;if(e&&(M.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return N(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[F,N,v]);let I=E===!0&&w!==`trigger-hover`;$D(C&&I,D===`touch`,O,T);let L=v.useStateSetter(`positionerElement`),R=sE(e,{open:C,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:k},{styles:P.positionerStyles,transitionStatus:A,props:_,refs:[t,L],hidden:!S,inert:!C});return(0,Z.jsxs)(cN.Provider,{value:P,children:[S&&I&&(0,Z.jsx)(RD,{inert:uE(!C),cutout:T}),(0,Z.jsx)(FS,{id:b,children:R})]})}),dN=W.createContext(void 0);function fN(){let[e,t]=W.useState(0),n=Q(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:W.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var pN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=YM(),l=lN(),u=aO(!0)!=null,{context:d,hasClosePart:f}=fN(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);Cw({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),rT(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Tw(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=sS(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...ww,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&uO.has(e.key)&&e.stopPropagation()}},oE(g),s],stateAttributesMapping:sy});return(0,Z.jsx)(KS,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:hv(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Z.jsx)(dN.Provider,{value:d,children:M})})}),mN=(0,W.createContext)(void 0),hN=e=>({className:t})=>(0,W.createElement)($o,{icon:e,"aria-hidden":!0,...t===void 0?{}:{className:t}}),gN={arrowLeft:hN(bo),arrowsExpand:hN(vo),arrowsToCenter:hN(So),bulletList:hN(Io),buttonCursor:hN(Do),chatBubble:hN(wo),chevronDown:hN(_o),chevronLeft:hN(yo),chevronRight:hN(xo),chevronUp:hN(Co),dividerY:hN(Ko),download:hN(Oo),envelope:hN(Lo),eye:hN(Zo),files:hN(ko),frame:hN(Ao),gridLayoutRows:hN(Fo),heading1:hN(jo),image:hN(Mo),layers:hN(No),message:hN(Ro),mobile:hN(Jo),monitor:hN(Eo),moon:hN(zo),palette:hN(Bo),paragraph:hN(Go),sidebarLeft:hN(Ho),sidebarLeftHide:hN(Vo),sidebarRight:hN(Wo),sidebarRightHide:hN(Uo),sliders:hN(qo),sparkle:hN(Yo),sun:hN(Xo),textColumns:hN(Po),xmark:hN(To)},_N=(0,W.createContext)(gN),vN=_N.Provider,yN=()=>(0,W.useContext)(_N),bN=(0,W.createContext)(null);function xN(){let e=(0,W.useContext)(bN);if(e===null)throw Error(`useEditorBundle must be used within an EditorProvider`);return e}function $(e){return rs(xN().store,e)}function SN(){return xN().store}var CN=e=>`${e.fileName}:${e.lineNumber}:${e.columnNumber}`,wN=e=>e.occurrences>1?`${e.tag} ${e.occurrence} of ${e.occurrences}`:e.tag,TN=(e,t)=>{let n=e.origins[0];if(n===void 0)return wN(e);let r=t.split(`
28
+ `)[n.lineNumber-1];return r===void 0?wN(e):r.slice(Math.max(0,n.columnNumber-1)).match(/<([A-Za-z][A-Za-z0-9_.:-]*)/)?.[1]??wN(e)},EN=(e,t)=>{let n=t.slice(e.start,e.end).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,` `).replace(/<[^>]+>/g,` `).replace(/&nbsp;/gi,` `).replace(/&amp;/gi,`&`).replace(/&lt;/gi,`<`).replace(/&gt;/gi,`>`).replace(/&quot;/gi,`"`).replace(/&#39;/gi,`'`).replace(/\s+/g,` `).trim();if(n!==``)return n.length>72?`${n.slice(0,69).trimEnd()}…`:n},DN=e=>{let t=[],n=(e,r)=>{t.push({depth:r,node:e});for(let t of e.children)n(t,r+1)};for(let t of e.roots)n(t,0);return t},ON=e=>{let t=Jc(e),n=new Map,r=new Map,i=[];for(let t of e){let e=[];n.set(t.instancePath,e);let a={instancePath:t.instancePath,selection:t,children:e};r.set(t.instancePath,a);let o=t.parentPath===void 0?void 0:n.get(t.parentPath);o===void 0?i.push(a):o.push(a)}return{roots:i,index:t,nodes:r}},kN=(e,t)=>{let n=[],r=e.index.get(t)?.parentPath;for(;r!==void 0;)n.unshift(r),r=e.index.get(r)?.parentPath;return n},AN=(e,t)=>[...kN(e,t),t].flatMap(t=>{let n=e.index.get(t);return n===void 0?[]:[{instancePath:t,label:wN(n)}]}),jN=e=>{let t=new Set;if(e===null)return t;for(let n of e.roots){t.add(n.instancePath);for(let e of n.children)e.children.length>0&&t.add(e.instancePath)}return t},MN={kind:`document`},NN={kind:`envelope`},PN=e=>new TextEncoder().encode(e).length,FN=e=>Math.max(1,Math.round(e/1024)),IN=e=>e.render===null?0:e.channel===`email`?FN(PN(e.render.html)):e.channel===`sms`?FN(PN(e.render.text)):FN(PN(JSON.stringify(e.render))),LN=(e,t)=>({outline:e.channel===`email`&&e.render!==null?ON(e.render.selections):null,sizeKb:IN(e),checks:YN(e,t)}),RN=(e,t)=>e.origins.length===t.origins.length&&e.origins.every((e,n)=>{let r=t.origins[n];return r!==void 0&&r.fileName===e.fileName&&r.lineNumber===e.lineNumber&&r.columnNumber===e.columnNumber}),zN=(e,t)=>e.tag===t.tag&&e.authored===t.authored&&e.occurrence===t.occurrence&&e.occurrences===t.occurrences&&RN(e,t),BN=(e,t,n)=>{if(e.kind!==`element`)return e;if(t===null||t.channel!==`email`)return MN;let{render:r,fixture:i}=t;if(r===null||i===null)return MN;let a=r.selections.find(t=>t.instancePath===e.instancePath);if(a===void 0)return MN;if(e.revision===r.revision&&e.fixture===i)return e;let o=n?.index.get(e.instancePath);return o===void 0||!zN(o,a)?MN:{kind:`element`,instancePath:e.instancePath,revision:r.revision,fixture:i}},VN=(e,t,n)=>{let r=t.authoredSource!==void 0&&(n===null||n===t.authoredSource)?t.authoredSource:e.origin.authoredSource,i={...e.origin,authoredSource:r};if(t.channel!==e.channel)throw Error(`Host sent a ${t.channel} change for a ${e.channel} document`);return{...e,rev:t.rev,origin:i,fixtures:t.fixtures,fixture:t.fixture,preview:t.preview,render:t.render,diagnostics:t.diagnostics,...t.channel===`email`?{incompatibilities:t.incompatibilities}:{}}},HN=104448,UN=e=>e.severity===`error`?`error`:e.severity===`warning`?`warn`:`info`,WN=e=>e===`caniemail/system-ui-ui-serif-ui-sans-serif-ui-rounded-ui-monospace`?`System fonts`:e===`caniemail/media`?`Media queries`:e===`caniemail/color-scheme-meta-tag`?`Color scheme metadata`:e.startsWith(`caniemail/`)?e.slice(10).replace(/-property$/,``).replace(/-attribute$/,` attribute`).replace(/-element$/,` element`):e.replaceAll(`-`,` `),GN=(e,t)=>{let n=new Map;for(let t of e){let e=n.get(t.code)??new Map,r=JSON.stringify([t.severity,t.compatibility?.assessment,t.compatibility?.title,t.message,[...t.clients??[]].sort(),t.notes,t.provenance]),i=e.get(r),a=new Map;for(let e of i===void 0?[t]:[i,t])for(let t of e.occurrences??[e.origins])t.length>0&&a.set(JSON.stringify(t),t);e.set(r,{...t,origins:i?.origins??t.origins,fixtures:[...new Set([...i?.fixtures??[],...t.fixtures??[]])].sort(),occurrences:[...a.values()]}),n.set(t.code,e)}return[...n].map(([e,n])=>KN(`${t}:${e}`,[...n.values()]))},KN=(e,t)=>{let n=e=>e.compatibility?.assessment===`unverified`?0:e.compatibility?.assessment===`degradation`?1:2,r=[...t].sort((e,t)=>n(e)-n(t)),i=r.find(e=>e.severity===`error`)??r.find(e=>e.severity===`warning`)??r[0],a=new Set(r.flatMap(e=>e.fixtures??[])),o=new Set(r.flatMap(e=>e.clients??[]));return{id:e,severity:UN(i),label:i.compatibility?.title??WN(i.code),detail:[`${r.length} finding${r.length===1?``:`s`}`,...o.size===0?[]:[`${o.size} client${o.size===1?``:`s`}`],...a.size===0?[]:[`${a.size} fixture${a.size===1?``:`s`}`]].join(` · `),diagnostics:r}},qN=e=>{let t=PN(e.html);return t<=HN?{id:`size:gmail-clip`,severity:`ok`,label:`Gmail clipping`,detail:`HTML is ${Math.ceil(t/1024)} KB, under Gmail's 102 KB clipping threshold.`}:{id:`size:gmail-clip`,severity:`warn`,label:`Gmail clipping risk`,detail:`HTML is ${Math.ceil(t/1024)} KB, above Gmail's 102 KB clipping threshold.`}},JN={id:`build:no-render`,severity:`error`,label:`No render`,detail:`The template entry did not produce a render at this revision.`},YN=(e,t)=>{let n=[...GN(e.diagnostics,`diagnostic`),...e.channel===`email`?GN(e.incompatibilities,`compat`):[]];return e.render===null?[...n.length===0?[JN]:n,...t]:e.channel===`email`?[...n,qN(e.render),...t]:[...n,...t]},XN=e=>{let t=[],n=[],r=[],i=[];for(let a of e)a.severity===`error`?t.push(a):a.severity===`warn`?n.push(a):a.severity===`info`?r.push(a):i.push(a);return{actionable:[...t,...n],info:r,ok:i,errorCount:t.length,warnCount:n.length,badgeCount:t.length+n.length}},ZN=e=>j(e,`_tag`)&&e._tag===`DocumentUnavailable`&&j(e,`reason`)&&typeof e.reason==`string`,QN=e=>ZN(e)?e.reason:e instanceof Error?e.message:`The document session failed.`,$N=(e,t)=>{let n=``,r=[],i=!1,a,o=!1,s=!1,c,l=[],u=0,d=()=>{let e=l;l=[];for(let t of e)t.resolve(n)},f=e=>{let t=l;l=[];for(let n of t)n.reject(e)},p=()=>{if(a!==void 0&&(clearTimeout(a),a=void 0),e.access!==`editable`)return;let s=e.writer;if(i)return;i=!0;let c=u;(async()=>{for(;r.length>0&&!o;){let e=r[0],a={kind:`authoredSource`,baseRev:n,authoredSource:e.authoredSource};try{let e=await s.save(a);if(u!==c)return;n=e.rev,t.onPersistedRevision(n),r.shift(),t.onStorageError(null)}catch(e){if(u!==c)return;if(ZN(e)){t.onStorageError(e.reason),i=!1,f(e);return}r=[],o=!0,t.onConflict();break}}u===c&&(i=!1,d())})()},m=()=>{u+=1,i=!1,s=!1;let a=u,l=!1,d=[],f=e=>{if(u!==a)return;if(e.origin===`self`){t.onSelfAck(e);return}let i=r.length>0;i&&(o=!0),n=e.rev,t.onForeignChange(e,i)};e.document.open(e=>{l?f(e):d.push(e)},e=>{u===a&&(s=!1,t.onSessionError(QN(e)))}).then(({initial:e,close:i})=>{if(u!==a){i();return}c=i,l=!0,s=!0,n=e.rev,t.onInitial(e);for(let e of d)f(e);d.length=0,r.length>0&&p()}).catch(e=>{u===a&&t.onSessionError(QN(e))})};return{open:m,dispose:()=>{u+=1,a!==void 0&&clearTimeout(a),a=void 0,s=!1,c?.(),c=void 0},reload:()=>{o=!1,r=[],i=!1,a!==void 0&&clearTimeout(a),a=void 0,d(),c?.(),c=void 0,m()},enqueueAuthoredSource:(t,n)=>{if(e.access!==`editable`)return;let o={kind:`authoredSource`,authoredSource:t,coalesceKey:n?.coalesceKey},s=r.length-1,c=r[s],l=s>=+!!i;o.coalesceKey!==void 0&&l&&c?.kind===`authoredSource`&&c.coalesceKey===o.coalesceKey?r[s]=o:r.push(o),a!==void 0&&clearTimeout(a),a=setTimeout(p,300)},flushSaves:()=>(a!==void 0&&p(),r.length===0&&!i?Promise.resolve(n):new Promise((e,t)=>{l.push({resolve:e,reject:t})})),retrySave:()=>{if(e.access===`editable`){if(t.onStorageError(null),!s){c?.(),c=void 0,m();return}p()}},adoptRev:e=>{n=e,o=!1}}},eP={desktop:600,mobile:375},tP=`samva.editor.leftWidth`,nP=`samva.editor.assistantWidth`,rP=`samva.editor.rightWidth`,iP=260,aP=360,oP=320,sP=200,cP=420,lP=300,uP=520,dP=260,fP=440,pP=(e,t)=>{try{let n=localStorage.getItem(e);if(n===null)return t;let r=Number(n);return Number.isFinite(r)?r:t}catch{return t}},mP=(e,t)=>{try{localStorage.setItem(e,String(t))}catch{}},hP=e=>e!==null&&e.channel===`email`?e.render:null,gP=(e,t)=>{let n,r,i=t=>e.access!==`editable`||t.doc?.access.kind===`readonly`||t.lifecycleBusy,a=t=>t!==null&&e.access===`editable`&&e.sourceAccess===`editable`&&t.access.kind!==`readonly`,o=(e,t,n)=>{let r=LN(t,e.hostChecks),i=!e.layersSeeded&&r.outline!==null;return{doc:t,pendingAuthoredSource:n,...r,render:hP(t),expandedLayers:i?jN(r.outline):e.expandedLayers,layersSeeded:e.layersSeeded||i,selection:BN(e.selection,t,e.outline)}},s=ts((s,c)=>{let l=(e,t)=>{let r=c();r.doc!==null&&(s({doc:{...r.doc,origin:{...r.doc.origin,authoredSource:e}},pendingAuthoredSource:e,sourceEditError:null}),n.enqueueAuthoredSource(e,{coalesceKey:t?.coalesceKey??`authored-source`}))},u=e=>{let t=c();if(i(t)||!t.sourceEditable||t.conflict||t.doc===null)return;let n=e===`undo`?t.undoHistory:t.redoHistory,r=n.at(-1);if(r!==void 0){if(t.doc.origin.authoredSource!==(e===`undo`?r.after:r.before)){s({sourceEditError:`History conflicts with a newer change. Your current work is kept. Review the saved versions.`});return}s(e===`undo`?{undoHistory:n.slice(0,-1),redoHistory:[...t.redoHistory,r]}:{redoHistory:n.slice(0,-1),undoHistory:[...t.undoHistory,r]}),l(e===`undo`?r.before:r.after)}};return{sourceEditError:null,assistantOriginIndex:0,undoHistory:[],redoHistory:[],workspaceView:`visual`,doc:null,pendingAuthoredSource:null,editable:e.access===`editable`,sourceEditable:e.access===`editable`&&e.sourceAccess===`editable`,metadataEditable:e.access===`editable`&&e.metadataAccess!==`readonly`,readonlyReason:null,render:null,outline:null,sizeKb:0,checks:t.hostChecks,hostChecks:t.hostChecks,lifecycleCapability:e.lifecycle,versionsCapability:e.versions,telemetry:e.telemetry,assetsCapability:e.assets,fixtureCapability:e.fixtures,fixtureBusy:!1,fixtureError:null,diagnosticAssistance:null,selection:MN,renameActive:!1,expandedLayers:new Set,layersSeeded:!1,leftCollapsed:!1,rightCollapsed:!1,designView:`layers`,focusedPane:`assistant`,leftWidth:pP(tP,iP),assistantWidth:Math.min(uP,Math.max(lP,pP(nP,aP))),rightWidth:pP(rP,oP),previewDevice:`desktop`,canvasZoom:`100`,layoutMode:`wide`,metadataSaving:!1,metadataError:null,lifecycleBusy:!1,conflict:!1,storageError:null,hoveredCandidatePath:null,actions:{requestSourceAssistance:e=>s({assistantOriginIndex:e,rightCollapsed:!1}),requestDiagnosticAssistance:e=>{let t=c();t.doc===null||i(t)||t.pendingAuthoredSource!==null||t.conflict||s({diagnosticAssistance:{id:(t.diagnosticAssistance?.id??0)+1,revision:t.doc.rev,check:e},rightCollapsed:!1})},openSource:()=>s({workspaceView:`source`}),undo:()=>u(`undo`),redo:()=>u(`redo`),applySourceEdit:e=>{let t=c();if(i(t)||!t.sourceEditable||t.conflict||t.doc===null)return;if(t.doc.rev!==e.revision||t.doc.origin.authoredSource!==e.source||t.pendingAuthoredSource!==null&&e.coalesceKey===void 0){s({sourceEditError:`That edit is stale. The preview moved on. Reselect the element and try again.`});return}let n=Sg(e.source,e.edits,{profile:{entry:t.doc.origin.file}});if(!n.ok){s({sourceEditError:n.reason});return}if(n.source===e.source)return;let r=t.undoHistory.at(-1);s({undoHistory:e.coalesceKey!==void 0&&r?.key===e.coalesceKey&&r.after===e.source?[...t.undoHistory.slice(0,-1),{before:r.before,after:n.source,key:e.coalesceKey}]:[...t.undoHistory,{before:e.source,after:n.source,key:e.coalesceKey}],redoHistory:[]}),l(n.source,{coalesceKey:e.coalesceKey})},replaceAuthoredSource:e=>{let t=c();i(t)||!t.sourceEditable||t.doc===null||e===t.doc.origin.authoredSource||t.conflict||(s({undoHistory:[...t.undoHistory,{before:t.doc.origin.authoredSource,after:e}],redoHistory:[]}),l(e))},viewFixture:e=>{let t=c(),n=t.fixtureCapability;n?.status===`ready`&&t.doc!==null&&!t.fixtureBusy&&t.doc.fixtures.includes(e)&&t.doc.fixture!==e&&(s({fixtureBusy:!0,fixtureError:null}),n.api.view(e).then(()=>s({fixtureBusy:!1}),()=>s({fixtureBusy:!1,fixtureError:`Couldn't render the ${e} fixture.`})))},reload:()=>{c().lifecycleBusy||(s({conflict:!1,storageError:null,fixtureError:null}),n.reload())},flushSaves:()=>n.flushSaves(),beginLifecycle:()=>{let t=c();return t.lifecycleBusy||t.doc===null||e.access!==`editable`||t.doc.access.kind===`readonly`?!1:(s({lifecycleBusy:!0}),!0)},endLifecycle:()=>s({lifecycleBusy:!1}),adoptLifecycleSnapshot:e=>{n.adoptRev(e.rev),s(t=>{if(t.doc===null)return{conflict:!1};let n={...t.doc,rev:e.rev,origin:{...t.doc.origin,authoredSource:e.authoredSource}};return{...o(t,n,null),sourceEditable:a(n),conflict:!1}})},retrySave:()=>{i(c())||n.retrySave()},select:e=>{s(t=>{if(e===null)return{selection:MN};let{render:n,doc:r}=t;if(n===null||r?.channel!==`email`||r.fixture===null||!n.selections.some(t=>t.instancePath===e))return{selection:MN};let i=new Set(t.expandedLayers);if(t.outline!==null)for(let n of kN(t.outline,e))i.add(n);return{assistantOriginIndex:0,selection:{kind:`element`,instancePath:e,revision:n.revision,fixture:r.fixture},expandedLayers:i}});let{selection:t}=c();t.kind===`element`&&r?.({instancePath:t.instancePath,revision:t.revision,fixture:t.fixture})},selectDocument:()=>s({selection:MN}),selectEnvelope:()=>s({selection:NN}),toggleLeft:()=>s(e=>({leftCollapsed:!e.leftCollapsed})),toggleRight:()=>s(e=>({rightCollapsed:!e.rightCollapsed})),setDesignView:e=>{c().designView!==e&&s({designView:e})},setFocusedPane:e=>{c().focusedPane!==e&&s({focusedPane:e})},openReview:()=>s(e=>({designView:`review`,focusedPane:e.layoutMode===`narrow`?`assistant`:`design`})),setWorkspaceView:e=>s({workspaceView:e}),setLeftWidth:e=>{let t=Math.min(cP,Math.max(sP,Math.round(e)));mP(tP,t),s({leftWidth:t})},setAssistantWidth:e=>{let t=Math.min(uP,Math.max(lP,Math.round(e)));mP(nP,t),s({assistantWidth:t})},setRightWidth:e=>{let t=Math.min(fP,Math.max(dP,Math.round(e)));mP(rP,t),s({rightWidth:t})},setPreviewDevice:e=>s({previewDevice:e}),setCanvasZoom:e=>s({canvasZoom:e}),setLayoutMode:e=>{if(c().layoutMode!==e){if(e===`wide`){s({layoutMode:e,leftCollapsed:!1,rightCollapsed:!1,canvasZoom:`100`});return}if(e===`standard`){s({layoutMode:e,leftCollapsed:!1,rightCollapsed:!0,canvasZoom:`fit`});return}s({layoutMode:e,leftCollapsed:!0,rightCollapsed:!0,canvasZoom:`fit`})}},setRenameActive:e=>s({renameActive:e}),rename:t=>{let n=c();if(i(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let r=e.writer,a=n.doc;if(a===null)return;let o=t.trim()||`Untitled template`;o!==a.name&&(s(e=>e.doc===null?e:{doc:{...e.doc,name:o},metadataSaving:!0,metadataError:null}),r.save({kind:`metadata`,patch:{name:o}}).then(()=>s({metadataSaving:!1}),()=>{s(e=>({doc:e.doc===null?e.doc:{...e.doc,name:a.name},metadataSaving:!1,metadataError:`Couldn't save the template name.`}))}))},saveMetadata:t=>{let n=c();if(i(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let r=e.writer,a=n.doc;a!==null&&(s(e=>e.doc===null?e:{doc:{...e.doc,metadata:{fromDefault:t.fromDefault===void 0?e.doc.metadata.fromDefault:t.fromDefault??void 0,replyToDefault:t.replyToDefault===void 0?e.doc.metadata.replyToDefault:t.replyToDefault??void 0}},metadataSaving:!0,metadataError:null}),r.save({kind:`metadata`,patch:t}).then(()=>s({metadataSaving:!1}),()=>{s(e=>({doc:e.doc===null?e.doc:{...e.doc,metadata:a.metadata},metadataSaving:!1,metadataError:`Couldn't save the sender defaults.`}))}))},toggleLayerExpand:e=>s(t=>{let n=new Set(t.expandedLayers);return n.has(e)?n.delete(e):n.add(e),{expandedLayers:n}}),ancestryOf:e=>{let{outline:t}=c();return t===null?[]:kN(t,e)},breadcrumbOf:e=>{let{outline:t}=c();return t===null?[]:AN(t,e)},setHovered:e=>s({hoveredCandidatePath:e}),setHostChecks:e=>{Object.is(c().hostChecks,e)||s(t=>({hostChecks:e,checks:t.doc===null?e:YN(t.doc,e)}))}}}}),c=(e,t)=>{s.setState(n=>{if(n.doc===null)return n;let r=t?n.pendingAuthoredSource:null,i=VN(n.doc,e,r),a=e.authoredSource!==void 0&&e.authoredSource===i.origin.authoredSource;return o(n,i,a?null:r)})};return n=$N(e,{onInitial:t=>{s.setState(n=>({...o(n,t,null),editable:e.access===`editable`&&t.access.kind!==`readonly`,sourceEditable:a(t),readonlyReason:t.access.kind===`readonly`?t.access.reason:null}))},onPersistedRevision:e=>{s.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e}})},onSelfAck:e=>c(e,!0),onForeignChange:(e,t)=>{if(t){s.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e.rev},sourceEditable:!1,conflict:!0});return}c(e,!1),s.setState(e=>({sourceEditable:a(e.doc)}))},onConflict:()=>s.setState({conflict:!0,sourceEditable:!1}),onStorageError:e=>s.setState({storageError:e}),onSessionError:e=>s.setState({storageError:e})}),{host:e,store:s,spine:n,setUserSelectListener:e=>{r=e}}},_P=[];function vP({host:e,checks:t=_P,icons:n,onSelectElement:r,preparePreviewDocument:i,children:a}){let[o,s]=(0,W.useState)(()=>gP(e,{hostChecks:t}));o.host!==e&&s(gP(e,{hostChecks:t})),(0,W.useEffect)(()=>(o.spine.open(),()=>o.spine.dispose()),[o]),(0,W.useEffect)(()=>{o.store.getState().actions.setHostChecks(t)},[o,t]),(0,W.useLayoutEffect)(()=>(o.setUserSelectListener(r),()=>o.setUserSelectListener(void 0)),[o,r]);let c=(0,W.useMemo)(()=>n===void 0?gN:{...gN,...n},[n]);return(0,Z.jsx)(bN.Provider,{value:o,children:(0,Z.jsx)(mN.Provider,{value:i,children:(0,Z.jsx)(vN,{value:c,children:a})})})}var yP=e=>{let t=({className:t})=>{let n=yN()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})};return t.displayName=`EditorIcon(${e})`,t},bP=yP(`arrowsExpand`),xP=yP(`arrowsToCenter`),SP=yP(`bulletList`),CP=yP(`buttonCursor`),wP=yP(`chevronDown`),TP=yP(`chevronLeft`),EP=yP(`chevronRight`),DP=yP(`chevronUp`),OP=yP(`dividerY`),kP=yP(`download`),AP=yP(`envelope`),jP=yP(`eye`),MP=yP(`files`),NP=yP(`frame`),PP=yP(`gridLayoutRows`),FP=yP(`heading1`),IP=yP(`image`),LP=yP(`layers`),RP=yP(`mobile`),zP=yP(`monitor`),BP=yP(`palette`),VP=yP(`paragraph`),HP=yP(`sidebarLeft`),UP=yP(`sidebarLeftHide`),WP=yP(`sidebarRight`),GP=yP(`sidebarRightHide`),KP=yP(`sliders`),qP=yP(`sparkle`),JP=yP(`textColumns`),YP=yP(`xmark`);function XP(...e){return HO(e)}var ZP=`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,QP=XP(`inline-flex items-center justify-center gap-1.5 rounded-[7px] font-medium transition-all outline-none disabled:pointer-events-none disabled:opacity-50`,`bg-[var(--editor-raised-bg)] text-[color:var(--editor-raised-fg)] shadow-[var(--editor-raised-shadow)]`,`hover:bg-[var(--editor-raised-bg-hover)] aria-expanded:bg-[var(--editor-raised-bg-hover)] data-popup-open:bg-[var(--editor-raised-bg-hover)]`,`active:translate-y-px active:shadow-[var(--editor-raised-shadow-pressed)] disabled:shadow-none data-disabled:shadow-none`,ZP),$P=XP(`inline-flex items-center justify-center gap-1.5 rounded-md border border-transparent font-medium whitespace-nowrap text-muted-foreground outline-none`,`hover:bg-muted hover:text-foreground`,`transition-[color,background-color,border-color,box-shadow] duration-150 ease-out`,ZP,`data-[pressed]:border-[color:var(--editor-chip-border)] data-[pressed]:bg-[var(--editor-chip-bg)] data-[pressed]:text-[color:var(--editor-chip-fg)] data-[pressed]:shadow-[var(--editor-chip-shadow)]`,`data-active:border-[color:var(--editor-chip-border)] data-active:bg-[var(--editor-chip-bg)] data-active:text-[color:var(--editor-chip-fg)] data-active:shadow-[var(--editor-chip-shadow)]`,`aria-pressed:border-[color:var(--editor-chip-border)] aria-pressed:bg-[var(--editor-chip-bg)] aria-pressed:text-[color:var(--editor-chip-fg)] aria-pressed:shadow-[var(--editor-chip-shadow)]`),eF=XP(`min-h-9 w-full rounded-lg border border-border bg-background px-2.5 text-[13px] text-foreground outline-none disabled:cursor-not-allowed disabled:bg-surface-inset disabled:text-muted-foreground`,ZP),tF=new Set([`frame.start`,`document.switcher`,`rail.assistant`,`rail.review`,`statusbar.headline`]),nF=e=>{let t=new Set,n=new Map;for(let r of e){if(t.has(r.id))throw Error(`Editor contribution id "${r.id}" is used twice.`);t.add(r.id);let e=n.get(r.slot)??[];if(tF.has(r.slot)&&e.length>0)throw Error(`Editor region "${r.slot}" holds one contribution; "${e[0].id}" and "${r.id}" both target it.`);e.push(r),n.set(r.slot,e)}let r=n.get(`toolbar.actions`);if(r!==void 0){let e=e=>e.slot===`toolbar.actions`?e.order:void 0;n.set(`toolbar.actions`,r.toSorted((t,n)=>{let r=e(t),i=e(n);return r===void 0||i===void 0?r===i?0:r===void 0?1:-1:r-i}))}let i=e=>(n.get(e)??[]).filter(t=>t.slot===e);return{all:i,one:e=>i(e)[0]}},rF=(0,W.createContext)(nF([])),iF=rF.Provider,aF=e=>(0,W.useContext)(rF).one(e),oF=e=>(0,W.useContext)(rF).all(e),sF=(0,W.createContext)(null),cF=sF.Provider;function lF(){let e=aF(`rail.assistant`),t=aF(`rail.review`),n=(0,W.useContext)(sF),r=SN(),{doc:i,render:a,outline:o,selection:s,originIndex:c,checks:l,diagnosticAssistance:u,layout:d,canFix:f}=$(BO(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,originIndex:e.assistantOriginIndex,checks:e.checks,diagnosticAssistance:e.diagnosticAssistance,layout:e.layoutMode,canFix:e.sourceEditable&&!e.conflict&&e.pendingAuthoredSource===null&&!e.lifecycleBusy})));if(e===void 0||n===null)return null;let p=XN(l),m=s.kind===`element`?o?.index.get(s.instancePath)??null:null,h=m===null||s.kind!==`element`?null:{originIndex:c,instancePath:m.instancePath,fixture:s.fixture,label:wN(m)},g=i?.channel===`email`?i.fixture:null,_=o===null||g===null||a===null||i===null?[]:DN(o).map(({depth:e,node:t})=>{let n=EN(t.selection,a.html);return{instancePath:t.instancePath,fixture:g,...t.selection.origins[c]===void 0?{}:{originIndex:c},label:TN(t.selection,i.origin.authoredSource),...n===void 0?{}:{detail:n},depth:e,active:s.kind===`element`&&s.instancePath===t.instancePath}});return{panel:e.render({flushSaves:()=>r.getState().actions.flushSaves(),exportHtml:n.exportHtml,canExport:n.canExport,openReview:t===void 0?void 0:()=>r.getState().actions.openReview(),workspace:{draftRevision:i?.rev??null,saveVersionStatus:n.saveVersionStatus,checks:{errors:p.errorCount,warnings:p.warnCount,findings:p.actionable,canFix:f},diagnosticAssistance:u,pointedElement:h,availableInstancePaths:o===null?[]:[...o.index.keys()],layout:d,layers:_}}),header:e.header??null}}function uF({hidden:e=!1}){let t=lF(),n=$(e=>e.assistantWidth),r=$(e=>e.layoutMode),i=r===`compact`||r===`narrow`;return t===null?null:(0,Z.jsx)(`aside`,{"aria-label":`Assistant`,hidden:e,"data-editor-rail":`left`,"data-testid":`agent-column`,style:i?void 0:{width:n},className:XP(`min-h-0 min-w-0 flex-col overflow-hidden bg-background`,e?`hidden`:`flex`,i&&`h-full w-full flex-1`,!i&&`h-full shrink-0 border-r border-border`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,style:i?void 0:{width:n,maxWidth:`100%`},children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex min-h-11 shrink-0 items-center gap-2 border-b px-3 py-2`,children:[(0,Z.jsx)(qP,{className:`text-accent-orange size-[15px] shrink-0`}),(0,Z.jsx)(`p`,{className:`text-foreground truncate text-[13px] leading-none font-semibold`,children:`Assistant`}),t.header!==null&&(0,Z.jsx)(`div`,{className:`ml-auto shrink-0`,children:t.header})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:t.panel})]})})}function dF(){let e=lF(),{rightCollapsed:t,rightWidth:n,layoutMode:r}=$(BO(e=>({rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode})));if(e===null)return null;let i=r===`compact`||r===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Assistant`,"aria-hidden":t||void 0,inert:t||void 0,"data-editor-rail":`right`,style:{width:t?0:n,maxWidth:i?`calc(100% - 48px)`:void 0},className:XP(`flex h-full shrink-0 flex-col overflow-hidden border-l border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,i&&`absolute inset-y-0 right-0 z-40 shadow-[var(--shadow-floating)]`,t&&`border-l-0`),children:(0,Z.jsx)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:n,maxWidth:`100%`},children:(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:e.panel})})})}var fF=(0,W.createContext)(void 0),pF=()=>(0,W.useContext)(fF);function mF({label:e,source:t,editable:n,onChange:r,testId:i}){return(0,Z.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{className:`border-border-subtle bg-surface-inset text-muted-foreground border-b px-4 py-2 font-mono text-[11px] font-medium`,children:e}),(0,Z.jsx)(`textarea`,{"aria-label":e,"data-testid":i,readOnly:!n,spellCheck:!1,value:t,onChange:e=>r?.(e.target.value),className:XP(`border border-[color:var(--editor-well-border)] bg-[var(--editor-well-bg)] shadow-[var(--editor-well-shadow)]`,`samva-editor-scroll text-foreground min-h-0 flex-1 resize-none border-t-0 p-4 font-mono text-[12.5px] leading-5 outline-none`,`read-only:bg-muted read-only:shadow-none dark:read-only:bg-muted/40`)})]})}function hF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),{replaceAuthoredSource:n}=$(e=>e.actions);return e===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid flex-1 place-items-center text-sm`,children:`Loading…`}):(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:(0,Z.jsx)(mF,{label:`Authored TSX · ${e.origin.file}`,source:e.origin.authoredSource,editable:t,testId:`source-workspace.authored-tsx`,onChange:t?n:void 0})})}function gF(e){let t=SN(),{applySourceEdit:n}=$(e=>e.actions);return(0,W.useCallback)((r,i)=>{let{doc:a}=t.getState();if(a===null)return;let o=a.origin.authoredSource,s=e(o,r);if(!s.ok){t.setState({sourceEditError:s.reason});return}s.edits.length!==0&&n({revision:a.rev,source:o,edits:s.edits,coalesceKey:i})},[n,e,t])}function _F(e,t){return`${e}-view-tab-${t}`}var vF=XP($P,`h-7 px-2.5 text-[12px] capitalize`);function yF({value:e,onChange:t,children:n,panelId:r,idBase:i}){let a=(0,W.useId)(),o=i??a,s=`${o}-view-panel`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ek,{role:`tablist`,"aria-label":`Workspace view`,value:[e],onValueChange:e=>{let n=e[0];(n===`visual`||n===`source`)&&t(n)},className:`border-border bg-background flex h-10 shrink-0 items-center gap-1 border-b px-3`,children:[`visual`,`source`].map(t=>(0,Z.jsx)(qO,{id:_F(o,t),type:`button`,role:`tab`,"aria-selected":e===t,"aria-controls":r??s,"aria-pressed":void 0,value:t,"data-testid":`workspace.tab.${t}`,className:vF,children:t},t))}),r===void 0&&(0,Z.jsx)(`div`,{role:`tabpanel`,id:s,"aria-labelledby":_F(o,e),className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:n})]})}function bF({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-foreground font-medium`,children:e}),t]})}function xF({summary:e}){return(0,Z.jsxs)(`div`,{className:`border-border bg-surface-inset rounded-lg border border-dashed px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-foreground truncate font-mono text-[11.5px]`,children:e}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-0.5 text-[11px]`,children:`Locked structure. Preserved as is. Edit it in Source.`})]})}function SF({summary:e}){return(0,Z.jsx)(`span`,{title:`Locked expression. Edit it in Source.`,"data-testid":`channel-workspace.locked-chip`,className:`border-border bg-surface-inset text-muted-foreground inline-flex max-w-full shrink-0 truncate rounded-md border border-dashed px-1.5 py-0.5 font-mono text-[11.5px]`,children:e})}function CF({diagnostics:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{className:`grid gap-2`,children:e.map((e,t)=>(0,Z.jsx)(`li`,{className:`border-status-error/30 bg-status-error/5 text-status-error rounded-lg border px-3 py-2 text-[12px]`,children:e.message},`${e.code}-${t}`))})}function wF({variables:e}){return e.length===0?null:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,Z.jsx)(`span`,{className:`border-border-subtle bg-surface-inset rounded-full border px-2 py-0.5 font-mono text-[11px]`,children:e},e))})}function TF({text:e,className:t}){let n=b_(e);return(0,Z.jsxs)(`p`,{"data-testid":`sms-counter`,className:XP(`text-muted-foreground`,t),children:[n.encoding.toUpperCase(),` · `,n.characterCount,` character`,n.characterCount===1?``:`s`,` · `,n.segmentCount,` segment`,n.segmentCount===1?``:`s`]})}function EF({reason:e}){return e===null?null:(0,Z.jsx)(`p`,{role:`alert`,"data-testid":`channel-workspace.edit-refusal`,className:`border-status-error/30 bg-status-error/5 text-status-error rounded-lg border px-3 py-2 text-[12px]`,children:e})}var DF=`none`;function OF({segments:e,editable:t,onChange:n}){let r=(0,W.useRef)(!1);return(0,Z.jsx)(`div`,{className:`bg-muted text-foreground rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:e.map((e,i)=>e.kind===`locked`?(0,Z.jsx)(`span`,{contentEditable:!1,title:`Locked structure — edit in Source`,"data-testid":`sms-workspace.locked-segment`,className:`border-border bg-surface-inset text-muted-foreground mx-0.5 inline-flex rounded-md border border-dashed px-1.5 py-0.5 font-mono text-[11.5px]`,children:e.summary},`locked-${i}`):(0,Z.jsx)(`span`,{role:`textbox`,"aria-label":`SMS message preview segment ${i+1}`,"data-testid":`sms-workspace.preview-segment.${i+1}`,"aria-multiline":`true`,contentEditable:t?`plaintext-only`:!1,suppressContentEditableWarning:!0,onCompositionStart:()=>{r.current=!0},onCompositionEnd:e=>{r.current=!1,n(i,e.currentTarget.textContent??``)},onInput:e=>{r.current||n(i,e.currentTarget.textContent??``)},className:`focus:bg-background focus-visible:ring-ring/50 rounded-sm outline-none focus-visible:ring-[3px]`,children:e.text},`text-${i}`))})}function kF({form:e,editable:t,onEdit:n}){let r=pF(),i=e.category.kind===`literal`?e.category.value:void 0;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(bF,{label:`Category`,children:(0,Z.jsxs)(cD,{value:i??DF,disabled:!t||e.category.kind===`expression`,onValueChange:e=>n({kind:`category`,value:po.find(t=>t.value===e)?.value}),children:[(0,Z.jsx)(CD,{"data-testid":`sms-workspace.category`,className:eF,children:(0,Z.jsx)(TD,{})}),(0,Z.jsx)(ED,{container:r,children:(0,Z.jsx)(tO,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsxs)(SO,{className:`samva-editor-shell border-border bg-surface-elevated min-w-[var(--anchor-width)] rounded-lg border p-1 shadow-[var(--shadow-lg)]`,children:[(0,Z.jsx)(NO,{value:DF,"data-testid":`sms-workspace.category-option.none`,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(PO,{children:`Not set`})}),po.map(e=>(0,Z.jsx)(NO,{value:e.value,"data-testid":`sms-workspace.category-option.${e.value}`,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(PO,{children:e.label})},e.value))]})})})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Message body`}),e.segments.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(xF,{summary:e.summary},`locked-${r}`):(0,Z.jsx)(`textarea`,{"aria-label":`Message body segment ${r+1}`,"data-testid":`sms-workspace.body-segment.${r+1}`,value:e.text,disabled:!t,onChange:e=>n({kind:`text`,segment:r,text:e.target.value},`sms-${r}`),rows:5,className:`${eF} resize-y py-2`},`text-${r}`))]}),(0,Z.jsx)(wF,{variables:e.variables})]})}function AF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=gF(o_),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>a_(o),[o]),c=e?.channel===`sms`?e.render:null;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(yF,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(hF,{}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(`aside`,{className:`samva-editor-scroll border-border bg-background w-[380px] shrink-0 overflow-y-auto border-r p-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(CF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(EF,{reason:n}),s===null?(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[12.5px]`,children:[`The SMS body is not a `,(0,Z.jsx)(`code`,{children:`<Sms>`}),` written in place, so it is edited in Source.`]}):(0,Z.jsx)(kF,{form:s,editable:t,onEdit:a})]})}),(0,Z.jsx)(`main`,{className:`samva-editor-workspace samva-editor-scroll min-w-0 flex-1 overflow-auto p-8`,children:(0,Z.jsxs)(`div`,{className:`border-border bg-background mx-auto max-w-[420px] rounded-[28px] border p-5 shadow-[var(--shadow-lg)]`,children:[(0,Z.jsx)(`div`,{"data-testid":`sms-workspace.preview-heading`,className:`border-border-subtle text-muted-foreground mb-5 border-b pb-3 text-center text-[12px] font-medium`,children:`SMS preview`}),s===null?(0,Z.jsx)(`div`,{className:`bg-muted text-muted-foreground rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:c?.text||`Message preview`}):(0,Z.jsx)(OF,{segments:s.segments,editable:t,onChange:(e,t)=>a({kind:`text`,segment:e,text:t},`sms-${e}`)}),c!==null&&(0,Z.jsx)(TF,{text:c.text,className:`mt-4 text-center text-[11.5px]`})]})}),(0,Z.jsx)(dF,{})]})})})}var jF=[{kind:`text`,text:``,start:0,end:0}],MF=e=>e.kind===`literal`?e.value:e.kind===`expression`?e.source:``;function NF({value:e,options:t,disabled:n,ariaLabel:r,onChange:i}){let a=pF();return(0,Z.jsxs)(cD,{value:e,disabled:n,onValueChange:e=>{let n=t.find(t=>t.value===e);n!==void 0&&i(n.value)},children:[(0,Z.jsx)(CD,{"aria-label":r,className:eF,children:(0,Z.jsx)(TD,{})}),(0,Z.jsx)(ED,{container:a,children:(0,Z.jsx)(tO,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsx)(SO,{className:`samva-editor-shell border-border bg-surface-elevated min-w-[var(--anchor-width)] rounded-lg border p-1 shadow-[var(--shadow-lg)]`,children:t.map(e=>(0,Z.jsx)(NO,{value:e.value,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(PO,{children:e.label})},e.value))})})})]})}function PF({label:e,part:t,segments:n,editable:r,onEdit:i}){let a=n??jF,o=`whatsapp-workspace.slot.${e.toLowerCase()}`;return(0,Z.jsxs)(`div`,{className:`grid gap-1.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-foreground font-medium`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:a.map((n,a)=>n.kind===`locked`?(0,Z.jsx)(SF,{summary:n.summary},`locked-${a}`):(0,Z.jsx)(`input`,{"aria-label":a===0?e:`${e} ${a+1}`,value:n.text,disabled:!r,"data-testid":a===0?o:`${o}.${a+1}`,onChange:e=>i({kind:`text`,part:t,segment:a,text:e.target.value},`whatsapp-${t}-${a}`),className:`${eF} min-w-[8ch] flex-1`},`text-${a}`))})]})}function FF({ariaLabel:e,state:t,editable:n,onChange:r,testId:i}){return(0,Z.jsx)(`input`,{"aria-label":e,"data-testid":i,value:MF(t),disabled:!n||t.kind===`expression`,title:t.kind===`expression`?`Read from the input. Edit it in Source.`:void 0,onChange:e=>r(e.target.value),className:eF})}function IF({buttons:e,editable:t,onEdit:n}){let[r,i]=(0,W.useState)(`quick-reply`);return(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Buttons`}),e.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(xF,{summary:e.summary},`locked-${r}`):(0,Z.jsxs)(`div`,{className:`border-border grid gap-2 rounded-lg border p-3`,children:[(0,Z.jsx)(NF,{value:e.type,options:go,disabled:!t,ariaLabel:`Button ${r+1} type`,onChange:e=>n({kind:`buttonType`,button:r,type:e})}),(0,Z.jsx)(`input`,{"aria-label":`Button ${r+1} label`,value:e.text,disabled:!t,onChange:e=>n({kind:`buttonText`,button:r,text:e.target.value},`whatsapp-button-${r}-text`),className:eF}),e.type===`url`&&(0,Z.jsx)(FF,{ariaLabel:`Button ${r+1} URL`,state:e.url,editable:t,onChange:e=>n({kind:`buttonAttribute`,button:r,name:`url`,value:e},`whatsapp-button-${r}-url`)}),e.type===`phone`&&(0,Z.jsx)(FF,{ariaLabel:`Button ${r+1} phone`,state:e.phone,editable:t,onChange:e=>n({kind:`buttonAttribute`,button:r,name:`phone`,value:e},`whatsapp-button-${r}-phone`)}),t&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Remove button ${r+1}`,onClick:()=>n({kind:`buttonRemove`,button:r}),className:`text-muted-foreground hover:text-status-error justify-self-end text-[11.5px]`,children:`Remove`})]},`button-${r}`)),t&&(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(NF,{value:r,options:go,disabled:!1,ariaLabel:`New button type`,onChange:i}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`whatsapp-workspace.add-button`,onClick:()=>n({kind:`buttonAdd`,type:r}),className:`border-border hover:bg-muted shrink-0 rounded-lg border px-3 text-[12px]`,children:`Add`})]})]})}function LF({form:e,editable:t,onEdit:n}){let r=MF(e.category),i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(bF,{label:`Language`,children:(0,Z.jsx)(FF,{ariaLabel:`Language`,state:e.language,editable:t,onChange:e=>n({kind:`attribute`,name:`language`,value:e},`whatsapp-language`)})}),(0,Z.jsx)(bF,{label:`Category`,children:(0,Z.jsx)(NF,{value:r,options:mo,disabled:!t||e.category.kind!==`literal`,onChange:e=>n({kind:`attribute`,name:`category`,value:e})})}),(0,Z.jsx)(bF,{label:`Header type`,children:(0,Z.jsx)(NF,{value:i,options:ho,disabled:!t||e.header===null||e.headerType.kind===`expression`,onChange:e=>n({kind:`headerType`,value:e})})}),(0,Z.jsx)(PF,{label:`Header`,part:`header`,segments:e.header,editable:t,onEdit:n}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Body`}),e.body.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(xF,{summary:e.summary},`body-locked-${r}`):(0,Z.jsx)(`textarea`,{"aria-label":`Body segment ${r+1}`,"data-testid":`whatsapp-workspace.body.${r+1}`,value:e.text,disabled:!t,onChange:e=>n({kind:`text`,part:`body`,segment:r,text:e.target.value},`whatsapp-body-${r}`),rows:4,className:`${eF} resize-y py-2`},`body-text-${r}`))]}),(0,Z.jsx)(PF,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,onEdit:n}),(0,Z.jsx)(IF,{buttons:e.buttons,editable:t,onEdit:n}),(0,Z.jsx)(wF,{variables:e.variables})]})}function RF({label:e,part:t,segments:n,editable:r,placeholder:i,className:a,onEdit:o}){return(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:(n??jF).map((n,s)=>n.kind===`locked`?(0,Z.jsx)(SF,{summary:n.summary},`locked-${s}`):(0,Z.jsx)(`input`,{"aria-label":s===0?`${e} preview`:`${e} preview ${s+1}`,"data-testid":s===0?`whatsapp-workspace.preview.${e.toLowerCase()}`:`whatsapp-workspace.preview.${e.toLowerCase()}.${s+1}`,value:n.text,readOnly:!r,placeholder:i,onChange:e=>o({kind:`text`,part:t,segment:s,text:e.target.value},`whatsapp-${t}-${s}`),className:`placeholder:text-muted-foreground/60 min-w-0 flex-1 bg-transparent outline-none ${a} ${r?`focus-visible:ring-ring/50 rounded-sm focus-visible:ring-2`:`cursor-default`}`},`text-${s}`))})}var zF=e=>e.type===`copy-code`?`Copy code`:e.text;function BF({form:e,editable:t,render:n,onEdit:r}){let i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`border-border mx-auto max-w-[420px] rounded-[28px] border bg-[#e9e2d8] p-5 shadow-[var(--shadow-lg)] dark:bg-[#0b141a]`,children:[(0,Z.jsx)(`div`,{"data-testid":`whatsapp-workspace.preview-heading`,className:`text-muted-foreground mb-4 text-center text-[12px] font-medium`,children:`WhatsApp business preview`}),(0,Z.jsxs)(`div`,{className:`bg-background rounded-xl px-3.5 py-3 shadow-[var(--shadow-sm)]`,children:[(0,Z.jsx)(RF,{label:`Header`,part:`header`,segments:e.header,editable:t&&i===`text`,placeholder:i===`text`?`Add header`:`${i} header`,className:`mb-1 font-semibold`,onEdit:r}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:e.body.map((e,n)=>e.kind===`locked`?(0,Z.jsx)(SF,{summary:e.summary},`body-locked-${n}`):(0,Z.jsx)(`textarea`,{"aria-label":`Body preview segment ${n+1}`,"data-testid":`whatsapp-workspace.body-preview.${n+1}`,value:e.text,readOnly:!t,placeholder:`Write your message`,rows:Math.max(1,e.text.split(`
29
+ `).length),onChange:e=>r({kind:`text`,part:`body`,segment:n,text:e.target.value},`whatsapp-body-${n}`),className:`placeholder:text-muted-foreground/60 min-h-5 w-full resize-none overflow-hidden bg-transparent text-[14px] whitespace-pre-wrap outline-none ${t?`focus-visible:ring-ring/50 rounded-sm focus-visible:ring-2`:`cursor-default`}`},`body-text-${n}`))}),(0,Z.jsx)(RF,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,placeholder:`Add footer`,className:`text-muted-foreground mt-2 text-[11.5px]`,onEdit:r}),(n?.buttons??[]).map((e,t)=>(0,Z.jsx)(`div`,{className:`border-border-subtle text-accent-email mt-2 border-t pt-2 text-center text-[12px]`,children:zF(e)},`${zF(e)}-${t}`))]}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-4 text-center text-[11.5px] capitalize`,children:[n?.category??(MF(e.category)||`utility`),` template`]})]})}function VF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=gF(g_),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>f_(o),[o]),c=e?.channel===`whatsapp`?e.render:null;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(yF,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(hF,{}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(`aside`,{className:`samva-editor-scroll border-border bg-background w-[400px] shrink-0 overflow-y-auto border-r p-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(CF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(EF,{reason:n}),s===null?(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[12.5px]`,children:[`The WhatsApp body is not a `,(0,Z.jsx)(`code`,{children:`<WhatsApp>`}),` written in place with a body, so it is edited in Source.`]}):(0,Z.jsx)(LF,{form:s,editable:t,onEdit:a})]})}),(0,Z.jsx)(`main`,{className:`samva-editor-workspace samva-editor-scroll min-w-0 flex-1 overflow-auto p-8`,children:s!==null&&(0,Z.jsx)(BF,{form:s,editable:t,render:c,onEdit:a})}),(0,Z.jsx)(dF,{})]})})})}var HF=e=>({top:e.top,left:e.left,width:e.width,height:e.height}),UF=(e,t)=>{let n=e.querySelectorAll(`[${Gc}="${CSS.escape(t)}"]`),r=null;for(let e of n){let t=HF(e.getBoundingClientRect());if(r??=t,t.width>0&&t.height>0)return t}return r},WF=`a[href],button,input[type="button"],input[type="submit"],input[type="image"]`,GF=e=>e!==null&&`closest`in e&&typeof e.closest==`function`,KF=e=>GF(e)&&e.closest(WF)!==null,qF=e=>GF(e)?e.closest(`[data-samva-instance]`)?.getAttribute(`data-samva-instance`)??null:null,JF=`html,body{margin:0;padding:0;overflow:hidden}`,YF={"--editor-canvas-hover":`#93c5fd`,"--editor-canvas-selected":`#2563eb`,"--editor-canvas-selected-fg":`#fff`,"--editor-canvas-generated":`#a855f7`},XF=e=>`:root{${Object.entries(YF).map(([t,n])=>`${t}:${e[t]?.trim()||n}`).join(`;`)}}`,ZF=e=>{let t=e.parentElement;if(t===null)return{};let n=document.createElement(`span`);n.hidden=!0,t.appendChild(n);let r=Object.fromEntries(Object.keys(YF).map(e=>(n.style.color=`var(${e})`,[e,getComputedStyle(n).color])));return n.remove(),r},QF=/@media\s*\(\s*prefers-color-scheme:\s*dark\s*\)/g,$F=(e,t)=>e.replace(QF,t===`dark`?`@media all`:`@media not all`),eI=e=>e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.button!==0,tI=e=>{let t=e.contentDocument;if(t===null)return null;let n=t.body.getBoundingClientRect(),r=Math.max(n.height,t.body.offsetHeight),i=Math.ceil(r>0?r:Math.max(t.body.scrollHeight,t.documentElement.scrollHeight));return e.style.height=`${i}px`,i},nI=({document_:e,mount:t,width:n,dark:r,overlay:i,onSelect:a,onHover:o,onContextMenu:s})=>{let c=(0,W.useRef)(null),[l,u]=(0,W.useState)(null),d=(0,W.useRef)({onSelect:a,onHover:o,onContextMenu:s});return(0,W.useLayoutEffect)(()=>{d.current={onSelect:a,onHover:o,onContextMenu:s}},[a,o,s]),(0,W.useLayoutEffect)(()=>{let n=c.current;if(n===null)return;let r=n.contentDocument;if(r===null)return;let i,a=null,o=()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,tI(n)}))},s=new ResizeObserver(o),l=new MutationObserver(o),f=()=>{let e=r.head.querySelector(`style[data-samva-editor-chrome]`);e===null&&(e=r.createElement(`style`),e.dataset.samvaEditorChrome=``,r.head.appendChild(e)),e.textContent=`${JF}${XF(ZF(n))}`},p=()=>{r.open(),r.write(e),r.close(),i=t?.(r),f(),u(r.body),s.disconnect(),s.observe(r.body),l.disconnect(),l.observe(r.body,{childList:!0,subtree:!0}),tI(n)},m=e=>{!eI(e)&&KF(e.target)&&e.preventDefault(),d.current.onSelect?.(qF(e.target))},h=e=>d.current.onHover?.(qF(e.target)),g=()=>d.current.onHover?.(null),_=e=>{let t=d.current.onContextMenu;if(t===void 0)return;e.preventDefault();let r=n.getBoundingClientRect(),i=n.clientWidth===0?1:r.width/n.clientWidth,a=n.clientHeight===0?1:r.height/n.clientHeight;t({instancePath:qF(e.target),clientX:r.left+e.clientX*i,clientY:r.top+e.clientY*a})},v=()=>{r.addEventListener(`click`,m),r.addEventListener(`mousemove`,h),r.addEventListener(`mouseleave`,g),r.addEventListener(`contextmenu`,_)},y=()=>{r.removeEventListener(`click`,m),r.removeEventListener(`mousemove`,h),r.removeEventListener(`mouseleave`,g),r.removeEventListener(`contextmenu`,_)};p(),v();let b=new MutationObserver(f);return b.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{y(),s.disconnect(),l.disconnect(),b.disconnect(),a!==null&&cancelAnimationFrame(a),i?.()}},[e,t]),(0,Z.jsx)(`iframe`,{ref:c,"data-testid":`canvas.frame`,title:`Email canvas`,sandbox:`allow-same-origin`,style:{width:n,height:0,display:`block`,border:`none`,background:r?`#0a0a0a`:`var(--editor-canvas-document-bg, #fff)`,colorScheme:r?`dark`:`light`},children:l!==null&&i!==void 0?(0,SS.createPortal)(i,l):null})},rI=({html:e,forceColorScheme:t,...n})=>{let r=(0,W.useContext)(mN),i=t===void 0?e:$F(e,t),a=(0,W.useMemo)(()=>r?.(i),[i,r]),[o,s]=(0,W.useState)({prepare:r,generation:0});o.prepare!==r&&s({prepare:r,generation:o.generation+1});let c=a?.html??i;return(0,Z.jsx)(nI,{document_:c,mount:a?.mount,dark:t===`dark`,...n},`${o.generation}:${t??``}:${e}`)},iI=(e,t,n)=>({position:`fixed`,top:e.top,left:e.left,width:e.width,height:e.height,outline:`${n}px solid ${t}`,outlineOffset:-n,pointerEvents:`none`,zIndex:2147483646}),aI=({renderRevision:e,selected:t,hovered:n})=>{let r=(0,W.useRef)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),c=t?.instancePath??null,l=n?.instancePath??null;return(0,W.useLayoutEffect)(()=>{let e=r.current?.ownerDocument;e!==void 0&&(a(c===null?null:UF(e,c)),s(l===null||l===c?null:UF(e,l)))},[e,c,l]),(0,Z.jsxs)(`div`,{ref:r,"data-samva-overlay":!0,style:{position:`fixed`,inset:0,pointerEvents:`none`},children:[o===null?null:(0,Z.jsx)(`div`,{style:iI(o,`var(--editor-canvas-hover)`,1)}),i!==null&&t!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:iI(i,t.authored?`var(--editor-canvas-selected)`:`var(--editor-canvas-generated)`,2)}),(0,Z.jsx)(`div`,{"data-samva-chip":!0,style:{position:`fixed`,top:Math.max(0,i.top-18),left:i.left,padding:`1px 6px`,borderRadius:4,background:t.authored?`var(--editor-canvas-selected)`:`var(--editor-canvas-generated)`,color:`var(--editor-canvas-selected-fg)`,font:`11px/1.4 ui-sans-serif, system-ui, sans-serif`,pointerEvents:`none`,zIndex:2147483647},children:t.authored?wN(t):`${wN(t)} · generated`})]}):null]})},oI=(e,t,n)=>{let r=new Map;for(let i of e.diagnostics??[])if(i.code===`caniemail/target-attribute`&&i.severity===`warning`)for(let e of i.occurrences??[i.origins]){let i=e[0];if(i===void 0)continue;let a=_g(t,n,i);if(a===null||a.tag!==`a`||a.hasSpread)continue;let o=a.properties.filter(e=>e.name===`target`),s=o[0];if(o.length!==1||s===void 0||s.kind!==`literal`||![`_self`,`_parent`,`_top`].includes(s.value))continue;let c=yg(t,s,`_blank`);c!==null&&r.set(c.start,c)}return[...r.values()].sort((e,t)=>e.start-t.start)};function sI({check:e}){let t=aF(`rail.assistant`)!==void 0,{doc:n,sourceEditable:r,pending:i,conflict:a,lifecycleBusy:o}=$(BO(e=>({doc:e.doc,sourceEditable:e.sourceEditable,pending:e.pendingAuthoredSource!==null,conflict:e.conflict,lifecycleBusy:e.lifecycleBusy}))),s=$(e=>e.actions.applySourceEdit),c=$(e=>e.actions.requestDiagnosticAssistance);if(n===null||!r)return null;let l=oI(e,n.origin.authoredSource,n.origin.file);if(l.length===0&&!t)return null;let u=e.diagnostics?.some(e=>Cs(e.code)),d=i||a||o;return(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[l.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:[`Set `,l.length,` local link target`,l.length===1?``:`s`,` to _blank to match these clients.`]}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`check.fix-target`,disabled:d,className:`border-border hover:bg-muted rounded border px-2 py-1 text-[11.5px] disabled:opacity-50`,onClick:()=>s({revision:n.rev,source:n.origin.authoredSource,edits:l}),children:`Use new-window links`})]}),t&&(0,Z.jsx)(`button`,{type:`button`,"data-testid":u?`check.upgrade-with-assistant`:`check.fix-with-assistant`,disabled:d,className:`border-border hover:bg-muted rounded border px-2 py-1 text-[11.5px] disabled:opacity-50`,onClick:()=>c(e),children:u?`Upgrade with Assistant`:`Fix with Assistant`})]})}var cI={risk:`Known risk`,unverified:`Needs verification`,degradation:`Expected differences`,"not-applicable":`Not affected`};function lI({check:e,actions:t}){return e.diagnostics===void 0?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-foreground text-[12.5px]`,children:e.label}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:e.detail})]}):(0,Z.jsxs)(`details`,{className:`min-w-0 flex-1`,"data-testid":`check.${e.id}`,children:[(0,Z.jsxs)(`summary`,{className:`text-foreground cursor-pointer text-[12.5px] break-words`,children:[e.label,(0,Z.jsx)(`span`,{className:`text-muted-foreground mt-0.5 block text-[11.5px]`,children:e.detail})]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-3 text-[11.5px] break-words`,children:[e.diagnostics.map((e,t)=>(0,Z.jsxs)(`div`,{className:`border-border-subtle border-l pl-2`,children:[e.compatibility!==void 0&&(0,Z.jsxs)(`p`,{className:`mb-1 font-medium`,children:[e.compatibility.title,` ·`,` `,cI[e.compatibility.assessment]]}),(0,Z.jsx)(`p`,{children:e.message}),e.clients!==void 0&&!e.clients.every(t=>e.message.includes(t))&&(0,Z.jsxs)(`p`,{className:`mt-1`,children:[`Clients: `,e.clients.join(`, `)]}),e.notes!==void 0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.notes}),(e.fixtures?.length??0)>0&&(0,Z.jsxs)(`p`,{className:`mt-1`,children:[`Fixtures: `,e.fixtures.join(`, `)]}),(e.occurrences??[e.origins]).map((e,t)=>e.length===0?null:(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 break-all`,children:e.map(CN).join(` → `)},t)),e.provenance!==void 0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.provenance})]},t)),(0,Z.jsx)(`p`,{className:`text-muted-foreground font-mono break-all`,children:e.diagnostics[0]?.code}),t]})]})}var uI=e=>e===void 0?`No default sender`:e.name?`${e.name} <${e.email}>`:e.email;function dI(){return(0,Z.jsx)(`span`,{title:`Overridable per send`,className:`border-border-subtle text-placeholder shrink-0 rounded-full border px-2 py-px text-[10px]`,children:`default`})}function fI({value:e,placeholder:t,testId:n}){return(0,Z.jsx)(`span`,{"data-testid":n,className:`text-foreground min-w-0 flex-1 truncate`,children:e.length>0?e:(0,Z.jsx)(`span`,{className:`text-placeholder`,children:t})})}function pI(){let{doc:e,render:t,selected:n,layoutMode:r}=$(BO(e=>({doc:e.doc,render:e.render,selected:e.selection.kind===`envelope`,layoutMode:e.layoutMode}))),{selectEnvelope:i}=$(e=>e.actions),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=(0,W.useRef)(!1),l=e?.metadata.fromDefault,u=e?.metadata.replyToDefault??[],d=t?.subject??``,f=t?.preheader??``,p=r===`compact`||r===`narrow`;return(0,W.useEffect)(()=>{p&&!a&&c.current&&(c.current=!1,s.current?.focus())},[p,a]),(0,Z.jsxs)(fk,{open:!p||a,onOpenChange:e=>{e||(c.current=!0),o(e)},children:[p&&!a&&(0,Z.jsxs)(mk,{ref:s,"aria-label":`Expand envelope`,"data-testid":`envelope.expand`,onClick:e=>{e.stopPropagation(),i()},className:XP(`mb-4 flex h-11 w-full items-center gap-3 rounded-xl border bg-background px-3 text-left shadow-[var(--shadow-xs)] transition-[border-color,box-shadow] hover:border-sel-mid`,n&&`border-accent-email shadow-[0_0_0_1px_var(--accent-email)]`),children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`Envelope`}),(0,Z.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-[12px]`,children:d===``?`No subject`:d}),(0,Z.jsx)(wP,{className:`text-muted-foreground size-4 shrink-0`})]}),(0,Z.jsx)(wk,{children:(0,Z.jsxs)(`div`,{onClick:e=>{e.stopPropagation(),i()},className:XP(`mb-6 cursor-pointer overflow-hidden rounded-2xl border transition-shadow`,n?`border-accent-email shadow-[0_0_0_1px_var(--accent-email)]`:`border-border/80 hover:border-sel-mid`),children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle bg-surface-inset/80 flex items-center justify-between border-b px-3 py-1.5`,children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Select envelope`,"data-testid":`envelope.select`,onClick:e=>{e.stopPropagation(),i()},className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded px-1 py-0.5 text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`Envelope`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder text-[10px]`,children:`defaults muted · subject & preview rendered`}),p&&(0,Z.jsx)(mk,{"aria-label":`Collapse envelope`,"data-testid":`envelope.collapse`,onClick:e=>{e.stopPropagation()},className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded p-1`,children:(0,Z.jsx)(DP,{className:`size-3.5`})})]})]}),(0,Z.jsxs)(`div`,{className:`border-border-subtle bg-surface-inset/40 border-b`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`From`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate`,children:uI(l)}),(0,Z.jsx)(dI,{})]}),(0,Z.jsxs)(`div`,{"data-testid":`envelope.reply-to-row`,className:`flex items-center gap-3 px-4 py-2 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Reply-To`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate`,children:u.length>0?u.join(`, `):`None`}),(0,Z.jsx)(dI,{})]})]}),(0,Z.jsxs)(`div`,{className:`bg-background`,children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex items-center gap-3 border-b px-4 py-2.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Subject`}),(0,Z.jsx)(fI,{value:d,placeholder:`No subject`,testId:`envelope.subject-value`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Preview`}),(0,Z.jsx)(fI,{value:f,placeholder:`No preview text`,testId:`envelope.preview-value`})]})]})]})})]})}var mI=XP(`samva-editor-context-item`,`grid min-h-8 grid-cols-[1fr_auto] items-center gap-5 rounded-md px-2.5 text-[12.5px] text-foreground outline-none`,`data-[highlighted]:bg-sel-soft data-[highlighted]:text-accent-email`);function hI({children:e,ancestors:t,onSelect:n,onOpenChange:r,portalContainer:i,open:a,anchor:o}){return(0,Z.jsxs)(Qk,{open:a,onOpenChange:r,children:[(0,Z.jsx)(eA,{render:e}),(0,Z.jsx)(Rk,{container:i,children:(0,Z.jsx)(tA,{anchor:o,sideOffset:2,children:(0,Z.jsxs)(Fk,{"aria-label":`Select element`,"data-testid":`node-context-menu.popup`,className:`samva-editor-context-popup samva-editor-shell border-border bg-surface-elevated z-50 min-w-52 rounded-lg border p-1 shadow-[var(--shadow-lg)] outline-none`,children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground px-2.5 py-1 text-[11px]`,children:`Select`}),t.map(e=>(0,Z.jsxs)(Pk,{className:mI,"data-testid":`node-context-menu.item.${e.instancePath}`,onClick:()=>n(e.instancePath),children:[(0,Z.jsx)(`span`,{children:e.label}),e.generated?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`generated`}):null]},e.instancePath))]})})})]})}function gI({name:e,className:t}){return(0,Z.jsx)(`span`,{className:XP(`inline-flex items-baseline rounded-md bg-accent-teal/20 px-1.5 py-px font-mono text-[0.82em] font-medium text-foreground ring-1 ring-inset ring-accent-teal/20`,t),children:`{{${e}}}`})}function _I({children:e}){return(0,Z.jsx)(`div`,{className:`text-muted-foreground mb-2 flex items-center justify-between text-[10.5px] font-semibold tracking-[0.06em] uppercase`,children:e})}function vI({children:e,className:t,title:n,help:r=n,pressed:i,onClick:a,disabled:o,testId:s}){let c=pF();return(0,Z.jsxs)(DT,{disabled:o,children:[(0,Z.jsx)(FT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":n,"aria-pressed":i,disabled:o,"data-testid":s,onClick:a,className:XP(`inline-flex h-7.5 items-center gap-1.5 rounded-[7px] px-2.5 text-muted-foreground outline-none transition-all hover:bg-muted hover:text-foreground active:translate-y-px disabled:opacity-40`,`aria-pressed:bg-[var(--editor-pressed-bg)] aria-pressed:shadow-[var(--editor-pressed-shadow)]`,`aria-pressed:text-accent-foreground`,ZP,t)}),children:e}),(0,Z.jsx)(zT,{container:c,children:(0,Z.jsx)(cE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(lE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:r})})})]})}function yI({ariaLabel:e,options:t,value:n,onChange:r,size:i=`md`,testId:a}){let o=pF();return(0,Z.jsx)(ek,{"aria-label":e,value:[n],"data-testid":a,onValueChange:e=>{let t=e[0];t!==void 0&&r(t)},className:XP(`bg-muted inline-flex gap-0.5 rounded-lg p-0.5`,i===`sm`&&`rounded-[7px]`),children:t.map(e=>{let t=(0,Z.jsx)(qO,{type:`button`,"aria-label":e.title,"data-testid":e.testId,value:e.value,className:XP($P,i===`sm`?`h-6 px-2 text-xs`:`h-7 px-2.5 text-xs`),children:e.label},e.value);return e.title===void 0?t:(0,Z.jsxs)(DT,{children:[(0,Z.jsx)(FT,{render:t}),(0,Z.jsx)(zT,{container:o,children:(0,Z.jsx)(cE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(lE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:e.title})})})]},e.value)})})}function bI({children:e,className:t,overridden:n,testId:r}){return(0,Z.jsxs)(`span`,{"data-testid":r,className:XP(`inline-flex h-7 max-w-[170px] items-center gap-1.5 overflow-hidden rounded-[7px] border border-border bg-background px-2.5 font-mono text-xs whitespace-nowrap text-foreground`,n&&`border-accent-email/40 bg-sel-soft ring-1 ring-accent-email/20`,t),title:n?`Overridden on mobile`:void 0,children:[e,n&&(0,Z.jsx)(`span`,{className:`text-accent-email ml-auto text-[9px] font-semibold tracking-wide uppercase`,children:`M`})]})}function xI({pointing:e=!1}){let{doc:t,render:n,outline:r,selection:i,previewDevice:a,canvasZoom:o}=$(BO(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,previewDevice:e.previewDevice,canvasZoom:e.canvasZoom}))),{select:s,selectDocument:c,setHovered:l,setPreviewDevice:u,setCanvasZoom:d}=$(e=>e.actions),f=$(e=>e.hoveredCandidatePath===null?null:e.outline?.index.get(e.hoveredCandidatePath)??null),p=pF(),m=oF(`canvas.overlay`),h=(0,W.useRef)(null),[g,_]=(0,W.useState)(1),[v,y]=(0,W.useState)([]),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(null),w=i.kind===`element`?r?.index.get(i.instancePath)??null:null,T=a===`mobile`?375:600;(0,W.useLayoutEffect)(()=>{let e=h.current;if(e===null||typeof ResizeObserver>`u`)return;let t=()=>{let t=Math.max(240,e.clientWidth-80);_(Math.min(1,Math.max(.5,t/T)))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[T]);let E=o===`fit`?g:1,D=(0,W.useCallback)(t=>{if(e||r===null||t.instancePath===null){x(!1);return}let n=[...kN(r,t.instancePath),t.instancePath].toReversed().flatMap(e=>{let t=r.index.get(e);return t===void 0?[]:[{instancePath:e,label:wN(t),generated:!t.authored}]});if(n.length===0){x(!1);return}s(t.instancePath),y(n);let{clientX:i,clientY:a}=t;C({getBoundingClientRect:()=>DOMRect.fromRect({x:i,y:a})}),queueMicrotask(()=>x(!0))},[r,e,s]),O=n===null?null:(0,Z.jsx)(rI,{html:n.html,width:T,onSelect:s,onHover:l,onContextMenu:e?void 0:D,overlay:(0,Z.jsx)(aI,{renderRevision:n.revision,selected:w,hovered:f})});return(0,Z.jsxs)(`div`,{className:`samva-editor-workspace relative flex min-w-0 flex-1 flex-col`,children:[m.length>0&&(0,Z.jsx)(`div`,{"data-samva-canvas-status":!0,className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:m.map(e=>(0,Z.jsx)(W.Fragment,{children:e.render()},e.id))}),(0,Z.jsx)(`div`,{ref:h,"data-samva-canvas-viewport":!0,className:`samva-editor-scroll relative flex-1 overflow-auto px-10 pt-10 pb-24 [overflow-anchor:none]`,onClick:c,children:t===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid h-full place-items-center text-[12.5px]`,children:`Loading document…`}):(0,Z.jsxs)(`div`,{className:`mx-auto`,"data-canvas-zoom":o,style:{width:T,zoom:E},onClick:e=>e.stopPropagation(),children:[t.channel===`email`&&t.preview.status===`stale`&&(0,Z.jsxs)(`div`,{"data-testid":`canvas.preview-stale`,className:`border-warning/35 bg-warning/10 text-foreground mb-3 rounded-[9px] border px-3 py-2 text-[12px] shadow-sm`,children:[`Showing the last preview that worked. Your latest edit has a problem:`,` `,t.preview.reason]}),(0,Z.jsx)(pI,{}),O===null?(0,Z.jsx)(SI,{}):e?O:(0,Z.jsx)(hI,{ancestors:v,onSelect:s,portalContainer:p,anchor:S??void 0,open:b,onOpenChange:e=>x(e&&v.length>0),children:O})]})}),t!==null&&(0,Z.jsxs)(`div`,{className:`border-border bg-background/95 absolute bottom-3 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1 rounded-[9px] border p-1 shadow-[var(--shadow-lg)] backdrop-blur-md`,children:[(0,Z.jsx)(yI,{ariaLabel:`Canvas preview width`,value:a,onChange:e=>u(e),size:`sm`,options:[{value:`desktop`,title:`Preview desktop width`,testId:`canvas.device.desktop`,label:(0,Z.jsx)(zP,{className:`size-[13px]`})},{value:`mobile`,title:`Preview mobile width`,testId:`canvas.device.mobile`,label:(0,Z.jsx)(RP,{className:`size-[13px]`})}]}),(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`canvas.zoom`,title:o===`fit`?`Show canvas at 100%`:`Fit canvas to workspace`,"aria-label":o===`fit`?`Show canvas at 100%`:`Fit canvas to workspace`,onClick:()=>d(o===`fit`?`100`:`fit`),className:XP(`text-muted-foreground hover:bg-muted hover:text-foreground inline-flex h-7 items-center gap-1.5 rounded-[6px] px-2 text-[11.5px] transition-colors`,o===`fit`&&`bg-sel-soft text-accent-email`),children:[(0,Z.jsx)(xP,{className:`size-[14px]`}),o===`fit`?`Fit`:`100%`]})]})]})}function SI(){let e=$(BO(e=>e.checks.filter(e=>e.severity===`error`))),t=e.length>0;return(0,Z.jsxs)(`div`,{"data-testid":`canvas.unbuilt`,"data-unbuilt-reason":t?`failed`:`not-built`,className:`border-border bg-surface-inset text-foreground rounded-xl border border-dashed p-6 text-[12.5px]`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:t?`No preview`:`No preview yet`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:t?`The current draft broke the preview. Fix the source and it will come back.`:`Nothing has run this entry yet. The next pass puts the preview here.`}),t&&(0,Z.jsx)(`ul`,{className:`mt-4 space-y-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(lI,{check:e,actions:(0,Z.jsx)(sI,{check:e})})},e.id))})]})}function CI({checks:e,editable:t=!1}){let{actionable:n}=XN(e),r=e.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)).length;return(0,Z.jsxs)(`section`,{className:`space-y-3`,"aria-label":`Needs attention`,children:[(0,Z.jsxs)(`h3`,{className:`text-foreground text-[13px] font-semibold`,children:[`Needs attention`,n.length>0?` · ${n.length}`:``]}),n.length===0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.length===0?`No checks yet.`:`No known risks found.`}):n.map(e=>(0,Z.jsx)(lI,{check:e,actions:t?(0,Z.jsx)(sI,{check:e}):void 0},e.id)),(0,Z.jsx)(wI,{checks:e,editable:t}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:r>0?`${r} finding group${r===1?` needs`:`s need`} client verification.`:`These checks do not confirm rendering in every inbox.`})]})}function wI({checks:e,editable:t=!1}){let n=pF(),r=Object.fromEntries(Object.keys(cI).map(t=>[t,e.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===t)).length])),[i,a]=(0,W.useState)(`all`),[o,s]=(0,W.useState)(`all`),c=[...new Set(e.flatMap(e=>e.diagnostics?.flatMap(e=>e.clients??[])??[]))].sort(),l=e.flatMap(e=>{if(e.diagnostics===void 0)return i===`all`&&o===`all`?[e]:[];let t=e.diagnostics.filter(e=>(i===`all`||e.compatibility?.assessment===i)&&(o===`all`||e.clients?.includes(o)));return t.length===0?[]:[KN(e.id,t)]}),u=e=>e.severity===`error`||e.severity===`warn`?0:e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)?1:e.diagnostics?.some(e=>e.compatibility?.assessment===`degradation`)?2:3;return l.sort((e,t)=>u(e)-u(t)),(0,Z.jsxs)(ij,{onOpenChange:e=>{e&&(a(r.unverified>0?`unverified`:`all`),s(`all`))},children:[(0,Z.jsx)(sj,{"data-testid":`checks.compatibility-report`,className:`border-border text-foreground hover:bg-muted rounded-md border px-2.5 py-1.5 text-xs`,children:`Compatibility report`}),(0,Z.jsxs)(ZA,{container:n,children:[(0,Z.jsx)(HA,{className:`fixed inset-0 z-[130] bg-black/30`}),(0,Z.jsxs)(XA,{"data-testid":`checks.report`,className:`samva-editor-shell border-border bg-surface-elevated text-foreground fixed top-1/2 left-1/2 z-[131] flex max-h-[85dvh] w-[min(840px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border p-5 shadow-xl`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(oj,{className:`text-lg font-semibold`,children:`Compatibility report`}),(0,Z.jsx)(UA,{"data-testid":`checks.report.close`,"aria-label":`Close compatibility report`,className:`hover:bg-muted rounded border px-2 py-1 text-xs`,children:`Close`})]}),(0,Z.jsx)(WA,{className:`text-muted-foreground mt-2 text-sm`,children:`Client verification remains. Review known risks, unverified behavior and fallbacks before testing in your recipients’ inboxes.`}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:[Object.entries(cI).map(([e,t])=>`${r[e]} ${t.toLowerCase()}`).join(` · `),`. Groups can appear in more than one category.`]}),(0,Z.jsxs)(`div`,{className:`my-4 flex flex-wrap gap-3 text-xs`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[`Assessment`,(0,Z.jsxs)(`select`,{"data-testid":`checks.report.assessment`,"aria-label":`Assessment`,value:i,onChange:e=>a(e.target.value),className:`border-border bg-background rounded border p-2`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All assessments`}),Object.entries(cI).map(([e,t])=>(0,Z.jsxs)(`option`,{value:e,children:[t,` (`,r[e],`)`]},e))]})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[`Client`,(0,Z.jsxs)(`select`,{"data-testid":`checks.report.client`,"aria-label":`Client`,value:o,onChange:e=>s(e.target.value),className:`border-border bg-background rounded border p-2`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All clients`}),c.map(e=>(0,Z.jsx)(`option`,{children:e},e))]})]})]}),(0,Z.jsx)(`div`,{className:`samva-editor-scroll min-h-0 space-y-4 overflow-y-auto`,children:l.length===0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No evidence matches these filters.`}):l.map(e=>(0,Z.jsx)(`div`,{className:`border-border-subtle border-t pt-3`,children:(0,Z.jsx)(lI,{check:e,actions:t?(0,Z.jsx)(sI,{check:e}):void 0})},e.id))})]})]})]})}var TI=XP(`border-border bg-background text-foreground w-full rounded border px-2 py-1.5 text-xs`,ZP),EI=XP(`border-border hover:bg-muted rounded border px-2 py-1 text-xs disabled:opacity-50`,ZP);function DI({field:e,source:t,propose:n,apply:r}){let[i,a]=(0,W.useState)(e.value),[o,s]=(0,W.useState)(e.kind===`literal`&&e.literalType===`string`?JSON.stringify(e.value):e.value);return(0,Z.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[OI(e.name),` · `,e.kind,e.kind===`literal`?(0,Z.jsx)(`input`,{"aria-label":`${e.name} literal`,"data-testid":`source.property.${e.name}.literal`,type:e.literalType===`number`?`number`:`text`,className:TI,value:i,onChange:e=>a(e.target.value)}):(0,Z.jsx)(`code`,{className:`bg-muted mt-1 block rounded p-2 break-all`,children:e.value})]}),e.kind===`literal`&&(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.apply`,type:`button`,className:EI,disabled:yg(t,e,i)===null,onClick:()=>{let n=yg(t,e,i);n!==null&&r(n)},children:`Apply literal`}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{"data-testid":`source.property.${e.name}.expression-toggle`,className:`cursor-pointer text-xs`,children:e.kind===`literal`?`Change to a binding or expression`:`Review a binding or expression change`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground my-1 text-xs`,children:`This changes template logic. Fixture values are edited separately.`}),(0,Z.jsx)(`textarea`,{"aria-label":`${e.name} expression`,"data-testid":`source.property.${e.name}.expression`,className:TI,value:o,onChange:e=>s(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.review`,type:`button`,className:EI,onClick:()=>n(bg(t,e,o)),children:`Review expression diff`})]})]})}var OI=e=>e===`children`||e.startsWith(`text.`)?`Text`:e===`className`?`Style classes`:e,kI=e=>e instanceof Error&&e.message!==``?e.message:`The host could not save this.`;function AI(e){let t=$(e=>e.lifecycleCapability),{flushSaves:n}=$(e=>e.actions),[r,i]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(e===null||t?.status!==`ready`)return;let r=!1;return n().then(()=>t.api.inspect()).then(e=>{if(r)return;let t={};for(let n of e.files)n.binary!==!0&&n.status!==`deleted`&&n.content!==null&&(t[n.path]=n.content);i(t)}).catch(()=>{r||i(`failed`)}),()=>{r=!0}},[e,t,n]),e===null?{status:`entry`}:t?.status===`ready`?r===null?{status:`loading`}:r===`failed`?{status:`unavailable`}:{status:`ready`,files:r,api:t.api}:{status:`unavailable`}}function jI(e){return e.busy?`Waiting for the latest source to render.`:e.file!==null&&e.project===`loading`?`Reading ${e.file}.`:e.file!==null&&e.project===`unavailable`?`This element is written in ${e.file}, outside the template entry, and this host cannot edit project files from here. Open Source or ask the agent.`:e.resolved?`This source is read-only.`:`This origin cannot be resolved in its file. Open its source or ask the agent.`}function MI(e,t){return`${e.occurrences>1?`This element renders ${e.occurrences} times here (a loop or a repeated component), so one edit changes all ${e.occurrences}.`:`This changes this element.`}${t?` It is written in a partial, so every template that uses the partial changes too.`:``} Fixture items remain separate data.`}function NI({selection:e}){let{doc:t,pending:n,revision:r,editable:i,storeError:a,lifecycleBusy:o}=$(BO(e=>({doc:e.doc,pending:e.pendingAuthoredSource,revision:e.render?.revision,editable:e.sourceEditable,storeError:e.sourceEditError,lifecycleBusy:e.lifecycleBusy}))),{applySourceEdit:s,openSource:c,requestSourceAssistance:l,beginLifecycle:u,endLifecycle:d}=$(e=>e.actions),{flushSaves:f}=$(e=>e.actions),p=aF(`rail.assistant`)!==void 0,[m,h]=(0,W.useState)(0),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(``),[w,T]=(0,W.useState)(`<p>New content</p>`),[E,D]=(0,W.useState)(``),[O,k]=(0,W.useState)(null),[A,j]=(0,W.useState)(null),M=e.origins[m],N=t?.origin.file,P=M!==void 0&&M.fileName!==N,F=AI(P?M.fileName:null);if(t===null||N===void 0)return null;let I=t.origin.authoredSource,L=P&&M!==void 0?F.status===`ready`?F.files[M.fileName]??null:null:I,R=M===void 0||L===null?null:_g(L,M.fileName,M),ee=P?{entry:N,file:M.fileName,files:{...F.status===`ready`?F.files:{},[N]:I}}:{entry:N},z=i&&n===null&&!o&&!b&&r===t.rev&&R!==null&&L!==null,te=e=>{let t=Sg(L??``,e,{profile:ee});return{edits:e,refusal:t.ok?null:t.reason}},ne=e=>{if(L===null)return;if(y(null),_(null),!P){s({revision:r??``,source:L,edits:e});return}let t=Sg(L,e,{profile:ee});if(!t.ok){y(t.reason);return}F.status===`ready`&&u()&&(x(!0),f().then(e=>F.api.updateFile({path:M.fileName,baseRev:e,content:t.source})).catch(e=>y(kI(e))).finally(()=>{d(),x(!1)}))},re=e=>{ne([e]),j(null)},B=v??a,ie=R?.properties.find(e=>e.name===`className`),ae=R===null||L===null||ie?.kind===`literal`?null:(()=>{let e=kg(L,R,{kind:`add`,tokens:`x`});return e.ok?null:e.reason})(),oe=e.origins.length>1;return(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(_I,{children:`Source properties`}),oe&&(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[`Edit scope`,(0,Z.jsx)(`select`,{"aria-label":`Edit scope`,"data-testid":`source.scope`,className:TI,value:m,onChange:e=>{h(Number(e.target.value)),j(null)},children:e.origins.map((e,t)=>(0,Z.jsxs)(`option`,{value:t,children:[t===0?`Element`:`Call site ${t}`,` · `,CN(e)]},t))})]}),(0,Z.jsx)(`p`,{"data-testid":`source.scope-note`,className:`text-muted-foreground mt-2 text-xs`,children:oe&&m>0?`Changes this call site, including every loop iteration it produces. Fixture items remain separate data.`:MI(e,P)}),P&&(0,Z.jsxs)(`p`,{"data-testid":`source.partial-warning`,className:`border-border bg-muted mt-2 rounded border p-2 text-xs`,children:[`Edits apply to every template that uses this partial (`,M.fileName,`).`]}),z?(0,Z.jsxs)(Z.Fragment,{children:[R.properties.length===0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:`No unambiguous scalar properties here. Use source or the agent for this shape.`}),R.hasSpread&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:`Spread properties can override attributes here. Edit attributes in Source or ask the agent.`}),R.properties.filter(e=>!R.hasSpread||e.syntax===`child`).map(e=>(0,Z.jsx)(DI,{field:e,source:L,apply:re,propose:e=>j(te([e]))},`${t.rev}:${L}:${m}:${e.name}`)),ae!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.class-refusal`,className:`text-muted-foreground mt-3 text-xs`,children:ae}),ae===null&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[ie===void 0?`Style classes · literal`:`Add style classes`,(0,Z.jsx)(`input`,{"aria-label":`Style classes`,"data-testid":`source.classes`,className:TI,value:S,onChange:e=>C(e.target.value)})]}),(0,Z.jsx)(`button`,{"data-testid":`source.classes-add`,type:`button`,className:EI,disabled:S.trim()===``,onClick:()=>{let e=kg(L,R,{kind:`add`,tokens:S});e.ok?ne(e.edits):y(e.reason),C(``)},children:ie===void 0?`Apply styles`:`Add classes`})]}),(0,Z.jsxs)(`details`,{className:`mt-3`,children:[(0,Z.jsx)(`summary`,{"data-testid":`source.structure-toggle`,className:`cursor-pointer text-xs`,children:`Structure · authored block`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground my-2 text-xs`,children:`This changes the whole source block at the scope above. A rendered loop instance has no independent source block. Change fixture items separately; edit loop or conditional logic in Source.`}),(0,Z.jsx)(`textarea`,{"aria-label":`Insert TSX`,"data-testid":`source.insert`,value:w,className:TI,onChange:e=>T(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.review-insert`,type:`button`,className:EI,disabled:R.contentEnd===null,onClick:()=>{let e=Tg(L,R,{kind:`insert`,tsx:w});k(e===null?null:te(e))},children:`Review insert`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-delete`,type:`button`,className:EI,disabled:!R.structural,onClick:()=>{let e=Tg(L,R,{kind:`delete`});k(e===null?null:te(e))},children:`Review delete`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-duplicate`,type:`button`,className:EI,disabled:!R.structural,onClick:()=>{let e=Tg(L,R,{kind:`duplicate`});k(e===null?null:te(e))},children:`Review duplicate`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-move-up`,type:`button`,className:EI,disabled:R.previous===null,onClick:()=>{let e=Tg(L,R,{kind:`reorder`,direction:`before`});k(e===null?null:te(e))},children:`Move earlier`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-move-down`,type:`button`,className:EI,disabled:R.next===null,onClick:()=>{let e=Tg(L,R,{kind:`reorder`,direction:`after`});k(e===null?null:te(e))},children:`Move later`}),!P&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`mt-2 block text-xs`,children:[`Move into shared source container`,(0,Z.jsxs)(`select`,{"aria-label":`Move destination`,"data-testid":`source.destination`,value:E,className:TI,onChange:e=>D(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose destination`}),t.channel===`email`&&t.render?.selections.map(e=>(0,Z.jsxs)(`option`,{value:e.instancePath,children:[e.tag,` · `,e.instancePath,` ·`,` `,e.origins[0]===void 0?`generated`:CN(e.origins[0])]},e.instancePath))]})]}),(0,Z.jsx)(`button`,{"data-testid":`source.review-move`,type:`button`,className:EI,disabled:!R.structural||E===``,onClick:()=>{let e=(t.channel===`email`?t.render?.selections.find(e=>e.instancePath===E):void 0)?.origins[0],n=e===void 0?null:_g(L,N,e),r=n===null?null:Tg(L,R,{kind:`move`,destination:n});k(r===null?null:te(r)),_(r===null?`This destination cannot accept the selected block. Choose another source container or use Source.`:null)},children:`Review move`})]}),g!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error text-xs`,children:g}),O!==null&&(0,Z.jsxs)(`div`,{role:`region`,"aria-label":`Structural source diff`,className:`mt-2`,children:[(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:O.edits.map(e=>`- ${e.before}\n+ ${e.after}`).join(`
30
+ `)}),O.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.structure-refusal`,className:`text-status-error text-xs`,children:O.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-structure`,type:`button`,className:EI,disabled:O.refusal!==null,onClick:()=>{ne(O.edits),k(null)},children:`Apply structural change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:EI,onClick:()=>k(null),children:`Cancel`})]})]}),A!==null&&(0,Z.jsxs)(`div`,{role:`region`,"aria-label":`Proposed source diff`,className:`mt-3 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs`,children:`Review the exact source change`}),(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:A.edits.map(e=>`- ${e.before}\n+ ${e.after}`).join(`
31
+ `)}),A.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.proposal-refusal`,className:`text-status-error text-xs`,children:A.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-reviewed`,type:`button`,className:EI,disabled:A.refusal!==null,onClick:()=>{ne(A.edits),j(null)},children:`Apply reviewed change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:EI,onClick:()=>j(null),children:`Cancel`})]})]}):(0,Z.jsx)(`p`,{"data-testid":`source.unavailable`,className:`text-muted-foreground mt-2 text-xs`,children:jI({busy:n!==null||b||o,file:P?M.fileName:null,project:F.status,resolved:R!==null})}),B!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.edit-error`,className:`text-status-error mt-2 text-xs`,children:B}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:EI,onClick:c,children:`Open source`}),p&&(0,Z.jsx)(`button`,{type:`button`,className:EI,onClick:()=>l(m),children:`Ask agent`})]})]})}function PI(){let{undo:e,redo:t,error:n,editable:r}=$(BO(e=>({undo:e.undoHistory.length,redo:e.redoHistory.length,error:e.sourceEditError,editable:e.sourceEditable}))),i=$(e=>e.actions);return(0,Z.jsxs)(`div`,{className:`border-border border-b px-3 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`button`,{"data-testid":`source.undo`,type:`button`,className:EI,disabled:!r||e===0,onClick:i.undo,children:`Undo`}),(0,Z.jsx)(`button`,{"data-testid":`source.redo`,type:`button`,className:EI,disabled:!r||t===0,onClick:i.redo,children:`Redo`})]}),n!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error mt-1 text-xs`,children:n})]})}function FI(){let e=$(e=>e.doc),t=$(e=>e.pendingAuthoredSource),n=$(e=>e.sourceEditable),{applySourceEdit:r,openSource:i}=$(e=>e.actions),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(!1);if(e?.channel!==`email`)return null;let l=Dg(e.origin.authoredSource).find(t=>t.name===e.fixture);return(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsxs)(_I,{children:[`Fixture data · `,e.fixture]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Example input for this fixture. Changes do not replace template bindings or change other fixtures.`}),l===void 0?(0,Z.jsx)(`button`,{type:`button`,className:EI,onClick:i,children:`Open fixture source`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`textarea`,{"aria-label":`Fixture data source`,"data-testid":`source.fixture-data`,className:TI,value:a??l.source,onChange:e=>{o(e.target.value),c(!1)},disabled:!n||t!==null}),(0,Z.jsx)(`button`,{"data-testid":`source.fixture-review`,type:`button`,className:EI,disabled:!n||t!==null||a===null,onClick:()=>c(!0),children:`Review fixture change`}),s&&a!==null&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:`- ${l.source}\n+ ${a}`}),(0,Z.jsx)(`button`,{"data-testid":`source.fixture-apply`,type:`button`,className:EI,onClick:()=>{r({revision:e.rev,source:e.origin.authoredSource,edits:[{start:l.start,end:l.end,before:l.source,after:a}]}),o(null),c(!1)},children:`Apply fixture change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:EI,onClick:()=>{o(null),c(!1)},children:`Cancel`})]})]})]})}function II({selection:e}){let t=$(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(NI,{selection:e},t)}function LI(){let e=$(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(FI,{},e)}var RI=[],zI=[],BI=[];function VI({label:e,title:t,children:n}){return(0,Z.jsxs)(`div`,{title:t,className:`mt-1.5 flex items-center justify-between gap-2 first:mt-0`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e}),n]})}function HI(){let e=$(e=>e.doc?.variables??zI);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(_I,{children:`Variables`}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[12.5px]`,children:[(0,Z.jsx)(gI,{name:e.name,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`text-placeholder ml-auto text-[11px]`,children:e.required?`required`:`optional`})]},e.name))}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2.5 text-[11.5px]`,children:`The canvas shows the values of the fixture selected in the toolbar.`})]})}function UI(){let e=$(e=>e.checks),t=$(e=>e.sourceEditable);return(0,Z.jsx)(`div`,{className:`py-3`,children:(0,Z.jsx)(CI,{checks:e,editable:t})})}function WI(){let{deviceWidth:e,entryFile:t,fixture:n,fixtures:r}=$(BO(e=>({deviceWidth:eP[e.previewDevice],entryFile:e.doc?.origin.file??null,fixture:e.doc?.channel===`email`?e.doc.fixture:null,fixtures:e.doc?.channel===`email`?e.doc.fixtures:RI})));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(_I,{children:`Document`}),(0,Z.jsx)(VI,{label:`Width`,children:(0,Z.jsxs)(bI,{children:[e,` `,(0,Z.jsx)(`span`,{className:`text-placeholder text-[10.5px]`,children:`px`})]})}),t!==null&&(0,Z.jsx)(VI,{label:`Entry`,children:(0,Z.jsx)(bI,{children:t})}),n!==null&&(0,Z.jsx)(VI,{label:`Fixture`,title:`${r.length} declared`,children:(0,Z.jsx)(bI,{children:n})})]}),(0,Z.jsx)(LI,{},`${n}:${t}`),(0,Z.jsx)(HI,{}),(0,Z.jsx)(UI,{})]})}function GI({value:e,onChange:t,onCommit:n,placeholder:r,type:i=`text`,testId:a}){return(0,Z.jsx)(`input`,{type:i,value:e,placeholder:r,"data-testid":a,spellCheck:!1,onChange:e=>t(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:XP(`border-border bg-background text-foreground placeholder:text-placeholder h-7 max-w-none min-w-0 flex-1 rounded-[5px] border px-2.5 text-xs outline-none`,ZP)})}function KI(){let e=$(e=>e.doc),t=$(e=>e.metadataError),{saveMetadata:n}=$(e=>e.actions),r=e?.metadata.fromDefault,[i,a]=(0,W.useState)(r?.name??``),[o,s]=(0,W.useState)(r?.email??``),[c,l]=(0,W.useState)((e?.metadata.replyToDefault??[]).join(`, `)),u=()=>{let e=o.trim();n({fromDefault:e.length===0?null:{email:e,name:i.trim()||void 0}})};return(0,Z.jsxs)(`div`,{className:`py-3`,children:[(0,Z.jsx)(_I,{children:`Defaults · per send`}),(0,Z.jsx)(VI,{label:`From name`,children:(0,Z.jsx)(GI,{value:i,onChange:a,onCommit:u,placeholder:`Sender name`})}),(0,Z.jsx)(VI,{label:`From email`,children:(0,Z.jsx)(GI,{type:`email`,value:o,onChange:s,onCommit:u,placeholder:`you@domain.com`,testId:`inspector.envelope.from-email`})}),(0,Z.jsx)(VI,{label:`Reply-To`,children:(0,Z.jsx)(GI,{type:`email`,value:c,onChange:l,onCommit:()=>{let e=c.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);n({replyToDefault:e.length===0?null:e})},placeholder:`Comma-separated`})}),t!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error mt-2 text-[11.5px]`,children:t})]})}function qI(){let e=$(e=>e.metadataEditable),t=$(e=>e.render);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-border-subtle text-muted-foreground border-b py-2.5 text-[11px] leading-relaxed`,children:`Subject and preview text come from the template code and the fixture on screen. From / Reply-To are template defaults, overridden per send.`}),(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(_I,{children:`Rendered`}),(0,Z.jsx)(VI,{label:`Subject`,children:(0,Z.jsx)(bI,{children:t?.subject??`No subject`})}),(0,Z.jsx)(VI,{label:`Preview`,children:(0,Z.jsx)(bI,{children:t?.preheader??`No preview text`})})]}),e?(0,Z.jsx)(KI,{}):(0,Z.jsx)(`p`,{className:`text-muted-foreground py-3 text-xs`,children:`This host does not edit sender defaults.`})]})}function JI({selection:e}){let t=$(e=>e.render?.selections??BI),{select:n}=$(e=>e.actions),r=e.origins[0],i=e.origins.slice(1),a=Yc(t,e),o=Xc(t,e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(_I,{children:`Element`}),(0,Z.jsx)(VI,{label:`Tag`,children:(0,Z.jsx)(bI,{testId:`inspector.element.tag`,children:e.tag})}),(0,Z.jsx)(VI,{label:`Source`,title:e.authored?`This element was written in the template.`:`A compiler primitive produced this element; the authoring below is the call that asked for it.`,children:(0,Z.jsx)(bI,{testId:`inspector.element.provenance`,children:e.authored?`Authored`:`Generated`})}),(0,Z.jsx)(VI,{label:`Instance`,children:(0,Z.jsx)(bI,{testId:`inspector.element.instance`,children:e.instancePath})})]}),(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(_I,{children:`Authoring`}),r===void 0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:`The renderer produced this element with no authoring on the stack, so nothing in the template points at it.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(VI,{label:`Written at`,children:(0,Z.jsx)(bI,{testId:`inspector.authoring.origin`,children:CN(r)})}),(0,Z.jsx)(`p`,{"data-testid":`inspector.authoring.occurrence`,className:`text-muted-foreground mt-2 text-[11.5px]`,children:e.occurrences>1?`This authoring renders ${e.occurrences} elements here; this is number ${e.occurrence}.`:`This authoring renders one element here.`}),o.length>a.length&&(0,Z.jsxs)(`p`,{"data-testid":`inspector.authoring.definition-scope`,className:`text-muted-foreground mt-1 text-[11.5px]`,children:[o.length,` elements across the whole render come from it, through more than one call site.`]})]})]}),(0,Z.jsx)(II,{selection:e},`${e.instancePath}:${e.start}:${e.end}`),i.length>0&&(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(_I,{children:`Call sites`}),(0,Z.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:i.map((e,t)=>(0,Z.jsx)(`li`,{"data-testid":`inspector.call-site.${t}`,className:`text-foreground font-mono text-[11.5px] break-all`,children:CN(e)},`${CN(e)}:${t}`))}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-[11.5px]`,children:`Innermost call first.`})]}),a.length>1&&(0,Z.jsxs)(`div`,{className:`py-3`,children:[(0,Z.jsx)(_I,{children:`Iterations`}),(0,Z.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:a.map((t,r)=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`inspector.iteration.${t.instancePath}`,onClick:()=>n(t.instancePath),className:XP(`hover:bg-muted w-full rounded px-1.5 py-1 text-left font-mono text-[11.5px]`,t.instancePath===e.instancePath&&`bg-sel-soft text-accent-email`),children:[r+1,`. `,t.instancePath]})},t.instancePath))})]})]})}function YI({embedded:e=!1}={}){let t=pF(),{outline:n,selection:r,rightCollapsed:i,rightWidth:a,layoutMode:o}=$(BO(e=>({outline:e.outline,selection:e.selection,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode}))),{select:s,selectDocument:c,breadcrumbOf:l,toggleRight:u}=$(e=>e.actions),d=r.kind===`element`?n?.index.get(r.instancePath)??null:null,f=r.kind===`envelope`?`envelope`:d===null?`document`:`element`,p=d===null?[]:l(d.instancePath),m=!e&&(o===`compact`||o===`narrow`);return(0,Z.jsx)(`aside`,{"aria-label":`Inspector`,"data-testid":`inspector`,"aria-hidden":!e&&i?!0:void 0,inert:!e&&i?!0:void 0,"data-editor-rail":`right`,style:{width:e?`100%`:i?0:a,maxWidth:m?`calc(100% - 48px)`:void 0},className:XP(`flex h-full shrink-0 flex-col overflow-hidden bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,!e&&`border-l border-border`,m&&`absolute inset-y-0 right-0 z-40 shadow-[var(--shadow-floating)]`,!e&&i&&`border-l-0`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:e?`100%`:a,maxWidth:`100%`},children:[(0,Z.jsx)(`div`,{className:`border-border bg-background/95 sticky top-0 z-10 border-b backdrop-blur-md`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden text-xs`,children:f===`document`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Document`}):f===`envelope`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Envelope`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:c,"data-testid":`inspector.document`,className:`hover:bg-muted hover:text-foreground shrink-0 rounded px-1`,children:`Email`}),p.map((e,t)=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder`,children:`/`}),t===p.length-1?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:e.label}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(e.instancePath),className:`hover:bg-muted hover:text-foreground max-w-[72px] truncate rounded px-1`,children:e.label})]},e.instancePath))]})}),d!==null&&(0,Z.jsx)(`span`,{"data-testid":`inspector.selection-badge`,className:`bg-muted text-muted-foreground shrink-0 rounded-md px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase`,children:d.authored?wN(d):`${d.tag} · generated`}),!e&&(0,Z.jsxs)(DT,{children:[(0,Z.jsx)(FT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse inspector`,"data-testid":`inspector.collapse`,onClick:u,className:`text-muted-foreground hover:bg-muted hover:text-foreground shrink-0 rounded-md p-1.5`}),children:(0,Z.jsx)(GP,{className:`size-[15px]`})}),(0,Z.jsx)(zT,{container:t,children:(0,Z.jsx)(cE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(lE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse inspector`})})})]})]})}),(0,Z.jsxs)(bA,{"data-samva-scroll-area":`inspector`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(MA,{className:`size-full`,children:(0,Z.jsxs)(`div`,{className:`samva-inspector-content pb-4`,children:[f===`document`&&(0,Z.jsx)(WI,{}),f===`envelope`&&(0,Z.jsx)(qI,{}),d!==null&&(0,Z.jsx)(JI,{selection:d})]})}),(0,Z.jsx)(RA,{orientation:`vertical`,className:`absolute top-0 right-0 bottom-0 flex w-2.5 touch-none p-0.5 select-none`,children:(0,Z.jsx)(zA,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}var XI={body:AP,div:NP,table:PP,tbody:PP,tr:PP,td:JP,th:JP,h1:FP,h2:FP,h3:FP,h4:FP,h5:FP,h6:FP,p:VP,span:VP,a:CP,button:CP,img:IP,hr:OP,br:bP,ul:SP,ol:SP,li:SP},ZI=e=>XI[e.toLowerCase()]??NP;function QI({node:e,depth:t}){let{selectedPath:n,expandedLayers:r}=$(BO(e=>({selectedPath:e.selection.kind===`element`?e.selection.instancePath:null,expandedLayers:e.expandedLayers}))),{select:i,toggleLayerExpand:a,setHovered:o}=$(e=>e.actions),s=e.children.length>0,c=r.has(e.instancePath),l=n===e.instancePath,{selection:u}=e;return(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`div`,{className:`group relative`,style:{paddingLeft:t*12},onMouseEnter:()=>o(e.instancePath),onMouseLeave:()=>o(null),children:(0,Z.jsxs)(`div`,{className:XP(`flex h-[30px] w-full items-center gap-1.5 rounded-[7px] pr-2 pl-1.5 text-left transition-colors`,l?`bg-sel-soft text-accent-email`:`text-foreground hover:bg-muted`),children:[s?(0,Z.jsx)(`button`,{type:`button`,"aria-expanded":c,"data-testid":`left-rail.layer.toggle`,"aria-label":`${c?`Collapse`:`Expand`} ${wN(u)}`,className:XP(`grid size-3.5 shrink-0 place-items-center text-muted-foreground transition-transform`,c&&`rotate-90`),onClick:t=>{t.stopPropagation(),a(e.instancePath)},children:(0,Z.jsx)(EP,{className:`size-[11px]`})}):(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`button`,{"data-layer-instance-path":e.instancePath,"data-testid":`layers.node.${e.instancePath}`,type:`button`,onClick:()=>i(e.instancePath),className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,W.createElement)(ZI(u.tag),{className:XP(`size-[15px] shrink-0`,l?`text-accent-email`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px]`,children:wN(u)}),!u.authored&&(0,Z.jsx)(`span`,{className:`text-placeholder shrink-0 text-[10px]`,children:`generated`})]})]})}),s&&c&&(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.children.map(e=>(0,Z.jsx)(QI,{node:e,depth:t+1},e.instancePath))})]})}function $I(){let e=$(e=>e.outline);return e===null?(0,Z.jsx)(`div`,{className:`text-placeholder px-3 py-8 text-center text-xs`,children:`There is no preview yet, so there are no layers to show.`}):(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.roots.map(e=>(0,Z.jsx)(QI,{node:e,depth:0},e.instancePath))})}function eL(){let e=pF(),{leftCollapsed:t,leftWidth:n,layoutMode:r}=$(BO(e=>({leftCollapsed:e.leftCollapsed,leftWidth:e.leftWidth,layoutMode:e.layoutMode}))),{toggleLeft:i}=$(e=>e.actions),a=r===`compact`||r===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Layers`,"aria-hidden":t||void 0,inert:t||void 0,"data-editor-rail":`left`,style:{width:t?0:n,maxWidth:a?`calc(100% - 48px)`:void 0},className:XP(`flex h-full shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,a&&`absolute inset-y-0 left-0 z-40 shadow-[var(--shadow-floating)]`,t&&`border-r-0`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:n,maxWidth:`100%`},children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex items-center gap-0.5 border-b px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-foreground text-[12.5px] font-medium`,children:`Layers`}),(0,Z.jsxs)(DT,{children:[(0,Z.jsx)(FT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse layers`,"data-testid":`left-rail.collapse`,onClick:i,className:`text-muted-foreground hover:bg-muted hover:text-foreground ml-auto rounded-md p-1.5`}),children:(0,Z.jsx)(UP,{className:`size-[15px]`})}),(0,Z.jsx)(zT,{container:e,children:(0,Z.jsx)(cE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(lE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse layers`})})})]})]}),(0,Z.jsxs)(bA,{"data-samva-scroll-area":`layers`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(MA,{className:`size-full`,children:(0,Z.jsx)(`div`,{className:`px-2 pt-2.5 pb-5`,children:(0,Z.jsx)($I,{})})}),(0,Z.jsx)(RA,{orientation:`vertical`,className:`absolute top-0 right-0 bottom-0 flex w-2.5 touch-none p-0.5 select-none`,children:(0,Z.jsx)(zA,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}function tL({embedded:e=!1}={}){let t=pF(),{checks:n,doc:r,readonlyReason:i,rightCollapsed:a,rightWidth:o}=$(BO(e=>({checks:e.checks,doc:e.doc,readonlyReason:e.readonlyReason,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth}))),{toggleRight:s}=$(e=>e.actions);return!e&&a?null:(0,Z.jsxs)(`aside`,{"data-editor-rail":`right`,style:{width:e?`100%`:o},className:e?`bg-background flex h-full shrink-0 flex-col overflow-hidden`:`border-border bg-background flex h-full shrink-0 flex-col overflow-hidden border-l`,children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex h-11 items-center border-b px-3`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Template details`}),!e&&(0,Z.jsxs)(DT,{children:[(0,Z.jsx)(FT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse inspector`,onClick:s,className:`text-muted-foreground hover:bg-muted hover:text-foreground ml-auto rounded-md p-1.5`}),children:(0,Z.jsx)(GP,{className:`size-[15px]`})}),(0,Z.jsx)(zT,{container:t,children:(0,Z.jsx)(cE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(lE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse inspector`})})})]})]}),(0,Z.jsxs)(`div`,{className:`samva-editor-scroll min-h-0 flex-1 overflow-y-auto p-4 text-[12.5px]`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Read-only`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:i}),r!==null&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-3 font-mono text-[11.5px] break-all`,children:r.origin.file}),(0,Z.jsx)(`div`,{className:`border-border-subtle mt-5 border-t pt-4`,children:(0,Z.jsx)(CI,{checks:n})})]})]})}var nL=XP(`flex flex-1 items-center justify-center gap-1.5 px-2 text-[12px]`,$P),rL={layers:{label:`Layers`,Icon:LP},inspector:{label:`Inspector`,Icon:KP},review:{label:`Review`,Icon:MP}},iL=[`layers`,`inspector`,`review`];function aL({view:e,sourceEditable:t,review:n}){return e===`layers`?(0,Z.jsx)(`div`,{className:`samva-editor-scroll h-full overflow-y-auto px-2 pt-2.5 pb-5`,children:(0,Z.jsx)($I,{})}):e===`review`&&n!==null?(0,Z.jsx)(`div`,{className:`samva-editor-scroll h-full overflow-y-auto px-2 pt-2.5 pb-5`,children:n.content}):t?(0,Z.jsx)(YI,{embedded:!0}):(0,Z.jsx)(tL,{embedded:!0})}function oL({focused:e=!1}){let t=$(e=>e.sourceEditable),n=$(e=>e.rightWidth),r=$(e=>e.designView),i=$(e=>e.actions.setDesignView),a=aF(`rail.review`)??null,o=r===`review`&&a===null?`layers`:r,s=(0,W.useId)(),c=`${s}-panel`;return(0,Z.jsxs)(`aside`,{"aria-label":`Design`,"data-testid":`design-rail`,"data-editor-rail":`right`,style:e?void 0:{width:n},className:XP(`bg-background flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,e?`w-full flex-1`:`shrink-0 border-l border-border`),children:[(0,Z.jsx)(`div`,{className:`border-border-subtle flex min-h-11 shrink-0 items-center border-b px-2 py-1.5`,children:(0,Z.jsx)(ek,{role:`tablist`,"aria-label":`Design view`,value:[o],onValueChange:e=>{let t=e[0];(t===`layers`||t===`inspector`)&&i(t),t===`review`&&a!==null&&i(`review`)},className:`bg-muted flex flex-1 gap-0.5 rounded-lg p-0.5`,children:iL.filter(e=>e!==`review`||a!==null).map(e=>{let{Icon:t,label:n}=rL[e];return(0,Z.jsxs)(qO,{id:`${s}-tab-${e}`,type:`button`,role:`tab`,"aria-selected":o===e,"aria-controls":c,"aria-pressed":void 0,value:e,"data-testid":`design.tab.${e}`,className:nL,children:[(0,Z.jsx)(t,{className:`size-[14px]`}),n,e===`review`&&a?.badge]},e)})})}),(0,Z.jsx)(`div`,{role:`tabpanel`,id:c,"aria-labelledby":`${s}-tab-${o}`,className:`min-h-0 flex-1`,children:(0,Z.jsx)(aL,{view:o,sourceEditable:t,review:a})})]})}function sL({side:e}){let t=$(e=>e.leftWidth),n=$(e=>e.assistantWidth),r=$(e=>e.rightWidth),{setAssistantWidth:i,setLeftWidth:a,setRightWidth:o}=$(e=>e.actions),s=(0,W.useRef)(!1);return(0,W.useEffect)(()=>{let t=t=>{s.current&&(e===`assistant`?i(t.clientX):e===`assistant-end`?i(window.innerWidth-t.clientX):e===`left`?a(t.clientX):o(window.innerWidth-t.clientX))},n=()=>{s.current&&(s.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return window.addEventListener(`mousemove`,t),window.addEventListener(`mouseup`,n),()=>{window.removeEventListener(`mousemove`,t),window.removeEventListener(`mouseup`,n)}},[e,i,a,o]),(0,Z.jsx)(`div`,{"data-editor-resize":e,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":e===`assistant`||e===`assistant-end`?n:e===`left`?t:r,"aria-label":e===`assistant`||e===`assistant-end`?`Resize Assistant`:e===`left`?`Resize layers panel`:`Resize inspector`,"data-testid":e===`assistant`||e===`assistant-end`?`agent-column.resize`:e===`left`?`left-rail.resize`:`inspector.resize`,tabIndex:0,onMouseDown:e=>{e.preventDefault(),s.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},onKeyDown:s=>{let c=s.shiftKey?24:8;(s.key===`ArrowLeft`||s.key===`ArrowRight`)&&(s.preventDefault(),e===`assistant`?(s.key===`ArrowLeft`&&i(n-c),s.key===`ArrowRight`&&i(n+c)):e===`assistant-end`?(s.key===`ArrowLeft`&&i(n+c),s.key===`ArrowRight`&&i(n-c)):e===`left`?(s.key===`ArrowLeft`&&a(t-c),s.key===`ArrowRight`&&a(t+c)):(s.key===`ArrowLeft`&&o(r+c),s.key===`ArrowRight`&&o(r-c)))},className:XP(`group relative z-10 w-2 shrink-0 cursor-col-resize`,`before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border before:transition-colors`,`hover:before:w-0.5 hover:before:bg-accent-email active:before:bg-accent-email`,`after:absolute after:top-1/2 after:left-1/2 after:h-10 after:w-1 after:-translate-x-1/2 after:-translate-y-1/2 after:rounded-full after:bg-muted-foreground/35 after:opacity-60 after:transition-opacity`,`hover:after:opacity-100 hover:after:bg-accent-email`)})}var cL={assistant:{label:`Assistant`,tip:`Show the assistant`,Icon:qP},preview:{label:`Preview`,tip:`Show the preview`,Icon:jP},design:{label:`Design`,tip:`Show designs, layers, and inspector`,Icon:LP}};function lL(){let e=$(e=>e.sourceEditable),t=$(e=>e.leftCollapsed),n=$(e=>e.rightCollapsed),r=$(e=>e.layoutMode),i=aF(`rail.assistant`)!==void 0,a=aF(`rail.review`),o=$(e=>e.workspaceView),s=$(e=>e.focusedPane),c=$(e=>e.actions.setFocusedPane),l=SN(),u=e=>l.setState({workspaceView:e}),d=(0,W.useId)(),f=i&&r===`compact`,p=i&&r===`narrow`,m=f||p,h=f?[`assistant`,`preview`,`design`]:[`assistant`,`preview`],g=o===`source`?`preview`:h.includes(s)?s:`assistant`;return i?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(yF,{value:o,onChange:e=>{u(e),m&&c(`preview`)},idBase:d,panelId:`${d}-view-panel`}),m&&(0,Z.jsx)(ek,{role:`tablist`,value:[g],onValueChange:e=>{let t=e[0];h.some(e=>e===t)&&(c(t),t!==`preview`&&o===`source`&&u(`visual`))},"aria-label":`Editor pane`,className:`border-border bg-background flex h-11 shrink-0 items-center gap-1 border-b p-1.5`,children:h.map(e=>{let{Icon:t,label:n,tip:r}=cL[e];return(0,Z.jsxs)(qO,{id:`${d}-tab-${e}`,type:`button`,role:`tab`,"aria-selected":g===e,"aria-controls":`${d}-pane-${e}`,"aria-pressed":void 0,value:e,title:r,"data-testid":`agent-workspace.tab.${e}`,className:XP($P,`h-8 flex-1 px-2.5 text-[12px]`),children:[(0,Z.jsx)(t,{className:`size-3.5 shrink-0`}),n,e===`design`&&a?.badge]},e)})}),(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,"data-agent-workspace-layout":m?`focused`:`split`,children:[(0,Z.jsx)(`div`,{id:`${d}-pane-assistant`,role:m?`tabpanel`:void 0,"aria-labelledby":m?`${d}-tab-assistant`:void 0,hidden:m&&g!==`assistant`,className:XP(!m&&`contents`,m&&g===`assistant`&&`flex h-full min-h-0 min-w-0 flex-1`),children:(0,Z.jsx)(uF,{hidden:m&&g!==`assistant`})}),!m&&(0,Z.jsx)(sL,{side:`assistant`}),(0,Z.jsx)(`div`,{id:`${d}-pane-preview`,role:m?`tabpanel`:void 0,"aria-labelledby":m?`${d}-tab-preview`:void 0,hidden:m&&g!==`preview`,className:XP(`min-h-0 min-w-0 flex-1`,(!m||g===`preview`)&&`flex`),children:(0,Z.jsx)(`div`,{id:`${d}-view-panel`,role:`tabpanel`,"aria-labelledby":_F(d,o),className:`flex min-h-0 min-w-0 flex-1`,children:o===`source`?(0,Z.jsx)(hF,{}):(0,Z.jsx)(xI,{pointing:!0})})}),!m&&(0,Z.jsx)(sL,{side:`right`}),(0,Z.jsx)(`div`,{id:`${d}-pane-design`,role:f?`tabpanel`:void 0,"aria-labelledby":f?`${d}-tab-design`:void 0,hidden:m&&g!==`design`,className:XP(!m&&`contents`,m&&g===`design`&&`flex h-full min-h-0 min-w-0 flex-1`),children:p?null:(0,Z.jsx)(oL,{focused:m})})]})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(PI,{}),(0,Z.jsx)(yF,{value:o,onChange:u,children:o===`source`?(0,Z.jsx)(hF,{}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(eL,{}),!t&&(0,Z.jsx)(sL,{side:`left`}),(0,Z.jsx)(xI,{}),!n&&(0,Z.jsx)(sL,{side:`right`}),e?(0,Z.jsx)(YI,{}):(0,Z.jsx)(tL,{})]})})]})}var uL=RegExp(`\\s${Gc}="[^"]*"`,`g`),dL=e=>e.replace(uL,``),fL=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t===``?`email`:t},pL=(e,t)=>{let n=new Blob([dL(e)],{type:`text/html;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${fL(t)}.html`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)},mL=`image/png,image/jpeg,image/gif,image/webp,.woff2`,hL=1048576,gL=(e,t)=>{let n=e?.lastIndexOf(`/`)??-1;return`${e===void 0||n<0?``:e.slice(0,n+1)}assets/${t}`},_L=e=>{let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(t):``},vL=e=>j(e,`_tag`)&&e._tag===`ProjectFileExists`,yL=e=>j(e,`reason`)&&typeof e.reason==`string`?e.reason:`The template project operation failed.`,bL=e=>e.isPublished?`Published`:e.isHead?`Current saved version`:`Saved version`;function xL({file:e,content:t,busy:n,onChange:r,onApply:i,onReplace:a}){let o=e.status===`conflicted`;return(0,Z.jsxs)(`div`,{className:`border-border space-y-3 rounded-lg border p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h4`,{className:`truncate font-mono text-xs font-semibold`,children:e.path}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e.status})]}),e.binary===!0?(0,Z.jsx)(`div`,{className:`space-y-3`,"data-testid":`lifecycle-sheet.binary-file`,children:e.status===`deleted`?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Removed from the draft. Save a version to keep this change.`}):(0,Z.jsxs)(Z.Fragment,{children:[(e.status===`added`||e.status===`modified`)&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Unsaved until you save a version.`}),(0,Z.jsx)(`button`,{type:`button`,disabled:n,"data-testid":`lifecycle-sheet.replace-file`,onClick:a,className:XP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs disabled:opacity-50`,ZP),children:`Replace file`})]})}):o?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Resolve this file below before editing its workspace source.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`textarea`,{"aria-label":`Project source for ${e.path}`,"data-testid":`lifecycle-sheet.file-source.${e.path}`,value:t,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1,className:`border-border bg-surface-inset text-foreground min-h-52 w-full resize-y rounded-md border p-3 font-mono text-xs outline-none disabled:opacity-60`}),(0,Z.jsx)(`button`,{type:`button`,disabled:n||t===e.content,"data-testid":`lifecycle-sheet.apply-file.${e.path}`,onClick:()=>i(t),className:XP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,ZP),children:`Apply file`})]})]})}function SL({conflict:e,busy:t,onResolve:n}){let[r,i]=(0,W.useState)(e.draft??e.main??``);return(0,Z.jsxs)(`article`,{className:`border-status-warning/45 space-y-3 rounded-lg border p-4`,children:[(0,Z.jsx)(`h4`,{className:`font-mono text-xs font-semibold`,children:e.path}),(0,Z.jsxs)(`details`,{className:`border-border rounded-md border`,children:[(0,Z.jsx)(`summary`,{className:`hover:bg-muted cursor-pointer px-3 py-2 text-xs font-medium`,children:`Compare base, draft, and main`}),(0,Z.jsx)(`div`,{className:`divide-border border-border divide-y border-t`,children:[[`Base`,e.base],[`Draft`,e.draft],[`Latest saved version`,e.main]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`space-y-1 p-3`,children:[(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11px] font-medium`,children:e}),(0,Z.jsx)(`pre`,{className:`samva-editor-scroll max-h-32 overflow-auto font-mono text-xs whitespace-pre-wrap`,children:t??`File does not exist`})]},e))})]}),(0,Z.jsx)(`textarea`,{"aria-label":`Resolved source for ${e.path}`,"data-testid":`lifecycle-sheet.conflict-source.${e.path}`,value:r,onChange:e=>i(e.target.value),spellCheck:!1,className:`border-border bg-surface-inset text-foreground min-h-40 w-full resize-y rounded-md border p-3 font-mono text-xs outline-none`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`draft`),"data-testid":`lifecycle-sheet.keep-draft`,className:XP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,ZP),children:`Keep draft`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`main`),className:XP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,ZP),children:`Use saved version`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`lifecycle-sheet.resolve-edited.${e.path}`,onClick:()=>n({content:r}),className:XP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium`,ZP),children:`Use edited source`})]})]})}function CL({open:e,onClose:t,onLockedAction:n}){return e?(0,Z.jsx)(wL,{onClose:t,onLockedAction:n}):null}function wL({onClose:e,onLockedAction:t}){let n=pF(),r=$(e=>e.doc),i=$(e=>e.lifecycleCapability),{beginLifecycle:a,endLifecycle:o,flushSaves:s,adoptLifecycleSnapshot:c}=$(e=>e.actions),l=r!==null&&i?.status===`ready`,[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)({}),[v,y]=(0,W.useState)(()=>l?`loading`:null),b=(0,W.useRef)(null),x=(0,W.useRef)(null),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(l);if(l!==O&&(k(l),l&&(y(`loading`),d(null),T(null),D(null),p(null),h(null),_({}),C(null))),(0,W.useEffect)(()=>{if(i?.status!==`ready`)return;let e=!1;return s().then(()=>i.api.inspect()).then(t=>{if(e)return;d(t);let n=r?.origin.kind===`tsx`?r.origin.file:void 0;h(e=>e!==null&&t.files.some(({path:t})=>t===e)?e:n!==void 0&&t.files.some(({path:e})=>e===n)?n:t.files[0]?.path??null)}).catch(t=>{e||T(yL(t))}).finally(()=>{e||y(null)}),()=>{e=!0}},[r,s,i]),i===void 0)return null;if(i.status===`locked`)return(0,Z.jsx)(ij,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsxs)(ZA,{container:n,children:[(0,Z.jsx)(HA,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(aj,{className:`fixed inset-0 z-[111] grid place-items-center p-4`,children:(0,Z.jsxs)(XA,{className:`border-border bg-popover w-full max-w-lg rounded-xl border p-5 shadow-[var(--shadow-floating)]`,children:[(0,Z.jsx)(oj,{className:`text-base font-semibold`,children:`Publishing is unavailable`}),(0,Z.jsx)(WA,{className:`text-muted-foreground mt-2 text-sm`,"data-testid":`lifecycle-sheet.locked-reason`,children:i.upsell.reason}),(0,Z.jsx)(`a`,{"data-testid":`lifecycle-sheet.upsell-cta`,className:XP(`bg-primary text-primary-foreground mt-4 inline-flex rounded-md px-3 py-2 text-sm font-medium`,ZP),href:i.upsell.cta.href,onClick:e=>{t!==void 0&&(e.preventDefault(),t())},children:i.upsell.cta.label}),(0,Z.jsx)(UA,{className:XP(`border-border hover:bg-muted mt-4 ml-2 inline-flex rounded-md border px-3 py-2 text-sm font-medium`,ZP),children:`Close`})]})})]})});let A=u?.commits.find(({commit:e})=>e===f),j=u?.files.find(({path:e})=>e===m),M=j?.content??``,N=j===void 0?void 0:g[j.path],P=N?.baseContent===M?N.content:M,F=u?.files.some(e=>{let t=g[e.path],n=e.content??``;return t?.baseContent===n&&t.content!==n})??!1,I=u!==null&&!u.dirty&&u.conflicts.length===0&&!F,L=u?.commits.find(({commit:e})=>e===u.baseCommit),R=I&&u?.baseCommit===u.remoteHead,ee=async()=>d(await i.api.inspect()),z=()=>{u!==null&&R&&v===null&&a()&&(y(`publish`),T(null),i.api.publish({baseRev:u.rev,commit:u.baseCommit}).then(async()=>{await ee(),D(`Published the current saved version.`)}).catch(e=>T(yL(e))).finally(()=>{o(),y(null)}))},te=()=>{u!==null&&A!==void 0&&!A.isHead&&I&&v===null&&a()&&(y(`restore`),T(null),s().then(e=>i.api.restore({commit:A.commit,baseRev:e})).then(async e=>{c(e),await ee(),p(null),D(`Restored the saved version to the draft. Save a version to keep this restore.`)}).catch(e=>T(yL(e))).finally(()=>{o(),y(null)}))},ne=(e,t)=>{u!==null&&v===null&&a()&&(y(`resolve`),T(null),s().then(n=>i.api.resolveConflict({path:e.path,baseRev:n,resolution:t})).then(t=>{d(t),D(`Resolved ${e.path}.`)}).catch(e=>T(yL(e))).finally(()=>{o(),y(null)}))},re=(e,t)=>{u!==null&&v===null&&(y(`file`),T(null),i.api.updateFile({path:e.path,baseRev:u.rev,content:t}).then(t=>{d(t),_(t=>{let{[e.path]:n,...r}=t;return r}),D(`Updated ${e.path}.`)}).catch(e=>T(yL(e))).finally(()=>y(null)))},B=(e,t,n)=>{u!==null&&v===null&&(y(`file`),T(null),D(null),C(null),i.api.putAsset({path:e,baseRev:u.rev,bytes:t,replace:n}).then(t=>{d(t),h(e),D(`${n?`Replaced`:`Added`} ${e}. Save a version to keep this change.`)}).catch(n=>{vL(n)?C({path:e,bytes:t}):T(yL(n))}).finally(()=>y(null)))},ie=e=>{let t=b.current;t!==null&&(x.current=e===null?null:{replacePath:e},t.accept=e===null?mL:_L(e),t.value=``,t.click())},ae=e=>{let t=x.current;if(x.current=null,e===void 0||u===null)return;if(e.size>hL){D(null),T(`${e.name} is larger than 1 MB. Choose a smaller file.`);return}let n=r?.origin.kind===`tsx`?r.origin.file:void 0,i=t?.replacePath??gL(n,e.name);e.arrayBuffer().then(e=>{let n=new Uint8Array(e);if(t===null&&u.files.some(e=>e.path===i)){T(null),D(null),C({path:i,bytes:n});return}B(i,n,t!==null)}).catch(e=>T(yL(e)))};return(0,Z.jsx)(Uj,{open:!0,onOpenChange:t=>!t&&e(),swipeDirection:`right`,children:(0,Z.jsxs)(Bj,{container:n,children:[(0,Z.jsx)(gj,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(kM,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(zj,{className:`border-border bg-popover pointer-events-auto flex h-full w-full max-w-2xl flex-col border-l shadow-[var(--shadow-floating)]`,children:[(0,Z.jsxs)(`header`,{className:`border-border flex items-center justify-between border-b px-5 py-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(fM,{className:`text-base font-semibold`,children:`Publish and saved versions`}),(0,Z.jsx)(yj,{className:`text-muted-foreground mt-0.5 text-xs`,children:`Save keeps a named version. Restore brings an older version into your draft.`})]}),(0,Z.jsx)(_j,{"data-testid":`lifecycle-sheet.close`,className:XP(`hover:bg-muted rounded-md px-2 py-1 text-sm`,ZP),children:`Close`})]}),(0,Z.jsxs)(`div`,{className:`samva-editor-scroll min-h-0 flex-1 space-y-6 overflow-y-auto p-5`,children:[v===`loading`&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading saved versions…`}),w!==null&&(0,Z.jsx)(`p`,{className:`text-status-error text-sm`,role:`alert`,children:w}),E!==null&&(0,Z.jsx)(`p`,{className:`text-status-success text-sm`,role:`status`,"data-testid":`lifecycle-sheet.notice`,children:E}),u!==null&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`border-border bg-muted/30 space-y-3 rounded-lg border p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Current saved version`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:L?.message??`Current saved version`})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:z,disabled:!R||v!==null,"data-testid":`lifecycle-sheet.confirm-publish`,className:XP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-sm font-medium disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:v===`publish`?`Publishing…`:`Publish saved version`})]}),!I&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,"data-testid":`lifecycle-sheet.cleanliness-warning`,children:u.conflicts.length>0?`Resolve workspace conflicts before Save or Publish.`:`The draft has unsaved changes. Save a version before publishing or restoring.`}),I&&u.baseCommit!==u.remoteHead&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`The saved version changed elsewhere. Refresh before publishing.`})]}),(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Project files`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,"data-testid":`lifecycle-sheet.add-file`,onClick:()=>ie(null),className:XP(`border-border hover:bg-muted rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Add file`}),(0,Z.jsx)(`input`,{ref:b,type:`file`,accept:mL,hidden:!0,"data-testid":`lifecycle-sheet.add-file-input`,onChange:e=>ae(e.target.files?.[0])})]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Add PNG, JPEG, GIF, or WebP images and WOFF2 fonts up to 1 MB.`}),S!==null&&(0,Z.jsxs)(`div`,{className:`border-status-warning/45 space-y-3 rounded-lg border p-3`,"data-testid":`lifecycle-sheet.replace-prompt`,children:[(0,Z.jsxs)(`p`,{className:`text-xs`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:S.path}),` already exists. Replace it with the file you chose?`]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,"data-testid":`lifecycle-sheet.confirm-replace`,onClick:()=>B(S.path,S.bytes,!0),className:XP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Replace file`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,onClick:()=>C(null),className:XP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Cancel`})]})]}),(0,Z.jsx)(`div`,{className:`border-border divide-border divide-y rounded-lg border`,children:u.files.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`lifecycle-sheet.file.${e.path}`,onClick:()=>h(e.path),className:XP(`hover:bg-muted flex w-full items-center justify-between gap-4 px-3 py-2 text-left`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,m===e.path&&`bg-muted`),children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.path}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e.status})]},e.path))}),j!==void 0&&(0,Z.jsx)(xL,{file:j,content:P,busy:v!==null,onChange:e=>_(t=>{if(e===M){let{[j.path]:e,...n}=t;return n}return{...t,[j.path]:{baseContent:M,content:e}}}),onApply:e=>re(j,e),onReplace:()=>ie(j.path)},`${j.path}:${j.content??``}`)]}),u.conflicts.length>0&&(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Resolve conflicts`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:`Choose either side or edit the final file. Save remains blocked until every path is resolved.`})]}),u.conflicts.map(e=>(0,Z.jsx)(SL,{conflict:e,busy:v!==null,onResolve:t=>ne(e,t)},e.path))]}),(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Saved versions`}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:u.commits.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`lifecycle-sheet.commit.${e.commit}`,onClick:()=>p(e.commit),className:XP(`border-border hover:bg-muted flex w-full items-start justify-between gap-4 rounded-lg border p-3 text-left`,f===e.commit&&`ring-primary ring-2`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:[(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.message}),(0,Z.jsx)(`span`,{className:`text-muted-foreground mt-1 block text-xs`,children:e.committedAt.toLocaleString()})]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:bL(e)})]},e.commit))})]}),A!==void 0&&!A.isHead&&(0,Z.jsxs)(`section`,{className:`border-border space-y-3 rounded-lg border p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Restore saved version`}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:[`Bring “`,A.message,`” into the current draft. Save a version when you want to keep the restored draft.`]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:te,disabled:!I||v!==null,"data-testid":`lifecycle-sheet.restore`,className:XP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-sm`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:v===`restore`?`Restoring…`:`Restore this version`})]})]})]})]})})]})})}function TL({container:e,children:t}){return(0,Z.jsx)(fF,{value:e,children:t})}var EL={desktop:600,mobile:375},DL=`Copy code`;function OL({open:e,onClose:t}){return e?(0,Z.jsx)(kL,{onClose:t}):null}function kL({onClose:e}){let t=pF(),{doc:n,render:r,checks:i,previewDevice:a}=$(BO(e=>({doc:e.doc,render:e.render,checks:e.checks,previewDevice:e.previewDevice}))),[o,s]=(0,W.useState)(`preview`),[c,l]=(0,W.useState)(a),[u,d]=(0,W.useState)(`light`),[f,p]=(0,W.useState)(n?.channel);n?.channel!==f&&(p(n?.channel),s(`preview`));let[m,h]=(0,W.useState)(a);if(a!==m&&(h(a),s(`preview`),l(a),d(`light`)),n===null)return null;let g=n.metadata.fromDefault,_=(e,t)=>({value:e,label:t,testId:`preview-overlay.view.${e}`}),v=n.channel===`email`?[_(`preview`,`Preview`),_(`html`,`HTML`),_(`text`,`Text`),_(`source`,`TSX`)]:n.channel===`sms`?[_(`preview`,`Preview`),_(`text`,`Text`),_(`source`,`TSX`)]:[_(`preview`,`Preview`),_(`payload`,`Payload`),_(`source`,`TSX`)],y=o===`source`?n.origin.authoredSource:o===`html`&&r!==null?r.html:o===`text`&&r!==null?r.text:o===`text`&&n.channel===`sms`&&n.render!==null?n.render.text:o===`payload`&&n.channel===`whatsapp`&&n.render!==null?JSON.stringify(n.render,null,2):``;return(0,Z.jsx)(ij,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsx)(ZA,{container:t,children:(0,Z.jsxs)(XA,{className:`samva-editor-shell fixed inset-0 z-[100] flex flex-col bg-[var(--editor-canvas-bg)] outline-none`,children:[(0,Z.jsx)(oj,{className:`sr-only`,children:`Template preview`}),(0,Z.jsx)(WA,{className:`sr-only`,children:`Preview the rendered template and inspect its generated output.`}),(0,Z.jsxs)(`div`,{"data-testid":`preview-overlay.toolbar`,className:`border-border-subtle flex shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2.5 sm:gap-2.5 sm:px-4`,children:[(0,Z.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Preview`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground hidden text-xs sm:inline`,children:`rendered message, exactly what ships`}),(0,Z.jsx)(yI,{ariaLabel:`Preview format`,testId:`preview-overlay.format-group`,value:o,onChange:e=>s(e),options:v}),(0,Z.jsx)(`span`,{className:`hidden flex-1 sm:block`}),n.channel===`email`&&o===`preview`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yI,{ariaLabel:`Preview width`,testId:`preview-overlay.width-group`,value:c,onChange:e=>l(e),options:[{value:`desktop`,label:`Desktop`,testId:`preview-overlay.device.desktop`},{value:`mobile`,label:`Mobile`,testId:`preview-overlay.device.mobile`}]}),(0,Z.jsx)(yI,{ariaLabel:`Preview color scheme`,testId:`preview-overlay.color-scheme-group`,value:u,onChange:e=>d(e),options:[{value:`light`,label:`Light`,testId:`preview-overlay.scheme.light`},{value:`dark`,label:`Dark`,testId:`preview-overlay.scheme.dark`}]}),(0,Z.jsx)(wI,{checks:i})]}),(0,Z.jsxs)(UA,{"data-testid":`preview-overlay.close`,className:`border-border text-foreground hover:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 ml-auto inline-flex h-[30px] items-center gap-1.5 rounded-[7px] border px-2.5 outline-none focus-visible:ring-[3px]`,children:[`Close`,(0,Z.jsx)(`kbd`,{className:`text-muted-foreground text-[10px]`,children:`⎋`})]})]}),o===`preview`?n.channel===`email`?(0,Z.jsxs)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto px-6 pt-3 pb-12`,children:[(0,Z.jsxs)(`div`,{"data-testid":`preview-overlay.device-frame`,className:XP(`mx-auto mb-3.5 max-w-full truncate text-[12.5px] text-muted-foreground transition-[width] duration-180`,c===`mobile`?`w-[375px]`:`w-[600px]`),children:[g!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`b`,{className:`text-foreground font-semibold`,children:g.name??g.email}),g.name===void 0?null:(0,Z.jsxs)(Z.Fragment,{children:[` <`,g.email,`>`]}),` ·`,` `]}),(0,Z.jsx)(`b`,{className:`text-foreground font-semibold`,children:r?.subject??``}),r?.preheader!==void 0&&(0,Z.jsxs)(`span`,{className:`opacity-70`,children:[` — `,r.preheader]})]}),(0,Z.jsx)(`div`,{className:XP(`mx-auto h-[calc(100%-2rem)] max-w-full transition-[width] duration-180 ease-out`,c===`mobile`?`w-[375px]`:`w-[600px]`),children:r===null?(0,Z.jsx)(`pre`,{className:`border-status-error/40 bg-background text-status-error rounded-lg border p-4 font-mono text-xs whitespace-pre-wrap`,children:`The current draft did not build, so there is nothing to preview.`}):(0,Z.jsx)(rI,{html:r.html,width:EL[c],forceColorScheme:u})})]}):(0,Z.jsx)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto p-8`,children:(0,Z.jsx)(`div`,{className:`border-border bg-background mx-auto max-w-[460px] rounded-[28px] border p-5 shadow-[var(--shadow-lg)]`,children:n.channel===`sms`&&n.render!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{"data-testid":`preview-overlay.sms-body`,className:`bg-muted rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:n.render.text}),(0,Z.jsx)(TF,{text:n.render.text,className:`mt-4 text-center text-xs`})]}):n.channel===`whatsapp`&&n.render!==null?(0,Z.jsxs)(`div`,{className:`bg-surface-inset rounded-xl p-3.5`,children:[n.render.header!==void 0&&n.render.header.text!==``&&(0,Z.jsx)(`p`,{className:`mb-1 font-semibold`,children:n.render.header.text}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap`,children:n.render.body}),n.render.footer!==void 0&&n.render.footer!==``&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:n.render.footer}),n.render.buttons.map((e,t)=>(0,Z.jsx)(`div`,{className:`border-border-subtle text-accent-email mt-2 border-t pt-2 text-center text-xs`,children:e.type===`copy-code`?DL:e.text},`${e.type}-${t}`))]}):(0,Z.jsx)(`pre`,{className:`text-status-error whitespace-pre-wrap`,children:`The current draft did not build, so there is nothing to preview.`})})}):(0,Z.jsx)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto p-6`,children:(0,Z.jsx)(`pre`,{className:`border-border bg-background text-foreground mx-auto min-h-full max-w-[1100px] rounded-lg border p-5 font-mono text-[12px] leading-5 whitespace-pre-wrap`,children:y})})]})})})}function AL({saveVersionStatus:e,saveVersionState:t,onSaveVersion:n,saveVersionBusy:r,saveVersionBlocked:i,guestHeadline:a}){let o=pF(),{doc:s,checks:c,sizeKb:l,deviceWidth:u,layoutMode:d}=$(BO(e=>({doc:e.doc,checks:e.checks,sizeKb:e.sizeKb,deviceWidth:eP[e.previewDevice],layoutMode:e.layoutMode}))),{selectDocument:f}=$(e=>e.actions),p=$(e=>e.sourceEditable),m=$(e=>e.pendingAuthoredSource),h=$(BO(e=>({storageError:e.storageError,conflict:e.conflict}))),[g,_]=(0,W.useState)(!1),{errorCount:v,warnCount:y}=XN(c),b=d===`compact`||d===`narrow`,x=c.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)).length,S=`No known risks found`;x>0&&(S=`No known risks · ${x} need verification`),y>0&&(S=`${y} warning${y>1?`s`:``}`),v>0&&(S=`${v} check${v>1?`s`:``} failing`),c.length===0&&(S=`No checks yet`);let C=t===`error`||h.storageError!==null||h.conflict?`Couldn't save version`:m!==null||r===!0?`Saving…`:void 0;return(0,Z.jsxs)(`footer`,{className:`border-border bg-background text-muted-foreground z-30 flex min-h-8 items-center gap-4 border-t px-3.5 py-1 text-[11.5px]`,children:[(0,Z.jsxs)(tN,{open:g,onOpenChange:_,children:[(0,Z.jsxs)(iN,{"data-testid":`statusbar.checks-trigger`,"aria-label":d===`narrow`?S:void 0,onClick:()=>f(),className:XP(`inline-flex shrink-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 transition-colors hover:bg-muted hover:text-foreground`,a===void 0&&(d===`narrow`?`w-6`:`w-[clamp(96px,18vw,240px)]`),g&&`bg-muted text-foreground`),children:[(0,Z.jsx)(`span`,{className:XP(`size-[7px] shrink-0 rounded-full`,v>0?`bg-status-error`:y>0?`bg-status-warning`:`bg-muted-foreground`)}),a===void 0&&d!==`narrow`?(0,Z.jsx)(`span`,{className:`truncate`,children:S}):null]}),(0,Z.jsx)(sN,{container:o,children:(0,Z.jsx)(uN,{side:`top`,align:`start`,sideOffset:8,collisionPadding:12,className:`z-[80] outline-none`,children:(0,Z.jsx)(pN,{"data-testid":`statusbar.checks-popup`,className:`samva-editor-shell border-border bg-surface-elevated max-h-[min(560px,70vh)] w-[360px] origin-[var(--transform-origin)] overflow-y-auto rounded-xl border p-3.5 shadow-[var(--shadow-xl)] transition-[transform,scale,opacity] data-[ending-style]:scale-95 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0`,children:(0,Z.jsx)(CI,{checks:c,editable:p})})})})]}),a===void 0?!b&&(0,Z.jsx)(`span`,{className:`w-[52px] shrink-0`,children:s===null?`Loading…`:`Draft`}):(0,Z.jsx)(`span`,{"data-testid":`statusbar.guest`,className:`min-w-0 truncate`,children:C??a}),a===void 0?(0,Z.jsx)(`span`,{"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,className:XP(`truncate`,d===`narrow`?`min-w-0 flex-1`:`w-[150px] shrink-0`),children:e??`Autosaved just now`}):(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,children:C??e??a}),n!==void 0&&(0,Z.jsx)(`button`,{type:`button`,onClick:n,disabled:r===!0||i===!0,"data-testid":`topbar.save-version`,"aria-label":`Save the current draft as a version`,title:`Save this draft as a version (⌘/Ctrl+S)`,className:`hover:bg-muted hover:text-foreground w-[82px] shrink-0 rounded-md px-1.5 py-0.5 text-left transition-colors`,children:r===!0?`Saving…`:e===`Couldn’t save version`?`Retry`:`Save version`}),(0,Z.jsx)(`span`,{className:`flex-1`}),!b&&(0,Z.jsxs)(`span`,{className:`w-10 shrink-0 text-right`,children:[l,` KB`]}),d!==`narrow`&&(0,Z.jsx)(`span`,{className:`w-[42px] shrink-0 text-right`,children:s?.channel===`email`?`${u}px`:s?.channel.toUpperCase()??``})]})}var jL=`theme.css`,ML=`starter.css`,NL=`samva:brand`,PL=`@import "./${ML}";`,FL=`@import "${NL}";`,IL=/@import(?![\w-])/iy,LL=(e,t)=>{let n=e[t],r=t+1;for(;r<e.length;){let t=e[r];if(t===`\\`)r+=2;else if(t===n||t===`
32
+ `)return r+1;else r+=1}return e.length},RL=(e,t)=>{let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2},zL=e=>{let t=``,n=0;for(;n<e.length;)if(e.startsWith(`/*`,n))n=RL(e,n),t+=` `;else if(e[n]===`"`||e[n]===`'`){let r=LL(e,n);t+=e.slice(n,r),n=r}else t+=e[n],n+=1;return t},BL=e=>{let t=e[0];if(!(t!==`"`&&t!==`'`||e.length<2||e.at(-1)!==t))return e.slice(1,-1)},VL=e=>{let t=zL(e).trim(),n=/^url\(\s*(.*?)\s*\)$/is.exec(t);if(n!==null){let e=n[1]??``;return BL(e)??(/^[^\s"'()]+$/.test(e)?e:void 0)}return BL(t)},HL=e=>{let t=[],n=0,r=0;for(;r<e.length;){let i=e[r];if(i===`/`&&e[r+1]===`*`){r=RL(e,r);continue}if(i===`"`||i===`'`){r=LL(e,r);continue}if(i===`{`)n+=1;else if(i===`}`)n=Math.max(0,n-1);else if(i===`@`&&n===0&&(IL.lastIndex=r,IL.test(e))){let n=IL.lastIndex,i=n;for(;i<e.length&&e[i]!==`;`;)e.startsWith(`/*`,i)?i=RL(e,i):e[i]===`"`||e[i]===`'`?i=LL(e,i):i+=1;let a=Math.min(i+1,e.length);t.push({target:VL(e.slice(n,i)),end:a}),r=a;continue}r+=1}return t},UL=e=>{if(e===NL)return{slug:null};let t=`${NL}/`;if(e===void 0||!e.startsWith(t))return;let n=e.slice(t.length);return n.length===0?void 0:{slug:n}},WL=e=>{let t=e?.replace(/[?#].*$/,``);return t===`./starter.css`||t===`/starter.css`},GL=e=>{for(let{target:t}of HL(e)){let e=UL(t);if(e!==void 0)return e}return null},KL=e=>{let t=e.theme??``;if(GL(t)!==null)return t;let n=HL(t).find(({target:e})=>WL(e));if(n!==void 0)return`${t.slice(0,n.end)}\n${FL}${t.slice(n.end)}`;let r=[...e.starter?[PL]:[],FL].join(`
31
33
  `);return t.length===0?`${r}\n`:`${r}\n${t.startsWith(`
32
34
  `)?``:`
33
- `}${t}`},GL=(e,t)=>{if(e===void 0)return{kind:`pending`};let n=t?.find(({isDefault:e})=>e)??null;if(e===null)return{kind:`none`,defaultBrand:n};if(t===null)return{kind:`pending`};let r=e.slug===null?n:t.find(({slug:t})=>t===e.slug);return r==null?{kind:`missing`,slug:e.slug}:{kind:`brand`,brand:r}},KL=JP(`border-border-subtle bg-surface-inset text-muted-foreground inline-flex h-[22px] min-w-0 max-w-[180px] items-center gap-1 rounded-md border px-2 text-[11.5px] font-medium outline-none`,YP),qL=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function JL({source:e,onUseDefault:t}){let n=$(e=>e.doc?.rev??null),r=$(e=>e.editable&&e.lifecycleCapability?.status===`ready`),i=(0,W.useRef)(e.readTheme);(0,W.useEffect)(()=>{i.current=e.readTheme});let[a,o]=(0,W.useState)(void 0),[s,c]=(0,W.useState)(`idle`);(0,W.useEffect)(()=>{if(n===null)return;let e=!1;return i.current().then(t=>{e||o(UL(t.theme??``))},()=>void 0),()=>{e=!0}},[n]);let l=GL(a,e.brands);if(l.kind===`pending`)return e.status??null;let u;if(l.kind===`brand`){let{name:t,slug:n}=l.brand,r=e.brandLink(n);u=(0,Z.jsxs)(`a`,{href:r.href,"aria-label":`Brand: ${t}`,title:`Open ${t}`,"data-testid":`topbar.brand`,onClick:e=>{r.navigate!==void 0&&qL(e)&&(e.preventDefault(),r.navigate())},className:JP(KL,`hover:bg-muted hover:text-foreground`),children:[(0,Z.jsx)(RP,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:t})]})}else if(l.kind===`missing`)u=(0,Z.jsxs)(`span`,{"data-testid":`topbar.brand-missing`,title:l.slug===null?`This organization has no default brand.`:`This organization has no brand “${l.slug}”.`,className:JP(KL,`text-status-warning`),children:[(0,Z.jsx)(RP,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Brand not found`})]});else{let e=l.defaultBrand,n=r&&t!==void 0&&e!==null?()=>{c(`busy`),t().then(()=>c(`idle`),()=>c(`error`))}:void 0;u=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-testid":`topbar.brand-none`,className:KL,children:[(0,Z.jsx)(RP,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`No brand`})]}),n!==void 0&&e!==null&&(0,Z.jsx)(`button`,{type:`button`,"data-testid":`topbar.brand-use`,onClick:n,disabled:s===`busy`,"aria-busy":s===`busy`,title:`Theme this template with ${e.name}`,className:JP(`text-foreground hover:bg-muted inline-flex h-[22px] max-w-[180px] items-center rounded-md px-1.5 text-[11.5px] font-medium outline-none disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:(0,Z.jsxs)(`span`,{className:`truncate`,children:[`Use `,e.name]})}),s===`error`&&e!==null&&(0,Z.jsxs)(`span`,{role:`alert`,className:`text-status-error truncate text-[11.5px]`,children:[`Couldn’t use `,e.name]})]})}return(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink items-center gap-1`,children:[u,e.status]})}var YL=[];function XL(){let{doc:e,fixtures:t,fixture:n,busy:r,available:i}=$(zO(e=>({doc:e.doc,fixtures:e.doc?.fixtures??YL,fixture:e.doc?.fixture??null,busy:e.fixtureBusy,available:e.fixtureCapability?.status===`ready`}))),{viewFixture:a}=$(e=>e.actions);if(!i)return null;let o=n!==null&&t.length>=2;return e!==null&&!o?null:(0,Z.jsx)(`div`,{className:`w-[116px] shrink-0`,"data-testid":`topbar.fixture-slot`,children:o&&(0,Z.jsxs)(`label`,{className:`text-muted-foreground flex items-center text-[12px]`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:`Fixture`}),(0,Z.jsx)(`select`,{"data-testid":`topbar.fixture`,value:n,disabled:r,onChange:e=>a(e.target.value),title:`Render another declared fixture`,className:JP(`border-border bg-background text-foreground h-[30px] w-full rounded-[7px] border px-2 text-[12px] outline-none`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:t.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))})]})})}function ZL({leading:e,extraActions:t,onBack:n,onUndo:r,onRedo:i,canUndo:a=!1,canRedo:o=!1,onPreview:s,onLifecycle:c,channelSwitcher:l,exportEnabled:u,onExport:d,renameEnabled:f=!0,brand:p,onUseDefaultBrand:m}){let{doc:h,render:g,pendingAuthoredSource:_,lifecycleCapability:v,editable:y,readonlyReason:b,renameActive:x,metadataError:S,layoutMode:C}=$(zO(e=>({doc:e.doc,render:e.render,pendingAuthoredSource:e.pendingAuthoredSource,lifecycleCapability:e.lifecycleCapability,editable:e.editable,readonlyReason:e.readonlyReason,renameActive:e.renameActive,metadataError:e.metadataError,layoutMode:e.layoutMode}))),{rename:w,setRenameActive:T}=$(e=>e.actions),E=(0,W.useRef)(null),D=h?.name??`Untitled template`;(0,W.useEffect)(()=>{if(x&&E.current){E.current.focus();let e=document.createRange();e.selectNodeContents(E.current);let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e)}},[x]);let O=u===!0&&h?.channel===`email`&&g!==null&&_===null,k=C===`compact`||C===`narrow`,A=C===`standard`,j=()=>{O&&h!==null&&g!==null&&(dL(g.html,h.name),d?.())};return(0,Z.jsxs)(`header`,{className:JP(`z-30 flex min-w-0 flex-col border-b border-border bg-background/92 px-3 backdrop-blur-md`,k?`h-[92px]`:`h-12`),children:[(0,Z.jsxs)(`div`,{className:`flex h-12 min-w-0 shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[e!==void 0&&(0,Z.jsx)(`div`,{className:`mr-1 shrink-0`,children:e}),n!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(gI,{title:`Back to templates`,className:`gap-1.5`,onClick:n,testId:`topbar.back`,children:[(0,Z.jsx)(CP,{className:`size-[15px]`}),`Templates`]}),(0,Z.jsx)(`div`,{className:`bg-border mx-1 h-[18px] w-px`})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{ref:E,"data-testid":`topbar.name`,contentEditable:y&&f,suppressContentEditableWarning:!0,spellCheck:!1,title:y&&f?`Click to rename`:b??`This template name is fixed.`,className:JP(`min-w-[128px] max-w-[280px] truncate rounded-md border border-transparent px-[7px] py-[3px] text-[13.5px] font-medium outline-none`,`hover:bg-muted focus-visible:bg-background`,YP),onFocus:()=>{y&&f&&T(!0)},onBlur:e=>{y&&f&&(T(!1),w(e.currentTarget.textContent??``))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur()),e.key===`Escape`&&(e.currentTarget.textContent=D,e.currentTarget.blur())},children:D}),S!==null&&(0,Z.jsx)(`span`,{role:`alert`,className:`text-status-error truncate text-[11.5px]`,children:S}),l===void 0?(0,Z.jsx)(`span`,{className:`border-border-subtle bg-surface-inset text-muted-foreground inline-flex items-center rounded-md border px-2 py-0.5 text-[10.5px] font-medium tracking-[0.04em] uppercase`,children:h?.channel??`Template`}):(0,Z.jsx)(`div`,{className:JP(`min-w-0 shrink-0`,k&&`[&_[data-channel-button]]:px-1.5 [&_[data-channel-label]]:hidden`),children:l}),!y&&h!==null&&(0,Z.jsx)(`span`,{title:b??`This template is read-only.`,"data-testid":`topbar.readonly-badge`,className:`border-border-subtle bg-surface-inset text-muted-foreground inline-flex items-center rounded-md border px-2 py-0.5 text-[10.5px] font-medium`,children:`Read-only`}),p!==void 0&&h?.channel===`email`&&(0,Z.jsx)(JL,{source:p,onUseDefault:m})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!k&&r!==void 0&&(0,Z.jsx)(gI,{title:`Undo`,testId:`topbar.undo`,onClick:r,disabled:!a,className:`h-[30px] px-2.5`,children:`Undo`}),!k&&i!==void 0&&(0,Z.jsx)(gI,{title:`Redo`,testId:`topbar.redo`,onClick:i,disabled:!o,className:`h-[30px] px-2.5`,children:`Redo`}),!k&&(0,Z.jsx)(XL,{}),!k&&(0,Z.jsx)(`div`,{className:`bg-border mx-1 h-[18px] w-px`}),!k&&(0,Z.jsxs)(gI,{title:`Preview template`,testId:`topbar.preview`,onClick:s,className:`h-[30px] px-2.5`,children:[(0,Z.jsx)(kP,{className:`size-[15px]`}),A?null:`Preview`]}),u===!0&&!k&&(0,Z.jsxs)(gI,{title:O?`Export rendered HTML`:`Export waits for the latest render`,testId:`topbar.export`,onClick:j,disabled:!O,className:`h-[30px] px-2.5`,children:[(0,Z.jsx)(DP,{className:`size-[15px]`}),A?null:`Export HTML`]}),!k&&t,!k&&y&&v!==void 0&&(0,Z.jsx)(`button`,{type:`button`,onClick:c,"data-testid":`topbar.publish`,title:v.status===`locked`?v.upsell.reason:`Publish and view history`,className:JP(XP,`ml-0.5 h-[30px] px-3`),children:`Publish`})]})]}),k&&(0,Z.jsxs)(`div`,{className:`samva-editor-scroll border-border-subtle flex h-11 min-w-0 items-center gap-1 overflow-x-auto border-t`,children:[t,r!==void 0&&(0,Z.jsx)(gI,{title:`Undo`,testId:`topbar.undo`,onClick:r,disabled:!a,className:`h-10 shrink-0 px-2`,children:`Undo`}),i!==void 0&&(0,Z.jsx)(gI,{title:`Redo`,testId:`topbar.redo`,onClick:i,disabled:!o,className:`h-10 shrink-0 px-2`,children:`Redo`}),(0,Z.jsx)(XL,{}),(0,Z.jsxs)(gI,{title:`Preview template`,testId:`topbar.preview`,onClick:s,className:`h-10 shrink-0 px-2`,children:[(0,Z.jsx)(kP,{className:`size-[15px]`}),`Preview`]}),u===!0&&(0,Z.jsxs)(gI,{title:O?`Export rendered HTML`:`Export waits for the latest render`,testId:`topbar.export`,onClick:j,disabled:!O,className:`h-10 shrink-0 px-2`,children:[(0,Z.jsx)(DP,{className:`size-[15px]`}),`Export`]}),y&&v!==void 0&&(0,Z.jsx)(`button`,{type:`button`,onClick:c,"data-testid":`topbar.publish`,title:v.status===`locked`?v.upsell.reason:`Publish and view history`,className:JP(XP,`h-10 shrink-0 px-2.5`),children:`Publish`})]})]})}var QL=[],$L=e=>e>=1280?`wide`:e>=980?`standard`:e>=720?`compact`:`narrow`;function eR(){let e=$(e=>e.conflict),{reload:t}=$(e=>e.actions);return!$(e=>e.editable)||!e?null:(0,Z.jsxs)(`div`,{className:`border-border bg-surface-elevated text-foreground absolute inset-x-0 top-3 z-30 mx-auto flex w-fit items-center gap-3 rounded-lg border px-3.5 py-2 text-[13px] shadow-[var(--shadow-md)]`,children:[(0,Z.jsx)(`span`,{children:`Document changed elsewhere — your recent edits weren’t saved.`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`bg-primary text-primary-foreground rounded-md px-2.5 py-1 font-medium transition-opacity hover:opacity-90`,children:`Reload`})]})}function tR(){let e=$(e=>e.storageError),t=$(e=>e.conflict),{retrySave:n}=$(e=>e.actions);return!$(e=>e.editable)||e===null||t?null:(0,Z.jsxs)(`div`,{className:`border-status-warning/45 bg-surface-elevated text-foreground absolute inset-x-0 top-3 z-30 mx-auto flex w-fit items-center gap-3 rounded-lg border px-3.5 py-2 text-[13px] shadow-[var(--shadow-md)]`,children:[(0,Z.jsxs)(`span`,{children:[e,` Your work is kept here; export a copy or retry.`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`border-border hover:bg-muted rounded-md border px-2.5 py-1 font-medium transition-colors`,children:`Retry`})]})}function nR(){let e=$(e=>e.doc);return e===null||e.channel===`email`?(0,Z.jsx)(sL,{}):e.channel===`sms`?(0,Z.jsx)(OF,{}):(0,Z.jsx)(zF,{})}function rR({height:e=`100dvh`,contributions:t=QL,brand:n,onBack:r,exportable:i,renameEnabled:a,onLockedLifecycle:o}){let s=$(e=>e.leftCollapsed),c=$(e=>e.rightCollapsed),l=$(e=>e.layoutMode),u=$(e=>e.doc?.rev??null),d=$(e=>e.undoHistory.length),f=$(e=>e.redoHistory.length),p=$(e=>e.sourceEditable),m=$(e=>e.doc),h=$(e=>e.render),g=$(e=>e.pendingAuthoredSource),_=$(e=>e.lifecycleBusy),v=$(e=>e.conflict),y=$(e=>e.storageError),b=(0,W.useMemo)(()=>eF(t),[t]),x=b.one(`frame.start`),S=b.one(`statusbar.headline`),C=b.one(`rail.assistant`)!==void 0,{flushSaves:w,beginLifecycle:T,endLifecycle:E,adoptLifecycleSnapshot:D,toggleLeft:O,toggleRight:k,setLayoutMode:A,undo:j,redo:M}=$(e=>e.actions),N=$(e=>e.versionsCapability),P=$(e=>e.telemetry),F=N?.status===`ready`?N.api:void 0,I=(0,W.useMemo)(()=>F===void 0?void 0:e=>F.save(e),[F]),L=(0,W.useMemo)(()=>F===void 0?void 0:()=>F.savedRevision(),[F]),R=()=>P?.({name:`preview`}),ee=()=>P?.({name:`export`}),[z,te]=(0,W.useState)(!1),[ne,re]=(0,W.useState)(!1),[B,ie]=(0,W.useState)(`idle`),[ae,oe]=(0,W.useState)(null),[se,ce]=(0,W.useState)(null),le=bN();(0,W.useEffect)(()=>{if(L===void 0||u===null)return;let e=!0;return L().then(t=>{e&&ce(t===u?t:null)}).catch(()=>{e&&ce(null)}),()=>{e=!1}},[u,L]);let V=(0,W.useRef)(null),H=(0,W.useRef)(()=>{}),ue=(0,W.useRef)(null),de=(0,W.useRef)(null),fe=i===!0&&m?.channel===`email`&&h!==null&&g===null,U=()=>{fe&&m!==null&&h!==null&&(dL(h.html,m.name),ee?.())},pe=()=>{if(I===void 0)return Promise.resolve();if(V.current!==null)return V.current;if(!T())return Promise.resolve();let e=()=>{},t=new Promise(t=>{e=t});return V.current=t,ie(`saving`),le.getState().actions.flushSaves().then(async e=>{let t=le.getState().doc,n=await I(e),r=le.getState().doc;t!==null&&(r?.rev===e||r?.rev===n)&&r.origin.authoredSource===t.origin.authoredSource&&le.getState().actions.adoptLifecycleSnapshot({rev:n,authoredSource:t.origin.authoredSource}),oe(n),ie(`idle`)}).catch(()=>ie(`error`)).finally(()=>{E(),V.current===t&&(V.current=null),e()}),t};(0,W.useEffect)(()=>{H.current=pe});let me=n===void 0||I===void 0?void 0:async()=>{let e=le.getState().lifecycleCapability;if(e?.status!==`ready`)return;let t=await le.getState().actions.flushSaves(),r=await n.readTheme(),i=WL(r);i!==r.theme&&await e.api.updateFile({path:kL,baseRev:t,content:i}),await pe()},he=`idle`;B===`saving`?he=`saving`:B===`error`?he=`error`:u!==null&&(ae===u||se===u)&&g===null&&!v&&y===null&&(he=`saved`);let ge;I!==void 0&&(ge=`Unsaved changes`,he===`saving`?ge=`Saving version…`:he===`saved`?ge=`Saved version`:he===`error`&&(ge=`Couldn’t save version`));let _e={flushSaves:w,beginLifecycle:T,endLifecycle:E,adoptLifecycleSnapshot:D,undo:j,redo:M,canUndo:p&&d>0,canRedo:p&&f>0,preview:()=>{te(!0),R?.()},exportHtml:U,canExport:fe},ve=b.all(`toolbar.leading`).map(e=>(0,Z.jsx)(W.Fragment,{children:e.render()},e.id)),ye=b.all(`toolbar.actions`).map(e=>(0,Z.jsx)(W.Fragment,{children:e.render(_e)},e.id)),be=b.one(`document.switcher`)?.render(_e);(0,W.useEffect)(()=>{if(I===void 0)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&e.target instanceof HTMLElement&&e.target.closest(`[data-samva-editor-theme]`)!==null&&e.target.closest(`[role="menu"], [role="dialog"], [data-base-ui-portal]`)===null&&(e.preventDefault(),H.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[I]),(0,W.useLayoutEffect)(()=>{let e=ue.current;if(e===null||typeof ResizeObserver>`u`)return;let t,n=e=>{let n=$L(e);n!==t&&(t=n,A(n))};n(e.getBoundingClientRect().width);let r=new ResizeObserver(([e])=>{e!==void 0&&n(e.contentRect.width)});return r.observe(e),()=>r.disconnect()},[A]);let xe=(l===`compact`||l===`narrow`)&&(!s||!c);return(0,W.useEffect)(()=>{if(!xe)return;let e=e=>{e.key===`Escape`&&(s||O(),c||k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,xe,c,O,k]),(0,Z.jsx)(nF,{value:b,children:(0,Z.jsx)(oF,{value:{exportHtml:U,canExport:fe,saveVersionStatus:I===void 0?`unavailable`:he},children:(0,Z.jsx)(CL,{container:de,children:(0,Z.jsxs)(`div`,{ref:ue,className:`samva-editor-frame flex`,style:{height:e},children:[x?.render(),(0,Z.jsxs)(`div`,{"data-samva-editor-theme":`host`,"data-layout":l,inert:_,"aria-busy":_,className:`samva-editor-shell grid min-w-0 flex-1 grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden`,children:[(0,Z.jsx)(ZL,{leading:ve.length===0?void 0:ve,extraActions:ye.length===0?void 0:ye,onBack:x===void 0?r:void 0,onPreview:()=>{te(!0),R?.()},onLifecycle:()=>re(!0),onUndo:j,onRedo:M,canUndo:p&&d>0,canRedo:p&&f>0,channelSwitcher:be,exportEnabled:i,renameEnabled:a,onExport:ee,brand:n,onUseDefaultBrand:me}),(0,Z.jsxs)(`div`,{className:`samva-editor-body relative flex min-h-0 min-w-0 overflow-hidden`,children:[xe&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close editor panel`,className:`bg-background/45 absolute inset-0 z-30 cursor-default backdrop-blur-[1px]`,onClick:()=>{s||O(),c||k()}}),s&&!C&&(0,Z.jsxs)(ET,{children:[(0,Z.jsx)(PT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Show layers and blocks`,"data-testid":`shell.show-left`,onClick:O,className:`border-border bg-background/92 text-muted-foreground hover:bg-muted hover:text-foreground absolute top-3 left-3 z-20 rounded-md border p-1.5 shadow-[var(--shadow-md)] backdrop-blur-md transition-colors`}),children:(0,Z.jsx)(BP,{className:`size-[15px]`})}),(0,Z.jsx)(RT,{container:de,children:(0,Z.jsx)(sE,{side:`right`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(cE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Show layers and blocks`})})})]}),c&&!C&&(0,Z.jsxs)(ET,{children:[(0,Z.jsx)(PT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Show inspector`,"data-testid":`shell.show-right`,onClick:k,className:`border-border bg-background/92 text-muted-foreground hover:bg-muted hover:text-foreground absolute top-3 right-3 z-20 rounded-md border p-1.5 shadow-[var(--shadow-md)] backdrop-blur-md transition-colors`}),children:(0,Z.jsx)(HP,{className:`size-[15px]`})}),(0,Z.jsx)(RT,{container:de,children:(0,Z.jsx)(sE,{side:`left`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(cE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Show inspector`})})})]}),(0,Z.jsx)(nR,{}),(0,Z.jsx)(eR,{}),(0,Z.jsx)(tR,{})]}),(0,Z.jsx)(OL,{saveVersionStatus:S!==void 0&&!S.saveVersion?void 0:ge,saveVersionState:I===void 0?void 0:he,onSaveVersion:S!==void 0&&!S.saveVersion||I===void 0?void 0:pe,saveVersionBusy:he===`saving`,saveVersionBlocked:_,guestHeadline:S?.headline})]}),(0,Z.jsx)(EL,{open:z,onClose:()=>te(!1)}),(0,Z.jsx)(xL,{open:ne,onClose:()=>re(!1),onLockedAction:o}),(0,Z.jsx)(`div`,{ref:de,"data-samva-editor-portal-root":!0,className:`samva-editor-shell`})]})})})})}function iR({name:e,className:t}){let n=_N()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})}function aR({label:e,icon:t,title:n,upsell:r,onAction:i,testId:a}){let[o,s]=(0,W.useState)(!1),c=dF();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(gI,{title:e,help:r.reason,testId:a,onClick:()=>s(!0),className:`h-[30px] px-2.5`,children:[t,e]}),(0,Z.jsx)(Hj,{open:o,onOpenChange:s,swipeDirection:`right`,children:(0,Z.jsxs)(zj,{container:c,children:[(0,Z.jsx)(hj,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(OM,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(Rj,{className:`samva-editor-shell border-border bg-background pointer-events-auto flex h-full w-[420px] max-w-[92vw] flex-col border-l shadow-[var(--shadow-floating)] outline-none`,children:[(0,Z.jsx)(vj,{className:`sr-only`,children:r.reason}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-4 pb-3`,children:[(0,Z.jsx)(dM,{className:`text-[15px] font-semibold`,children:n}),(0,Z.jsx)(gj,{type:`button`,"aria-label":`Close ${e.toLowerCase()} panel`,"data-testid":a===void 0?void 0:`${a}.close`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1.5`,children:(0,Z.jsx)(qP,{className:`size-[15px]`})})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-start gap-4 px-5 pt-6 pb-8`,children:[(0,Z.jsx)(`div`,{className:`border-border-subtle bg-surface-inset text-muted-foreground rounded-lg border px-3.5 py-3 text-[13px]`,children:r.reason}),(0,Z.jsx)(`a`,{href:r.cta.href,onClick:e=>{i!==void 0&&(e.preventDefault(),i())},"data-testid":a===void 0?void 0:`${a}.cta`,className:`bg-primary text-primary-foreground inline-flex h-9 items-center rounded-[7px] px-4 font-medium transition-opacity hover:opacity-90`,children:r.cta.label})]})]})})]})})]})}var oR=`2026-10-03.1`,sR=class extends Hn(`DocumentConflict`){},cR=class extends Hn(`DocumentUnavailable`){};Hn(`LifecycleUnavailable`),Hn(`ProjectFileExists`);var lR=(e,t)=>{let n=new URL(`api/${e}`,window.location.href);for(let[e,r]of Object.entries(t))n.searchParams.set(e,r);return n.toString()},uR=e=>e.fixture,dR=(e,t,n,r)=>({rev:t,origin:n,...r===void 0?{}:{authoredSource:r},...e}),fR=(e,t,n)=>ca(function*(){let r=yield*Fa(),i=new EventSource(lR(`events`,{id:e,client:t}));yield*ha(()=>aa(()=>i.close())),i.addEventListener(`samva:change`,t=>{let i=JSON.parse(t.data);i.id===e&&(n.rev=i.rev,n.fixture=uR(i),i.authoredSource!==void 0&&(n.authoredSource=i.authoredSource),Ia(r,dR(i,i.rev,i.origin,i.authoredSource)))});let a=()=>fetch(lR(`document`,{id:e,client:t})).then(e=>e.ok?e.json():void 0).then(e=>{if(e===void 0)return;let t=e.origin.authoredSource;(e.rev!==n.rev||t!==n.authoredSource||uR(e)!==n.fixture)&&(n.rev=e.rev,n.authoredSource=t,n.fixture=uR(e),Ia(r,dR(e,e.rev,`external`,t)))}).catch(()=>{}),o=!1,s;i.addEventListener(`open`,()=>{if(!o){o=!0,s?.(oa);return}a()}),i.addEventListener(`error`,()=>{!o&&i.readyState!==EventSource.OPEN&&s?.(new cR({reason:`editor event stream failed to open`}))}),yield*sa(e=>{if(i.readyState===EventSource.OPEN)return o=!0,e(oa);s=e});let c=yield*na({try:()=>fetch(lR(`document`,{id:e,client:t})),catch:e=>new cR({reason:String(e)})});if(!c.ok)return yield*new cR({reason:`open failed (${c.status})`});let l=yield*na({try:()=>c.json(),catch:e=>new cR({reason:String(e)})});return n.rev=l.rev,n.authoredSource=l.origin.authoredSource,n.fixture=uR(l),{initial:l,changes:oo(r)}}),pR=(e,t)=>({view:n=>ca(function*(){let r=yield*na({try:()=>fetch(lR(`fixture`,{id:e,client:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fixture:n})}),catch:e=>new cR({reason:String(e)})});if(r.ok)return;let i=`view fixture failed (${r.status})`;return yield*new cR({reason:yield*na({try:()=>r.json(),catch:()=>new cR({reason:i})}).pipe(fa(e=>e.error??i))})})}),mR=(e,t)=>({save:n=>ca(function*(){if(n.kind!==`authoredSource`)return yield*new cR({reason:`Local metadata is declared in source.`});let r=yield*na({try:()=>fetch(lR(`document`,{id:e,client:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),catch:e=>new cR({reason:String(e)})}),i=yield*na({try:()=>r.json(),catch:e=>new cR({reason:String(e)})});return r.status===409?yield*new sR({expectedRev:n.baseRev,actualRev:i.actualRev??n.baseRev}):!r.ok||i.rev===void 0?yield*new cR({reason:i.error??`Local source save failed.`}):{rev:i.rev}})}),hR=({id:e})=>{let t=crypto.randomUUID();return{contractVersion:oR,access:`editable`,sourceAccess:`editable`,metadataAccess:`readonly`,writer:mR(e,t),document:{open:fR(e,t,{rev:``})},fixtures:{status:`ready`,api:pR(e,t)}}},gR=e=>new URL(`api/${e}`,window.location.href).toString(),_R=async e=>{let t=await fetch(gR(e));if(!t.ok)throw Error(`${e} failed (${t.status})`);return t.json()},vR=()=>{let[e,t]=(0,W.useState)(()=>typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches);return(0,W.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e)},[e]),()=>t(e=>!e)};function yR({onBack:e,onToggleTheme:t}){return(0,Z.jsxs)(`nav`,{"aria-label":`Samva editor`,className:`border-border bg-background z-30 flex w-12 flex-none flex-col items-center gap-1 border-r py-3`,children:[(0,Z.jsx)(`span`,{className:`bg-primary text-primary-foreground mb-2 grid size-7 place-items-center rounded-lg text-[13px] font-bold`,children:`S`}),e?(0,Z.jsx)(`button`,{type:`button`,title:`Back to templates`,onClick:e,className:`text-muted-foreground hover:bg-muted hover:text-foreground grid size-8 place-items-center rounded-lg transition-colors`,children:(0,Z.jsx)(iR,{name:`arrowLeft`,className:`size-[16px]`})}):null,(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,title:`Toggle theme`,onClick:t,className:`text-muted-foreground hover:bg-muted hover:text-foreground grid size-8 place-items-center rounded-lg transition-colors dark:hidden`,children:(0,Z.jsx)(iR,{name:`moon`,className:`size-[16px]`})}),(0,Z.jsx)(`button`,{type:`button`,title:`Toggle theme`,onClick:t,className:`text-muted-foreground hover:bg-muted hover:text-foreground hidden size-8 place-items-center rounded-lg transition-colors dark:grid`,children:(0,Z.jsx)(iR,{name:`sun`,className:`size-[16px]`})})]})}var bR={authenticatedLabel:`Authenticated`,authenticatedTitle:`The host provides authenticated capabilities.`};function xR({template:e,authenticated:t,editorAffordances:n,onBack:r,onToggleTheme:i}){let a=n.publishingInstructions,o=(0,W.useMemo)(()=>fo(hR({id:e.id})),[e.id]);return(0,Z.jsx)(gP,{host:o,children:(0,Z.jsx)(`div`,{className:`relative h-dvh`,children:(0,Z.jsx)(rR,{contributions:[{slot:`frame.start`,id:`project-rail`,render:()=>(0,Z.jsx)(yR,{onBack:r,onToggleTheme:i})},...t&&a!==void 0?[{slot:`toolbar.actions`,id:`send`,render:()=>(0,Z.jsx)(aR,{label:`Send`,title:`Send “${e.name}”`,upsell:a,testId:`vite-editor.send`})}]:[]],onBack:r,renameEnabled:!1})})},`${e.id}:${e.channel}`)}var SR={email:{icon:`envelope`,label:`Email`,className:`bg-sel-soft text-accent-email`},sms:{icon:`message`,label:`SMS`,className:`bg-muted text-primary`},whatsapp:{icon:`chatBubble`,label:`WhatsApp`,className:`bg-status-success/10 text-status-success`}};function CR({catalog:e,authenticated:t,editorAffordances:n,onOpen:r,onToggleTheme:i}){return(0,Z.jsxs)(`div`,{className:`flex h-dvh`,children:[(0,Z.jsx)(yR,{onToggleTheme:i}),(0,Z.jsx)(`div`,{className:`bg-surface-inset min-w-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`mx-auto max-w-[720px] px-6 py-16`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-foreground text-lg font-semibold`,children:`Templates`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-[13px]`,children:`Preview your templates and fixtures. Source edits save to your project.`})]}),(0,Z.jsx)(`span`,{className:t?`bg-status-success/12 text-status-success rounded-full px-2.5 py-1 text-[11px] font-medium`:`bg-muted text-muted-foreground rounded-full px-2.5 py-1 text-[11px] font-medium`,title:t?n.authenticatedTitle:`Local editing only.`,children:t?n.authenticatedLabel:`Local only`})]}),e.diagnostics.length>0?(0,Z.jsx)(`section`,{"aria-label":`Catalog diagnostics`,className:`border-border bg-surface-elevated mt-6 overflow-hidden rounded-xl border`,children:e.diagnostics.map((e,t)=>(0,Z.jsxs)(`div`,{className:`px-4 py-3 text-[12px]`+(t>0?` border-border-subtle border-t`:``),children:[(0,Z.jsxs)(`p`,{className:e.severity===`error`?`text-status-error`:`text-status-warning`,children:[e.file,` · `,e.code]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.message})]},`${e.file}:${e.code}:${t}`))}):null,(0,Z.jsxs)(`ul`,{className:`border-border bg-surface-elevated mt-8 overflow-hidden rounded-xl border shadow-md`,children:[e.templates.length===0?(0,Z.jsxs)(`li`,{className:`text-muted-foreground px-4 py-10 text-center text-[13px]`,children:[`No valid templates found. Add a `,(0,Z.jsx)(`code`,{className:`text-foreground`,children:`.tsx`}),` file with a Samva template as its default export.`]}):null,e.templates.map((e,t)=>{let n=SR[e.channel];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"data-testid":`template-card.${e.id}`,className:`hover:bg-muted flex w-full items-center gap-3 px-4 py-3 text-left transition-colors`+(t>0?` border-border-subtle border-t`:``),children:[(0,Z.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-lg ${n.className}`,children:(0,Z.jsx)(iR,{name:n.icon,className:`size-[16px]`})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-foreground block truncate text-[13px] font-medium`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground block truncate text-[12px]`,children:e.id})]}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground text-right text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`block`,children:n.label}),(0,Z.jsx)(`span`,{className:`block`,children:`Editable source`})]})]})},e.id)})]})]})})]})}function wR(){let e=vR(),[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(bR),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=!0,t=()=>_R(`templates`).then(t=>{e&&(o(t),c(null))});Promise.all([_R(`capabilities`).then(t=>{e&&(n(!!t.authenticated),i(t.editorAffordances??bR))}),t()]).catch(t=>{e&&c(String(t))});let r=new EventSource(gR(`catalog-events`));return r.addEventListener(`samva:catalog`,()=>{t().catch(t=>{e&&c(String(t))})}),()=>{e=!1,r.close()}},[]);let d=a?.templates.find(e=>e.id===l)??null;return l!==null&&a!==null&&d===null&&u(null),s===null?a===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid h-dvh place-items-center text-[13px]`,children:`Loading templates…`}):d===null?(0,Z.jsx)(CR,{catalog:a,authenticated:t,editorAffordances:r,onOpen:e=>u(e.id),onToggleTheme:e}):(0,Z.jsx)(xR,{template:d,authenticated:t,editorAffordances:r,onBack:()=>u(null),onToggleTheme:e}):(0,Z.jsxs)(`div`,{className:`text-status-error grid h-dvh place-items-center px-6 text-center text-[13px]`,children:[`Couldn’t reach the Samva editor dev server: `,s]})}(0,co.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(W.StrictMode,{children:(0,Z.jsx)(wR,{})}));
35
+ `}${t}`},qL=(e,t)=>{if(e===void 0)return{kind:`pending`};let n=t?.find(({isDefault:e})=>e)??null;if(e===null)return{kind:`none`,defaultBrand:n};if(t===null)return{kind:`pending`};let r=e.slug===null?n:t.find(({slug:t})=>t===e.slug);return r==null?{kind:`missing`,slug:e.slug}:{kind:`brand`,brand:r}},JL=XP(`border-border-subtle bg-surface-inset text-muted-foreground inline-flex h-[22px] min-w-0 max-w-[180px] items-center gap-1 rounded-md border px-2 text-[11.5px] font-medium outline-none`,ZP),YL=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function XL({source:e,onUseDefault:t}){let n=$(e=>e.doc?.rev??null),r=$(e=>e.editable&&e.lifecycleCapability?.status===`ready`),i=(0,W.useRef)(e.readTheme);(0,W.useEffect)(()=>{i.current=e.readTheme});let[a,o]=(0,W.useState)(void 0),[s,c]=(0,W.useState)(`idle`);(0,W.useEffect)(()=>{if(n===null)return;let e=!1;return i.current().then(t=>{e||o(GL(t.theme??``))},()=>void 0),()=>{e=!0}},[n]);let l=qL(a,e.brands);if(l.kind===`pending`)return e.status??null;let u;if(l.kind===`brand`){let{name:t,slug:n}=l.brand,r=e.brandLink(n);u=(0,Z.jsxs)(`a`,{href:r.href,"aria-label":`Brand: ${t}`,title:`Open ${t}`,"data-testid":`topbar.brand`,onClick:e=>{r.navigate!==void 0&&YL(e)&&(e.preventDefault(),r.navigate())},className:XP(JL,`hover:bg-muted hover:text-foreground`),children:[(0,Z.jsx)(BP,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:t})]})}else if(l.kind===`missing`)u=(0,Z.jsxs)(`span`,{"data-testid":`topbar.brand-missing`,title:l.slug===null?`This organization has no default brand.`:`This organization has no brand “${l.slug}”.`,className:XP(JL,`text-status-warning`),children:[(0,Z.jsx)(BP,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Brand not found`})]});else{let e=l.defaultBrand,n=r&&t!==void 0&&e!==null?()=>{c(`busy`),t().then(()=>c(`idle`),()=>c(`error`))}:void 0;u=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-testid":`topbar.brand-none`,className:JL,children:[(0,Z.jsx)(BP,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`No brand`})]}),n!==void 0&&e!==null&&(0,Z.jsx)(`button`,{type:`button`,"data-testid":`topbar.brand-use`,onClick:n,disabled:s===`busy`,"aria-busy":s===`busy`,title:`Theme this template with ${e.name}`,className:XP(`text-foreground hover:bg-muted inline-flex h-[22px] max-w-[180px] items-center rounded-md px-1.5 text-[11.5px] font-medium outline-none disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:(0,Z.jsxs)(`span`,{className:`truncate`,children:[`Use `,e.name]})}),s===`error`&&e!==null&&(0,Z.jsxs)(`span`,{role:`alert`,className:`text-status-error truncate text-[11.5px]`,children:[`Couldn’t use `,e.name]})]})}return(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink items-center gap-1`,children:[u,e.status]})}var ZL=[];function QL(){let{doc:e,fixtures:t,fixture:n,busy:r,available:i}=$(BO(e=>({doc:e.doc,fixtures:e.doc?.fixtures??ZL,fixture:e.doc?.fixture??null,busy:e.fixtureBusy,available:e.fixtureCapability?.status===`ready`}))),{viewFixture:a}=$(e=>e.actions);if(!i)return null;let o=n!==null&&t.length>=2;return e!==null&&!o?null:(0,Z.jsx)(`div`,{className:`w-[116px] shrink-0`,"data-testid":`topbar.fixture-slot`,children:o&&(0,Z.jsxs)(`label`,{className:`text-muted-foreground flex items-center text-[12px]`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:`Fixture`}),(0,Z.jsx)(`select`,{"data-testid":`topbar.fixture`,value:n,disabled:r,onChange:e=>a(e.target.value),title:`Render another declared fixture`,className:XP(`border-border bg-background text-foreground h-[30px] w-full rounded-[7px] border px-2 text-[12px] outline-none`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:t.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))})]})})}function $L({leading:e,extraActions:t,onBack:n,onUndo:r,onRedo:i,canUndo:a=!1,canRedo:o=!1,onPreview:s,onLifecycle:c,channelSwitcher:l,exportEnabled:u,onExport:d,renameEnabled:f=!0,brand:p,onUseDefaultBrand:m}){let{doc:h,render:g,pendingAuthoredSource:_,lifecycleCapability:v,editable:y,readonlyReason:b,renameActive:x,metadataError:S,layoutMode:C}=$(BO(e=>({doc:e.doc,render:e.render,pendingAuthoredSource:e.pendingAuthoredSource,lifecycleCapability:e.lifecycleCapability,editable:e.editable,readonlyReason:e.readonlyReason,renameActive:e.renameActive,metadataError:e.metadataError,layoutMode:e.layoutMode}))),{rename:w,setRenameActive:T}=$(e=>e.actions),E=(0,W.useRef)(null),D=h?.name??`Untitled template`;(0,W.useEffect)(()=>{if(x&&E.current){E.current.focus();let e=document.createRange();e.selectNodeContents(E.current);let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e)}},[x]);let O=u===!0&&h?.channel===`email`&&g!==null&&_===null,k=C===`compact`||C===`narrow`,A=C===`standard`,j=()=>{O&&h!==null&&g!==null&&(pL(g.html,h.name),d?.())};return(0,Z.jsxs)(`header`,{className:XP(`z-30 flex min-w-0 flex-col border-b border-border bg-background/92 px-3 backdrop-blur-md`,k?`h-[92px]`:`h-12`),children:[(0,Z.jsxs)(`div`,{className:`flex h-12 min-w-0 shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[e!==void 0&&(0,Z.jsx)(`div`,{className:`mr-1 shrink-0`,children:e}),n!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(vI,{title:`Back to templates`,className:`gap-1.5`,onClick:n,testId:`topbar.back`,children:[(0,Z.jsx)(TP,{className:`size-[15px]`}),`Templates`]}),(0,Z.jsx)(`div`,{className:`bg-border mx-1 h-[18px] w-px`})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{ref:E,"data-testid":`topbar.name`,contentEditable:y&&f,suppressContentEditableWarning:!0,spellCheck:!1,title:y&&f?`Click to rename`:b??`This template name is fixed.`,className:XP(`min-w-[128px] max-w-[280px] truncate rounded-md border border-transparent px-[7px] py-[3px] text-[13.5px] font-medium outline-none`,`hover:bg-muted focus-visible:bg-background`,ZP),onFocus:()=>{y&&f&&T(!0)},onBlur:e=>{y&&f&&(T(!1),w(e.currentTarget.textContent??``))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur()),e.key===`Escape`&&(e.currentTarget.textContent=D,e.currentTarget.blur())},children:D}),S!==null&&(0,Z.jsx)(`span`,{role:`alert`,className:`text-status-error truncate text-[11.5px]`,children:S}),l===void 0?(0,Z.jsx)(`span`,{className:`border-border-subtle bg-surface-inset text-muted-foreground inline-flex items-center rounded-md border px-2 py-0.5 text-[10.5px] font-medium tracking-[0.04em] uppercase`,children:h?.channel??`Template`}):(0,Z.jsx)(`div`,{className:XP(`min-w-0 shrink-0`,k&&`[&_[data-channel-button]]:px-1.5 [&_[data-channel-label]]:hidden`),children:l}),!y&&h!==null&&(0,Z.jsx)(`span`,{title:b??`This template is read-only.`,"data-testid":`topbar.readonly-badge`,className:`border-border-subtle bg-surface-inset text-muted-foreground inline-flex items-center rounded-md border px-2 py-0.5 text-[10.5px] font-medium`,children:`Read-only`}),p!==void 0&&h?.channel===`email`&&(0,Z.jsx)(XL,{source:p,onUseDefault:m})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!k&&r!==void 0&&(0,Z.jsx)(vI,{title:`Undo`,testId:`topbar.undo`,onClick:r,disabled:!a,className:`h-[30px] px-2.5`,children:`Undo`}),!k&&i!==void 0&&(0,Z.jsx)(vI,{title:`Redo`,testId:`topbar.redo`,onClick:i,disabled:!o,className:`h-[30px] px-2.5`,children:`Redo`}),!k&&(0,Z.jsx)(QL,{}),!k&&(0,Z.jsx)(`div`,{className:`bg-border mx-1 h-[18px] w-px`}),!k&&(0,Z.jsxs)(vI,{title:`Preview template`,testId:`topbar.preview`,onClick:s,className:`h-[30px] px-2.5`,children:[(0,Z.jsx)(jP,{className:`size-[15px]`}),A?null:`Preview`]}),u===!0&&!k&&(0,Z.jsxs)(vI,{title:O?`Export rendered HTML`:`Export waits for the latest render`,testId:`topbar.export`,onClick:j,disabled:!O,className:`h-[30px] px-2.5`,children:[(0,Z.jsx)(kP,{className:`size-[15px]`}),A?null:`Export HTML`]}),!k&&t,!k&&y&&v!==void 0&&(0,Z.jsx)(`button`,{type:`button`,onClick:c,"data-testid":`topbar.publish`,title:v.status===`locked`?v.upsell.reason:`Publish and view history`,className:XP(QP,`ml-0.5 h-[30px] px-3`),children:`Publish`})]})]}),k&&(0,Z.jsxs)(`div`,{className:`samva-editor-scroll border-border-subtle flex h-11 min-w-0 items-center gap-1 overflow-x-auto border-t`,children:[t,r!==void 0&&(0,Z.jsx)(vI,{title:`Undo`,testId:`topbar.undo`,onClick:r,disabled:!a,className:`h-10 shrink-0 px-2`,children:`Undo`}),i!==void 0&&(0,Z.jsx)(vI,{title:`Redo`,testId:`topbar.redo`,onClick:i,disabled:!o,className:`h-10 shrink-0 px-2`,children:`Redo`}),(0,Z.jsx)(QL,{}),(0,Z.jsxs)(vI,{title:`Preview template`,testId:`topbar.preview`,onClick:s,className:`h-10 shrink-0 px-2`,children:[(0,Z.jsx)(jP,{className:`size-[15px]`}),`Preview`]}),u===!0&&(0,Z.jsxs)(vI,{title:O?`Export rendered HTML`:`Export waits for the latest render`,testId:`topbar.export`,onClick:j,disabled:!O,className:`h-10 shrink-0 px-2`,children:[(0,Z.jsx)(kP,{className:`size-[15px]`}),`Export`]}),y&&v!==void 0&&(0,Z.jsx)(`button`,{type:`button`,onClick:c,"data-testid":`topbar.publish`,title:v.status===`locked`?v.upsell.reason:`Publish and view history`,className:XP(QP,`h-10 shrink-0 px-2.5`),children:`Publish`})]})]})}var eR=[],tR=e=>e>=1280?`wide`:e>=980?`standard`:e>=720?`compact`:`narrow`;function nR(){let e=$(e=>e.conflict),{reload:t}=$(e=>e.actions);return!$(e=>e.editable)||!e?null:(0,Z.jsxs)(`div`,{className:`border-border bg-surface-elevated text-foreground absolute inset-x-0 top-3 z-30 mx-auto flex w-fit items-center gap-3 rounded-lg border px-3.5 py-2 text-[13px] shadow-[var(--shadow-md)]`,children:[(0,Z.jsx)(`span`,{children:`Document changed elsewhere — your recent edits weren’t saved.`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`bg-primary text-primary-foreground rounded-md px-2.5 py-1 font-medium transition-opacity hover:opacity-90`,children:`Reload`})]})}function rR(){let e=$(e=>e.storageError),t=$(e=>e.conflict),{retrySave:n}=$(e=>e.actions);return!$(e=>e.editable)||e===null||t?null:(0,Z.jsxs)(`div`,{className:`border-status-warning/45 bg-surface-elevated text-foreground absolute inset-x-0 top-3 z-30 mx-auto flex w-fit items-center gap-3 rounded-lg border px-3.5 py-2 text-[13px] shadow-[var(--shadow-md)]`,children:[(0,Z.jsxs)(`span`,{children:[e,` Your work is kept here; export a copy or retry.`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`border-border hover:bg-muted rounded-md border px-2.5 py-1 font-medium transition-colors`,children:`Retry`})]})}function iR(){let e=$(e=>e.doc);return e===null||e.channel===`email`?(0,Z.jsx)(lL,{}):e.channel===`sms`?(0,Z.jsx)(AF,{}):(0,Z.jsx)(VF,{})}function aR({height:e=`100dvh`,contributions:t=eR,brand:n,onBack:r,exportable:i,renameEnabled:a,onLockedLifecycle:o}){let s=$(e=>e.leftCollapsed),c=$(e=>e.rightCollapsed),l=$(e=>e.layoutMode),u=$(e=>e.doc?.rev??null),d=$(e=>e.undoHistory.length),f=$(e=>e.redoHistory.length),p=$(e=>e.sourceEditable),m=$(e=>e.doc),h=$(e=>e.render),g=$(e=>e.pendingAuthoredSource),_=$(e=>e.lifecycleBusy),v=$(e=>e.conflict),y=$(e=>e.storageError),b=(0,W.useMemo)(()=>nF(t),[t]),x=b.one(`frame.start`),S=b.one(`statusbar.headline`),C=b.one(`rail.assistant`)!==void 0,{flushSaves:w,beginLifecycle:T,endLifecycle:E,adoptLifecycleSnapshot:D,toggleLeft:O,toggleRight:k,setLayoutMode:A,undo:j,redo:M}=$(e=>e.actions),N=$(e=>e.versionsCapability),P=$(e=>e.telemetry),F=N?.status===`ready`?N.api:void 0,I=(0,W.useMemo)(()=>F===void 0?void 0:e=>F.save(e),[F]),L=(0,W.useMemo)(()=>F===void 0?void 0:()=>F.savedRevision(),[F]),R=()=>P?.({name:`preview`}),ee=()=>P?.({name:`export`}),[z,te]=(0,W.useState)(!1),[ne,re]=(0,W.useState)(!1),[B,ie]=(0,W.useState)(`idle`),[ae,oe]=(0,W.useState)(null),[se,ce]=(0,W.useState)(null),le=SN();(0,W.useEffect)(()=>{if(L===void 0||u===null)return;let e=!0;return L().then(t=>{e&&ce(t===u?t:null)}).catch(()=>{e&&ce(null)}),()=>{e=!1}},[u,L]);let V=(0,W.useRef)(null),H=(0,W.useRef)(()=>{}),ue=(0,W.useRef)(null),de=(0,W.useRef)(null),fe=i===!0&&m?.channel===`email`&&h!==null&&g===null,U=()=>{fe&&m!==null&&h!==null&&(pL(h.html,m.name),ee?.())},pe=()=>{if(I===void 0)return Promise.resolve();if(V.current!==null)return V.current;if(!T())return Promise.resolve();let e=()=>{},t=new Promise(t=>{e=t});return V.current=t,ie(`saving`),le.getState().actions.flushSaves().then(async e=>{let t=le.getState().doc,n=await I(e),r=le.getState().doc;t!==null&&(r?.rev===e||r?.rev===n)&&r.origin.authoredSource===t.origin.authoredSource&&le.getState().actions.adoptLifecycleSnapshot({rev:n,authoredSource:t.origin.authoredSource}),oe(n),ie(`idle`)}).catch(()=>ie(`error`)).finally(()=>{E(),V.current===t&&(V.current=null),e()}),t};(0,W.useEffect)(()=>{H.current=pe});let me=n===void 0||I===void 0?void 0:async()=>{let e=le.getState().lifecycleCapability;if(e?.status!==`ready`)return;let t=await le.getState().actions.flushSaves(),r=await n.readTheme(),i=KL(r);i!==r.theme&&await e.api.updateFile({path:jL,baseRev:t,content:i}),await pe()},he=`idle`;B===`saving`?he=`saving`:B===`error`?he=`error`:u!==null&&(ae===u||se===u)&&g===null&&!v&&y===null&&(he=`saved`);let ge;I!==void 0&&(ge=`Unsaved changes`,he===`saving`?ge=`Saving version…`:he===`saved`?ge=`Saved version`:he===`error`&&(ge=`Couldn’t save version`));let _e={flushSaves:w,beginLifecycle:T,endLifecycle:E,adoptLifecycleSnapshot:D,undo:j,redo:M,canUndo:p&&d>0,canRedo:p&&f>0,preview:()=>{te(!0),R?.()},exportHtml:U,canExport:fe},ve=b.all(`toolbar.leading`).map(e=>(0,Z.jsx)(W.Fragment,{children:e.render()},e.id)),ye=b.all(`toolbar.actions`).map(e=>(0,Z.jsx)(W.Fragment,{children:e.render(_e)},e.id)),be=b.one(`document.switcher`)?.render(_e);(0,W.useEffect)(()=>{if(I===void 0)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&e.target instanceof HTMLElement&&e.target.closest(`[data-samva-editor-theme]`)!==null&&e.target.closest(`[role="menu"], [role="dialog"], [data-base-ui-portal]`)===null&&(e.preventDefault(),H.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[I]),(0,W.useLayoutEffect)(()=>{let e=ue.current;if(e===null||typeof ResizeObserver>`u`)return;let t,n=e=>{let n=tR(e);n!==t&&(t=n,A(n))};n(e.getBoundingClientRect().width);let r=new ResizeObserver(([e])=>{e!==void 0&&n(e.contentRect.width)});return r.observe(e),()=>r.disconnect()},[A]);let xe=(l===`compact`||l===`narrow`)&&(!s||!c);return(0,W.useEffect)(()=>{if(!xe)return;let e=e=>{e.key===`Escape`&&(s||O(),c||k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,xe,c,O,k]),(0,Z.jsx)(iF,{value:b,children:(0,Z.jsx)(cF,{value:{exportHtml:U,canExport:fe,saveVersionStatus:I===void 0?`unavailable`:he},children:(0,Z.jsx)(TL,{container:de,children:(0,Z.jsxs)(`div`,{ref:ue,className:`samva-editor-frame flex`,style:{height:e},children:[x?.render(),(0,Z.jsxs)(`div`,{"data-samva-editor-theme":`host`,"data-layout":l,inert:_,"aria-busy":_,className:`samva-editor-shell grid min-w-0 flex-1 grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden`,children:[(0,Z.jsx)($L,{leading:ve.length===0?void 0:ve,extraActions:ye.length===0?void 0:ye,onBack:x===void 0?r:void 0,onPreview:()=>{te(!0),R?.()},onLifecycle:()=>re(!0),onUndo:j,onRedo:M,canUndo:p&&d>0,canRedo:p&&f>0,channelSwitcher:be,exportEnabled:i,renameEnabled:a,onExport:ee,brand:n,onUseDefaultBrand:me}),(0,Z.jsxs)(`div`,{className:`samva-editor-body relative flex min-h-0 min-w-0 overflow-hidden`,children:[xe&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close editor panel`,className:`bg-background/45 absolute inset-0 z-30 cursor-default backdrop-blur-[1px]`,onClick:()=>{s||O(),c||k()}}),s&&!C&&(0,Z.jsxs)(DT,{children:[(0,Z.jsx)(FT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Show layers and blocks`,"data-testid":`shell.show-left`,onClick:O,className:`border-border bg-background/92 text-muted-foreground hover:bg-muted hover:text-foreground absolute top-3 left-3 z-20 rounded-md border p-1.5 shadow-[var(--shadow-md)] backdrop-blur-md transition-colors`}),children:(0,Z.jsx)(HP,{className:`size-[15px]`})}),(0,Z.jsx)(zT,{container:de,children:(0,Z.jsx)(cE,{side:`right`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(lE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Show layers and blocks`})})})]}),c&&!C&&(0,Z.jsxs)(DT,{children:[(0,Z.jsx)(FT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Show inspector`,"data-testid":`shell.show-right`,onClick:k,className:`border-border bg-background/92 text-muted-foreground hover:bg-muted hover:text-foreground absolute top-3 right-3 z-20 rounded-md border p-1.5 shadow-[var(--shadow-md)] backdrop-blur-md transition-colors`}),children:(0,Z.jsx)(WP,{className:`size-[15px]`})}),(0,Z.jsx)(zT,{container:de,children:(0,Z.jsx)(cE,{side:`left`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(lE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Show inspector`})})})]}),(0,Z.jsx)(iR,{}),(0,Z.jsx)(nR,{}),(0,Z.jsx)(rR,{})]}),(0,Z.jsx)(AL,{saveVersionStatus:S!==void 0&&!S.saveVersion?void 0:ge,saveVersionState:I===void 0?void 0:he,onSaveVersion:S!==void 0&&!S.saveVersion||I===void 0?void 0:pe,saveVersionBusy:he===`saving`,saveVersionBlocked:_,guestHeadline:S?.headline})]}),(0,Z.jsx)(OL,{open:z,onClose:()=>te(!1)}),(0,Z.jsx)(CL,{open:ne,onClose:()=>re(!1),onLockedAction:o}),(0,Z.jsx)(`div`,{ref:de,"data-samva-editor-portal-root":!0,className:`samva-editor-shell`})]})})})})}function oR({name:e,className:t}){let n=yN()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})}function sR({label:e,icon:t,title:n,upsell:r,onAction:i,testId:a}){let[o,s]=(0,W.useState)(!1),c=pF();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(vI,{title:e,help:r.reason,testId:a,onClick:()=>s(!0),className:`h-[30px] px-2.5`,children:[t,e]}),(0,Z.jsx)(Uj,{open:o,onOpenChange:s,swipeDirection:`right`,children:(0,Z.jsxs)(Bj,{container:c,children:[(0,Z.jsx)(gj,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(kM,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(zj,{className:`samva-editor-shell border-border bg-background pointer-events-auto flex h-full w-[420px] max-w-[92vw] flex-col border-l shadow-[var(--shadow-floating)] outline-none`,children:[(0,Z.jsx)(yj,{className:`sr-only`,children:r.reason}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-4 pb-3`,children:[(0,Z.jsx)(fM,{className:`text-[15px] font-semibold`,children:n}),(0,Z.jsx)(_j,{type:`button`,"aria-label":`Close ${e.toLowerCase()} panel`,"data-testid":a===void 0?void 0:`${a}.close`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1.5`,children:(0,Z.jsx)(YP,{className:`size-[15px]`})})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-start gap-4 px-5 pt-6 pb-8`,children:[(0,Z.jsx)(`div`,{className:`border-border-subtle bg-surface-inset text-muted-foreground rounded-lg border px-3.5 py-3 text-[13px]`,children:r.reason}),(0,Z.jsx)(`a`,{href:r.cta.href,onClick:e=>{i!==void 0&&(e.preventDefault(),i())},"data-testid":a===void 0?void 0:`${a}.cta`,className:`bg-primary text-primary-foreground inline-flex h-9 items-center rounded-[7px] px-4 font-medium transition-opacity hover:opacity-90`,children:r.cta.label})]})]})})]})})]})}var cR=`2026-10-03.1`,lR=class extends Hn(`DocumentConflict`){},uR=class extends Hn(`DocumentUnavailable`){};Hn(`LifecycleUnavailable`),Hn(`ProjectFileExists`);var dR=(e,t)=>{let n=new URL(`api/${e}`,window.location.href);for(let[e,r]of Object.entries(t))n.searchParams.set(e,r);return n.toString()},fR=e=>e.fixture,pR=(e,t,n,r)=>({rev:t,origin:n,...r===void 0?{}:{authoredSource:r},...e}),mR=(e,t,n)=>ca(function*(){let r=yield*Fa(),i=new EventSource(dR(`events`,{id:e,client:t}));yield*ha(()=>aa(()=>i.close())),i.addEventListener(`samva:change`,t=>{let i=JSON.parse(t.data);i.id===e&&(n.rev=i.rev,n.fixture=fR(i),i.authoredSource!==void 0&&(n.authoredSource=i.authoredSource),Ia(r,pR(i,i.rev,i.origin,i.authoredSource)))});let a=()=>fetch(dR(`document`,{id:e,client:t})).then(e=>e.ok?e.json():void 0).then(e=>{if(e===void 0)return;let t=e.origin.authoredSource;(e.rev!==n.rev||t!==n.authoredSource||fR(e)!==n.fixture)&&(n.rev=e.rev,n.authoredSource=t,n.fixture=fR(e),Ia(r,pR(e,e.rev,`external`,t)))}).catch(()=>{}),o=!1,s;i.addEventListener(`open`,()=>{if(!o){o=!0,s?.(oa);return}a()}),i.addEventListener(`error`,()=>{!o&&i.readyState!==EventSource.OPEN&&s?.(new uR({reason:`editor event stream failed to open`}))}),yield*sa(e=>{if(i.readyState===EventSource.OPEN)return o=!0,e(oa);s=e});let c=yield*na({try:()=>fetch(dR(`document`,{id:e,client:t})),catch:e=>new uR({reason:String(e)})});if(!c.ok)return yield*new uR({reason:`open failed (${c.status})`});let l=yield*na({try:()=>c.json(),catch:e=>new uR({reason:String(e)})});return n.rev=l.rev,n.authoredSource=l.origin.authoredSource,n.fixture=fR(l),{initial:l,changes:oo(r)}}),hR=(e,t)=>({view:n=>ca(function*(){let r=yield*na({try:()=>fetch(dR(`fixture`,{id:e,client:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fixture:n})}),catch:e=>new uR({reason:String(e)})});if(r.ok)return;let i=`view fixture failed (${r.status})`;return yield*new uR({reason:yield*na({try:()=>r.json(),catch:()=>new uR({reason:i})}).pipe(fa(e=>e.error??i))})})}),gR=(e,t)=>({save:n=>ca(function*(){if(n.kind!==`authoredSource`)return yield*new uR({reason:`Local metadata is declared in source.`});let r=yield*na({try:()=>fetch(dR(`document`,{id:e,client:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),catch:e=>new uR({reason:String(e)})}),i=yield*na({try:()=>r.json(),catch:e=>new uR({reason:String(e)})});return r.status===409?yield*new lR({expectedRev:n.baseRev,actualRev:i.actualRev??n.baseRev}):!r.ok||i.rev===void 0?yield*new uR({reason:i.error??`Local source save failed.`}):{rev:i.rev}})}),_R=({id:e})=>{let t=crypto.randomUUID();return{contractVersion:cR,access:`editable`,sourceAccess:`editable`,metadataAccess:`readonly`,writer:gR(e,t),document:{open:mR(e,t,{rev:``})},fixtures:{status:`ready`,api:hR(e,t)}}},vR=e=>new URL(`api/${e}`,window.location.href).toString(),yR=async e=>{let t=await fetch(vR(e));if(!t.ok)throw Error(`${e} failed (${t.status})`);return t.json()},bR=()=>{let[e,t]=(0,W.useState)(()=>typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches);return(0,W.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e)},[e]),()=>t(e=>!e)};function xR({onBack:e,onToggleTheme:t}){return(0,Z.jsxs)(`nav`,{"aria-label":`Samva editor`,className:`border-border bg-background z-30 flex w-12 flex-none flex-col items-center gap-1 border-r py-3`,children:[(0,Z.jsx)(`span`,{className:`bg-primary text-primary-foreground mb-2 grid size-7 place-items-center rounded-lg text-[13px] font-bold`,children:`S`}),e?(0,Z.jsx)(`button`,{type:`button`,title:`Back to templates`,onClick:e,className:`text-muted-foreground hover:bg-muted hover:text-foreground grid size-8 place-items-center rounded-lg transition-colors`,children:(0,Z.jsx)(oR,{name:`arrowLeft`,className:`size-[16px]`})}):null,(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,title:`Toggle theme`,onClick:t,className:`text-muted-foreground hover:bg-muted hover:text-foreground grid size-8 place-items-center rounded-lg transition-colors dark:hidden`,children:(0,Z.jsx)(oR,{name:`moon`,className:`size-[16px]`})}),(0,Z.jsx)(`button`,{type:`button`,title:`Toggle theme`,onClick:t,className:`text-muted-foreground hover:bg-muted hover:text-foreground hidden size-8 place-items-center rounded-lg transition-colors dark:grid`,children:(0,Z.jsx)(oR,{name:`sun`,className:`size-[16px]`})})]})}var SR={authenticatedLabel:`Authenticated`,authenticatedTitle:`The host provides authenticated capabilities.`};function CR({template:e,authenticated:t,editorAffordances:n,onBack:r,onToggleTheme:i}){let a=n.publishingInstructions,o=(0,W.useMemo)(()=>fo(_R({id:e.id})),[e.id]);return(0,Z.jsx)(vP,{host:o,children:(0,Z.jsx)(`div`,{className:`relative h-dvh`,children:(0,Z.jsx)(aR,{contributions:[{slot:`frame.start`,id:`project-rail`,render:()=>(0,Z.jsx)(xR,{onBack:r,onToggleTheme:i})},...t&&a!==void 0?[{slot:`toolbar.actions`,id:`send`,render:()=>(0,Z.jsx)(sR,{label:`Send`,title:`Send “${e.name}”`,upsell:a,testId:`vite-editor.send`})}]:[]],onBack:r,renameEnabled:!1})})},`${e.id}:${e.channel}`)}var wR={email:{icon:`envelope`,label:`Email`,className:`bg-sel-soft text-accent-email`},sms:{icon:`message`,label:`SMS`,className:`bg-muted text-primary`},whatsapp:{icon:`chatBubble`,label:`WhatsApp`,className:`bg-status-success/10 text-status-success`}};function TR({catalog:e,authenticated:t,editorAffordances:n,onOpen:r,onToggleTheme:i}){return(0,Z.jsxs)(`div`,{className:`flex h-dvh`,children:[(0,Z.jsx)(xR,{onToggleTheme:i}),(0,Z.jsx)(`div`,{className:`bg-surface-inset min-w-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`mx-auto max-w-[720px] px-6 py-16`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-foreground text-lg font-semibold`,children:`Templates`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-[13px]`,children:`Preview your templates and fixtures. Source edits save to your project.`})]}),(0,Z.jsx)(`span`,{className:t?`bg-status-success/12 text-status-success rounded-full px-2.5 py-1 text-[11px] font-medium`:`bg-muted text-muted-foreground rounded-full px-2.5 py-1 text-[11px] font-medium`,title:t?n.authenticatedTitle:`Local editing only.`,children:t?n.authenticatedLabel:`Local only`})]}),e.diagnostics.length>0?(0,Z.jsx)(`section`,{"aria-label":`Catalog diagnostics`,className:`border-border bg-surface-elevated mt-6 overflow-hidden rounded-xl border`,children:e.diagnostics.map((e,t)=>(0,Z.jsxs)(`div`,{className:`px-4 py-3 text-[12px]`+(t>0?` border-border-subtle border-t`:``),children:[(0,Z.jsxs)(`p`,{className:e.severity===`error`?`text-status-error`:`text-status-warning`,children:[e.file,` · `,e.code]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.message})]},`${e.file}:${e.code}:${t}`))}):null,(0,Z.jsxs)(`ul`,{className:`border-border bg-surface-elevated mt-8 overflow-hidden rounded-xl border shadow-md`,children:[e.templates.length===0?(0,Z.jsxs)(`li`,{className:`text-muted-foreground px-4 py-10 text-center text-[13px]`,children:[`No valid templates found. Add a `,(0,Z.jsx)(`code`,{className:`text-foreground`,children:`.tsx`}),` file with a Samva template as its default export.`]}):null,e.templates.map((e,t)=>{let n=wR[e.channel];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"data-testid":`template-card.${e.id}`,className:`hover:bg-muted flex w-full items-center gap-3 px-4 py-3 text-left transition-colors`+(t>0?` border-border-subtle border-t`:``),children:[(0,Z.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-lg ${n.className}`,children:(0,Z.jsx)(oR,{name:n.icon,className:`size-[16px]`})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-foreground block truncate text-[13px] font-medium`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground block truncate text-[12px]`,children:e.id})]}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground text-right text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`block`,children:n.label}),(0,Z.jsx)(`span`,{className:`block`,children:`Editable source`})]})]})},e.id)})]})]})})]})}function ER(){let e=bR(),[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(SR),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=!0,t=()=>yR(`templates`).then(t=>{e&&(o(t),c(null))});Promise.all([yR(`capabilities`).then(t=>{e&&(n(!!t.authenticated),i(t.editorAffordances??SR))}),t()]).catch(t=>{e&&c(String(t))});let r=new EventSource(vR(`catalog-events`));return r.addEventListener(`samva:catalog`,()=>{t().catch(t=>{e&&c(String(t))})}),()=>{e=!1,r.close()}},[]);let d=a?.templates.find(e=>e.id===l)??null;return l!==null&&a!==null&&d===null&&u(null),s===null?a===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid h-dvh place-items-center text-[13px]`,children:`Loading templates…`}):d===null?(0,Z.jsx)(TR,{catalog:a,authenticated:t,editorAffordances:r,onOpen:e=>u(e.id),onToggleTheme:e}):(0,Z.jsx)(CR,{template:d,authenticated:t,editorAffordances:r,onBack:()=>u(null),onToggleTheme:e}):(0,Z.jsxs)(`div`,{className:`text-status-error grid h-dvh place-items-center px-6 text-center text-[13px]`,children:[`Couldn’t reach the Samva editor dev server: `,s]})}(0,co.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(W.StrictMode,{children:(0,Z.jsx)(ER,{})}));