@samva/vite 0.15.0 → 0.15.1
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.
|
@@ -28,7 +28,7 @@ Error generating stack: `+e.message+`
|
|
|
28
28
|
`,t-1),e.lastIndexOf(`\r`,t-1)),r=e.slice(n+1,t);return/^[ \t]*$/.test(r)?r:null},Qg=(e,t)=>{if(Zg(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-(Zg(e,t.start)??``).length,end:t.end+n[0].length}},$g=(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=Zg(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=Qg(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}]},e_=(e,t)=>{let n=e.program;if(!Lg(n))return null;for(let e of Rg(n.body)){let n=e.type===`ExportNamedDeclaration`&&Lg(e.declaration)?e.declaration:e;if(n.type===`VariableDeclaration`){for(let e of Rg(n.declarations))if(Lg(e.id)&&e.id.name===t&&Lg(e.init)&&e.init.type===`ObjectExpression`)return e.init}}return null},t_=e=>{let t=Bg(e);if(t===null)return[];let n=[];return zg(t,r=>{if(r.type!==`CallExpression`||!Lg(r.callee)||r.callee.type!==`Identifier`||r.callee.name!==`defineTemplate`)return;let i=Rg(r.arguments)[0];if(i?.type!==`ObjectExpression`)return;let a=Rg(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 Rg(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`?e_(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},n_=e=>e.split(/\s+/).filter(e=>e!==``),r_=(e,t,n)=>{let r=t.properties.find(e=>e.name===`className`),i=e=>{if(n.kind===`set`)return n_(n.value).join(` `);let t=n_(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(n_(r.value));return{ok:!0,edits:[{start:r.start,end:r.end,before:e.slice(r.start,r.end),after:JSON.stringify(a)}]}},i_=e=>is(e)&&typeof e.type==`string`&&typeof e.start==`number`&&typeof e.end==`number`,a_=e=>Array.isArray(e)?e.filter(i_):[],o_=(e,t)=>{let n=e[t];return i_(n)?n:null},s_=e=>{try{let t=am(e,{sourceType:`module`,plugins:[`typescript`,`jsx`]});return i_(t)?t:null}catch{return null}},c_=(e,t)=>{if(Array.isArray(e)){for(let n of e)c_(n,t);return}if(i_(e)&&t(e)!==!1)for(let[n,r]of Object.entries(e))n!==`loc`&&n!==`extra`&&n!==`comments`&&c_(r,t)},l_=e=>e===null?``:e.type===`JSXIdentifier`?typeof e.name==`string`?e.name:``:e.type===`JSXMemberExpression`?`${l_(o_(e,`object`))}.${l_(o_(e,`property`))}`:``,u_=e=>{if(e.type!==`JSXElement`)return null;let t=o_(e,`openingElement`);if(t===null)return null;let n=o_(e,`closingElement`);return{node:e,opening:t,closing:n,tag:l_(o_(t,`name`)),children:a_(e.children),attributes:a_(t.attributes),selfClosing:t.selfClosing===!0,contentStart:t.end,contentEnd:n===null?t.end:n.start}},d_=e=>{let t=o_(e,`body`);if(t===null)return null;if(t.type===`JSXElement`)return t;if(t.type!==`BlockStatement`)return null;let n=a_(t.body).filter(e=>e.type!==`EmptyStatement`),r=n.length===1?n[0]:void 0,i=r?.type===`ReturnStatement`&&r!==void 0?o_(r,`argument`):null;return i!==null&&i.type===`JSXElement`?i:null},f_=e=>{if(e.computed===!0)return null;let t=o_(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},p_=(e,t)=>{let n=null;return c_(e,e=>{if(n!==null)return!1;if(e.type!==`CallExpression`)return;let r=o_(e,`callee`);if(r?.type!==`Identifier`||r.name!==`defineTemplate`)return;let i=a_(e.arguments)[0];if(i?.type!==`ObjectExpression`)return!1;for(let e of a_(i.properties)){if(f_(e)!==t)continue;let r=e.type===`ObjectMethod`?e:e.type===`ObjectProperty`?o_(e,`value`):null;if(r===null||r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`&&r.type!==`ObjectMethod`)return!1;let i=d_(r),a=i===null?null:u_(i);return a!==null&&(n={root:a,parameter:a_(r.params)[0]??null}),!1}return!1}),n},m_=(e,t,n)=>{let r=n;return c_(e,e=>{if(e.type===`ImportDeclaration`){if(o_(e,`source`)?.value!==t)return!1;for(let t of a_(e.specifiers)){let e=o_(t,`imported`),i=o_(t,`local`);t.type===`ImportSpecifier`&&(e?.name===n||e?.value===n)&&(r=typeof i?.name==`string`?i.name:n)}return!1}}),r},h_=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},g_=e=>{let t=o_(e,`expression`);if(t===null)return null;if(t.type===`StringLiteral`&&typeof t.value==`string`)return t.value;if(t.type===`TemplateLiteral`&&a_(t.expressions).length===0){let e=a_(t.quasis)[0]?.value;return is(e)&&typeof e.cooked==`string`?e.cooked:null}return null},__=(e,t)=>{let n=e.slice(t.start,t.end).replace(/\s+/g,` `).trim();return n.length>60?`${n.slice(0,59)}…`:n},v_=(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+=h_(typeof o.value==`string`?o.value:``);continue}if(o.type===`JSXExpressionContainer`){let e=g_(o);if(e!==null){i+=e;continue}}a(o.start),n.push({kind:`locked`,summary:__(e,o),start:o.start,end:o.end}),r=o.end}return a(t.contentEnd),n},y_=e=>!/[{}<>&\r\n\t]/.test(e),b_=(e,t,n)=>{let r=[...e],i=r.map(e=>!y_(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},x_=(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:`>${b_(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:b_(i,c!==``,d!==``)}]}},S_=(e,t)=>e.attributes.find(e=>e.type===`JSXAttribute`&&l_(o_(e,`name`))===t)??null,C_=(e,t,n)=>{let r=S_(t,n);if(r===null)return{kind:`absent`};let i=o_(r,`value`);if(i?.type===`StringLiteral`&&typeof i.value==`string`)return{kind:`literal`,value:i.value};if(i?.type===`JSXExpressionContainer`){let e=g_(i);if(e!==null)return{kind:`literal`,value:e}}return{kind:`expression`,source:__(e,i??r)}},w_=e=>/["&\\\r\n]/.test(e)?`{${JSON.stringify(e)}}`:`"${e}"`,T_=(e,t,n,r)=>({start:t,end:n,before:e.slice(t,n),after:r}),E_=(e,t,n,r)=>{let i=S_(t,n);if(i===null){if(r===void 0)return{ok:!0,edits:[]};let i=t.attributes.at(-1)?.end??o_(t.opening,`name`)?.end??t.opening.end;return{ok:!0,edits:[T_(e,i,i,` ${n}=${w_(r)}`)]}}if(C_(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:[T_(e,n,i.end,``)]}}let a=o_(i,`value`);return{ok:!0,edits:a===null?[T_(e,i.end,i.end,`=${w_(r)}`)]:[T_(e,a.start,a.end,w_(r))]}},D_=` `,O_=(e,t)=>{let n=e.lastIndexOf(`
|
|
29
29
|
`,t-1)+1,r=e.slice(n,t);return/^[ \t]*$/.test(r)?r:null},k_=(e,t)=>{let n=O_(e,t.start),r=/^[ \t]*(\r?\n)/.exec(e.slice(t.end));return n===null||r===null?T_(e,t.start,t.end,``):T_(e,t.start-n.length,t.end+r[0].length,``)},A_=(e,t,n,r)=>{let i=O_(e,t.start);return n===`before`?T_(e,t.start,t.start,i===null?r:`${r}\n${i}`):T_(e,t.end,t.end,i===null?r:`\n${i}${r}`)},j_=(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 a_(n.properties)){let n=o_(t,`key`);n?.type===`Identifier`&&typeof n.name==`string`&&RegExp(`\\b${n.name}\\b`).test(e)&&r.add(n.name)}};return c_(t.node,t=>{t.type===`JSXExpressionContainer`&&g_(t)===null&&i(e.slice(t.start,t.end))}),[...r].sort()},M_=e=>{let t=s_(e);if(t===null)return null;let n=p_(t,`sms`);return n===null||n.root.tag!==m_(t,`@samva/markup/sms`,`Sms`)?null:{...n,tree:t}},N_=e=>{let t=M_(e);return t===null?null:{category:C_(e,t.root,`category`),segments:v_(e,t.root),variables:j_(e,t.root,t.parameter)}},P_=(e,t)=>{let n=M_(e);return n===null?{ok:!1,reason:`The SMS body is not editable here.`}:t.kind===`category`?t.value!==void 0&&!wm.includes(t.value)?{ok:!1,reason:`\`${t.value}\` is not an SMS category.`}:E_(e,n.root,`category`,t.value):x_(e,n.root,v_(e,n.root),t.segment,t.text)},F_={"quick-reply":`QuickReplyButton`,url:`UrlButton`,phone:`PhoneButton`,"copy-code":`CopyCodeButton`},I_={"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(F_).find(e=>F_[e]===n)??null},R_=e=>{let t=s_(e);if(t===null)return null;let n=p_(t,`whatsapp`),r=m_(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=u_(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`)}},z_=(e,t)=>{if(t.buttons===null)return[];let n=[];for(let r of t.buttons.children){if(r.type===`JSXText`&&h_(String(r.value??``))===``)continue;let i=u_(r),a=i===null?null:L_(i.tag,t.local);if(i===null||a===null){n.push({row:{kind:`locked`,summary:__(e,r)},node:r});continue}let o=v_(e,i),s=o[0];n.push({node:r,row:o.length===1&&s?.kind===`text`?{kind:`editable`,type:a,text:s.text,url:C_(e,i,`url`),phone:C_(e,i,`phone`)}:{kind:`locked`,summary:__(e,r)}})}return n},B_=e=>{let t=R_(e);if(t===null||t.body===null)return null;let{root:n}=t;return{language:C_(e,n,`language`),category:C_(e,n,`category`),header:t.header===null?null:v_(e,t.header),headerType:t.header===null?{kind:`absent`}:C_(e,t.header,`type`),body:v_(e,t.body),footer:t.footer===null?null:v_(e,t.footer),buttons:z_(e,t).map(({row:e})=>e),variables:j_(e,n,t.parameter)}},V_=(e,t,n,r)=>{let i=`${e}.${F_[t]}`;return`<${i}${t===`url`&&r.url!==void 0?` url=${w_(r.url)}`:t===`phone`&&r.phone!==void 0?` phone=${w_(r.phone)}`:``}>${b_(n,!1,!1)}</${i}>`},H_=(e,t)=>V_(e,t,I_[t],{url:`https://example.com`,phone:`+15555550100`}),U_=(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}>${b_(i,!1,!1)}</${a}>`;return{ok:!0,edits:[A_(e,n===`header`?t.body.node:t.buttons?.node??t.body.node,n===`header`?`before`:`after`,o)]}}let o=v_(e,a);return n!==`body`&&i===``&&o.length===1?{ok:!0,edits:[k_(e,a.node)]}:x_(e,a,o,r,i)},W_=(e,t)=>{let n=R_(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`&&!Tm.includes(t.value)?{ok:!1,reason:`Choose a WhatsApp category.`}:E_(e,r,t.name,t.value);case`headerType`:return n.header===null?{ok:!1,reason:`Add the header text before choosing its type.`}:Em.includes(t.value)?E_(e,n.header,`type`,t.value===`text`?void 0:t.value):{ok:!1,reason:`\`${t.value}\` is not a header type.`};case`text`:return U_(e,n,t.part,t.segment,t.text);case`buttonAdd`:{let r=H_(i,t.type),a=n.buttons;if(a===null){let t=n.footer??n.body,a=`${i}.Buttons`,o=O_(e,t.node.start),s=o===null?`<${a}>${r}</${a}>`:`<${a}>\n${o}${D_}${r}\n${o}</${a}>`;return{ok:!0,edits:[A_(e,t.node,`after`,s)]}}if(a.selfClosing){let t=`${i}.Buttons`,n=O_(e,a.node.start),o=n===null?`<${t}>${r}</${t}>`:`<${t}>\n${n}${D_}${r}\n${n}</${t}>`;return{ok:!0,edits:[T_(e,a.node.start,a.node.end,o)]}}let o=a.children.findLast(e=>e.type!==`JSXText`||h_(String(e.value??``))!==``);if(o!==void 0)return{ok:!0,edits:[A_(e,o,`after`,r)]};let s=O_(e,a.node.start);return{ok:!0,edits:[T_(e,a.contentStart,a.contentEnd,s===null?r:`\n${s}${D_}${r}\n${s}`)]}}}let a=z_(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:[k_(e,a.length===1?n.buttons.node:o.node)]};let s=u_(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 x_(e,s,v_(e,s),0,t.text);case`buttonAttribute`:return E_(e,s,t.name,t.value);default:{let{row:n}=o,r=e=>e.kind===`literal`?e.value:void 0,a=V_(i,t.type,n.text,{url:r(n.url)??`https://example.com`,phone:r(n.phone)??`+15555550100`});return{ok:!0,edits:[T_(e,o.node.start,o.node.end,a)]}}}},G_=new Set([`[`,`]`,`{`,`}`,`\\`,`~`,`|`,`€`,`^`,`\f`]),K_=/^[@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,\-./:;<=>?¡0-9ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà]*$/,q_=e=>{for(let t of e)if(!G_.has(t)&&!K_.test(t))return!0;return!1},J_=e=>{if(q_(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}},Y_=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=Y_()})),Z_={};function Q_(e,t){let n=W.useRef(Z_);return n.current===Z_&&(n.current=e(t)),n}var $_=[],ev=void 0;function tv(){return ev}function nv(e){$_.push(e)}function rv(e){let t=(t,n)=>{let r=Q_(av).current,i;try{ev=r;for(let e of $_)e.before(r);i=e(t,n);for(let e of $_)e.after(r);r.didInitialize=!0}finally{ev=void 0}return i};return t.displayName=e.displayName||e.name,t}function iv(e){return W.forwardRef(rv(e))}function av(){return{didInitialize:!1}}function ov(){}var sv=Object.freeze([]),cv=Object.freeze({}),X=typeof document<`u`?W.useLayoutEffect:()=>{};function lv(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 uv=lv(`https://base-ui.com/production-error`,`Base UI`),dv=W.createContext(void 0);function fv(e){let t=W.useContext(dv);if(t===void 0&&!e)throw Error(uv(72));return t}function pv(e){W.useEffect(e,sv)}var mv=0,hv=class e{static create(){return new e}currentId=mv;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=mv,t()},e)}isStarted(){return this.currentId!==mv}clear=()=>{this.currentId!==mv&&(clearTimeout(this.currentId),this.currentId=mv)};disposeEffect=()=>this.clear};function gv(){let e=Q_(hv.create).current;return pv(e.disposeEffect),e}function _v(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:vv,platform:yv,maxTouchPoints:bv}=_v(),xv=vv.toLowerCase(),Sv=yv.toLowerCase(),Cv=/^i(os$|p)/.test(Sv)||Sv===`macintel`&&bv>1,wv=`android`,Tv=Sv===wv||xv.includes(wv),Ev=!Cv&&Sv.startsWith(`mac`);Sv.startsWith(`win`),!Tv&&/^(linux|chrome os)/.test(Sv);var Dv=Ev||Cv,Ov=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!Ov&&xv.includes(`firefox`),!Ov&&xv.includes(`chrom`);var kv=Dv,Av=/jsdom|happydom/.test(xv);function jv(e){e.preventDefault(),e.stopPropagation()}function Mv(e){return`nativeEvent`in e}function Nv(e){return e.pointerType===``&&e.isTrusted?!0:Tv&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function Pv(e){return Av?!1:!Tv&&e.width===0&&e.height===0||Tv&&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 Fv(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Iv(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function Lv(){return typeof window<`u`}function Rv(e){return Vv(e)?(e.nodeName||``).toLowerCase():`#document`}function zv(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bv(e){return((Vv(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Vv(e){return Lv()?e instanceof Node||e instanceof zv(e).Node:!1}function Hv(e){return Lv()?e instanceof Element||e instanceof zv(e).Element:!1}function Uv(e){return Lv()?e instanceof HTMLElement||e instanceof zv(e).HTMLElement:!1}function Wv(e){return!Lv()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof zv(e).ShadowRoot}function Gv(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=ny(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Kv(e){return/^(table|td|th)$/.test(Rv(e))}function qv(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Jv=/transform|translate|scale|rotate|perspective|filter/,Yv=/paint|layout|strict|content/,Xv=e=>!!e&&e!==`none`,Zv;function Qv(e){let t=Hv(e)?ny(e):e;return Xv(t.transform)||Xv(t.translate)||Xv(t.scale)||Xv(t.rotate)||Xv(t.perspective)||!ey()&&(Xv(t.backdropFilter)||Xv(t.filter))||Jv.test(t.willChange||``)||Yv.test(t.contain||``)}function $v(e){let t=iy(e);for(;Uv(t)&&!ty(t);){if(Qv(t))return t;if(qv(t))return null;t=iy(t)}return null}function ey(){return Zv??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Zv}function ty(e){return/^(html|body|#document)$/.test(Rv(e))}function ny(e){return zv(e).getComputedStyle(e)}function ry(e){return Hv(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function iy(e){if(Rv(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Wv(e)&&e.host||Bv(e);return Wv(t)?t.host:t}function ay(e){let t=iy(e);return ty(t)?(e.ownerDocument||e).body:Uv(t)&&Gv(t)?t:ay(t)}function oy(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ay(e),i=r===e.ownerDocument?.body,a=zv(r);if(i){let e=sy(a);return t.concat(a,a.visualViewport||[],Gv(r)?r:[],e&&n?oy(e):[])}return t.concat(r,oy(r,[],n))}function sy(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function cy(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function ly(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Wv(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function uy(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var dy=`data-base-ui-focusable`,fy=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,py=`ArrowLeft`,my=`ArrowRight`,hy=`ArrowUp`,gy=`ArrowDown`,_y=`data-starting-style`,vy=`data-ending-style`,yy={[_y]:``},by={[vy]:``},xy={transitionStatus(e){return e===`starting`?yy:e===`ending`?by:null}},Sy=`data-open`,Cy=`data-closed`,wy=`data-anchor-hidden`,Ty=`data-popup-open`,Ey=`data-pressed`,Dy={[Ty]:``},Oy={[Ty]:``,[Ey]:``},ky={[Sy]:``},Ay={[Cy]:``},jy={[wy]:``},My={open(e){return e?Dy:null}},Ny={open(e){return e?Oy:null}},Py={open(e){return e?ky:Ay},anchorHidden(e){return e?jy:null}},Fy={...Py,...xy},Iy=`data-trigger-disabled`;function Ly(e,t){if(!Hv(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(Iy);for(let[,e]of t.entries())if(ly(e,n))return!e.hasAttribute(Iy);return!1}function Ry(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 zy(e){return e.matches(`html,body`)}function By(e){return Uv(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function Vy(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${fy}`)!=null}function Hy(e){return e?e.getAttribute(`role`)===`combobox`&&By(e):!1}function Uy(e){if(!e||Av)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function Wy(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&&!Fv(t)?0:typeof e==`function`?e():e}function Ky(e,t,n){let r=Gy(e,n);return typeof r==`number`?r:r?.[t]}function qy(e){return typeof e==`function`?e():e}function Jy(e,t){return t||e===`click`||e===`mousedown`}function Yy(e){return e?.includes(`mouse`)&&e!==`mousedown`}var Xy=`none`,Zy=`trigger-press`,Qy=`trigger-hover`,$y=`trigger-focus`,eb=`outside-press`,tb=`item-press`,nb=`close-press`,rb=`focus-out`,ib=`escape-key`,ab=`close-watcher`,ob=`list-navigation`,sb=`cancel-open`,cb=`sibling-open`,lb=`disabled`,ub=`imperative-action`,db=`swipe`,fb=`window-resize`;function pb(e,t,n,r){let i=!1,a=!1,o=r??cv;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_(),mb=W.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new hv,currentIdRef:{current:null},currentContextRef:{current:null}});function hb(e,t){e.current=t.current}function gb(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(mb),[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:Ky(c.current,`close`)},t!==null&&t!==i?(p(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,pb(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,hb(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 _b(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function vb(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function yb(e,t,n,r){let i=Q_(xb).current;return Sb(i,e,t,n,r)&&wb(i,[e,t,n,r]),i.callback}function bb(e){let t=Q_(xb).current;return Cb(t,e)&&wb(t,e),t.callback}function xb(){return{callback:null,cleanup:null,refs:[]}}function Sb(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Cb(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function wb(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 Tb(e){let t=Q_(Eb,e).current;return t.next=e,X(t.effect),t}function Eb(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Db={...W},Ob=Db.useInsertionEffect,kb=Ob&&Ob!==Db.useLayoutEffect?Ob:e=>e();function Q(e){let t=Q_(Ab).current;return t.next=e,kb(t.effect),t.trampoline}function Ab(){let e={next:void 0,callback:jb,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function jb(){}var Mb=null;globalThis.requestAnimationFrame;var Nb=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)}},Pb=class e{static create(){return new e}static request(e){return Nb.request(e)}static cancel(e){return Nb.cancel(e)}currentId=Mb;request(e){this.cancel(),this.currentId=Nb.request(()=>{this.currentId=Mb,e()})}cancel=()=>{this.currentId!==Mb&&(Nb.cancel(this.currentId),this.currentId=Mb)};disposeEffect=()=>this.cancel};function Fb(){let e=Q_(Pb.create).current;return pv(e.disposeEffect),e}function Ib(e){return e?.ownerDocument||document}var Lb={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Rb={...Lb,position:`fixed`,top:0,left:0},zb={...Lb,position:`absolute`},Bb=W.forwardRef(function(e,t){let[n,r]=W.useState();X(()=>{kv&&Ov&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,Z.jsx)(`span`,{...e,ref:t,style:Rb,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),Vb=Math.min,Hb=Math.max,Ub=Math.round,Wb=Math.floor,Gb=e=>({x:e,y:e}),Kb={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function qb(e,t,n){return Hb(e,Vb(t,n))}function Jb(e,t){return typeof e==`function`?e(t):e}function Yb(e){return e.split(`-`)[0]}function Xb(e){return e.split(`-`)[1]}function Zb(e){return e===`x`?`y`:`x`}function Qb(e){return e===`y`?`height`:`width`}function $b(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function ex(e){return Zb($b(e))}function tx(e,t,n){n===void 0&&(n=!1);let r=Xb(e),i=ex(e),a=Qb(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=ux(o)),[o,ux(o)]}function nx(e){let t=ux(e);return[rx(e),t,rx(t)]}function rx(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ix=[`left`,`right`],ax=[`right`,`left`],ox=[`top`,`bottom`],sx=[`bottom`,`top`];function cx(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ax:ix:t?ix:ax;case`left`:case`right`:return t?ox:sx;default:return[]}}function lx(e,t,n,r){let i=Xb(e),a=cx(Yb(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(rx)))),a}function ux(e){let t=Yb(e);return Kb[t]+e.slice(t.length)}function dx(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function fx(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:dx(e)}function px(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 mx(e,t){return t<0||t>=e.length}function hx(e,t){return _x(e.current,{disabledIndices:t})}function gx(e,t){return _x(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function _x(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&&vx(e,a,r));return a}function vx(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!bx(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function yx(e){return e.visibility===`hidden`||e.visibility===`collapse`}function bx(e,t=e?ny(e):null){return!e||!e.isConnected||!t||yx(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var xx=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Sx(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return Wv(n)?n.host:null}function Cx(e){for(let t of Array.from(e.children))if(Rv(t)===`summary`)return t;return null}function wx(e,t){let n=Cx(t);return!!n&&(e===n||ly(n,e))}function Tx(e){let t=e?Rv(e):``;return e!=null&&e.matches(xx)&&(t!==`summary`||e.parentElement!=null&&Rv(e.parentElement)===`details`&&Cx(e.parentElement)===e)&&(t!==`details`||Cx(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Ex(e){if(!Tx(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Sx(t)){let n=t!==e,r=Rv(t)===`slot`;if(t.hasAttribute(`inert`)||n&&Rv(t)===`details`&&!t.open&&!wx(e,t)||t.hasAttribute(`hidden`)||!r&&!Dx(t,n))return!1}return!0}function Dx(e,t){let n=ny(e);return t?n.display!==`none`:bx(e,n)}function Ox(e){let t=e.tabIndex;if(t<0){let t=Rv(e);if(t===`details`||t===`audio`||t===`video`||Uv(e)&&e.isContentEditable)return 0}return t}function kx(e){if(Rv(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Ax(e,t){let n=kx(e);if(!n)return!0;let r=t.find(e=>{let t=kx(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=kx(e);return t?.name===n.name&&t.form===n.form})===n}function jx(e){if(Uv(e)&&Rv(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return Uv(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Mx(e,t){jx(e).forEach(e=>{Tx(e)&&t.push(e),Mx(e,t)})}function Nx(e,t,n){jx(e).forEach(e=>{Uv(e)&&e.matches(t)&&n.push(e),Nx(e,t,n)})}function Px(e){return Ex(e)&&Ox(e)>=0}function Fx(e){let t=[];return Mx(e,t),t.filter(Ex)}function Ix(e){let t=Fx(e);return t.filter(e=>Ox(e)>=0&&Ax(e,t))}function Lx(e,t){let n=Ix(e),r=n.length;if(r===0)return;let i=cy(Ib(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Rx(e){return Lx(Ib(e).body,1)||e}function zx(e){return Lx(Ib(e).body,-1)||e}function Bx(e,t){if(!e)return null;let n=Ix(Ib(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 Vx(e){return Bx(e,1)}function Hx(e){return Bx(e,-1)}function Ux(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!ly(n,r)}function Wx(e){Ix(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function Gx(e){let t=[];Nx(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 Kx(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Kx(e,t.id,n)])}function qx(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 Jx(e){return`data-base-ui-${e}`}var Yx=0;function Xx(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Yx);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),ov;let o=requestAnimationFrame(a);return Yx=o,()=>{Yx===o&&(cancelAnimationFrame(o),Yx=0)}}var Zx={inert:new WeakMap,"aria-hidden":new WeakMap},Qx=`data-base-ui-inert`,$x={inert:new WeakSet,"aria-hidden":new WeakSet},eS=new WeakMap,tS=0;function nS(e){return $x[e]}function rS(e){return e?Wv(e)?e.host:rS(e.parentNode):null}var iS=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=rS(t);return e.contains(n)?n:null}).filter(e=>e!=null),aS=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},oS=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{Rv(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function sS(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=iS(t,e),l=i?oS(t,aS(c),new Set(c)):[],u=[],d=[];if(a){let e=Zx[a],n=nS(a);s=n,o=e;let r=iS(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);oS(t,aS(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=(eS.get(e)||0)+1;eS.set(e,t),d.push(e),t===1&&e.setAttribute(Qx,``)}),tS+=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=(eS.get(e)||0)-1;eS.set(e,t),t||e.removeAttribute(Qx)}),--tS,tS||(Zx.inert=new WeakMap,Zx[`aria-hidden`]=new WeakMap,$x.inert=new WeakSet,$x[`aria-hidden`]=new WeakSet,eS=new WeakMap)}}function cS(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=Ib(e[0]).body;return sS(e,a,n,r,{mark:i})}var lS=0;function uS(e,t=`mui`){let[n,r]=W.useState(e),i=e||n;return W.useEffect(()=>{n??(lS+=1,r(`${t}-${lS}`))},[n,t]),i}var dS=Db.useId;function fS(e,t){if(dS!==void 0){let n=dS();return e??(t?`${t}-${n}`:n)}return uS(e,t)}var pS=19;function mS(e){return pS>=e}function hS(e){if(!W.isValidElement(e))return null;let t=e,n=t.props;return(mS(19)?n?.ref:t.ref)??null}function gS(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function _S(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 vS(e,t){return typeof e==`function`?e(t):e}function yS(e,t){return typeof e==`function`?e(t):e}var bS={};function xS(e,t,n,r,i){if(!n&&!r&&!i&&!e)return CS(t);let a=CS(e);return t&&(a=wS(a,t)),n&&(a=wS(a,n)),r&&(a=wS(a,r)),i&&(a=wS(a,i)),a}function SS(e){if(e.length===0)return bS;if(e.length===1)return CS(e[0]);let t=CS(e[0]);for(let n=1;n<e.length;n+=1)t=wS(t,e[n]);return t}function CS(e){return OS(e)?{...kS(e,bS)}:TS(e)}function wS(e,t){return OS(t)?kS(t,e):ES(e,t)}function TS(e){let t={...e};for(let e in t){let n=t[e];DS(e,n)&&(t[e]=jS(n))}return t}function ES(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=gS(e.style,r);break;case`className`:e[n]=NS(e.className,r);break;default:e[n]=DS(n,r)?AS(e[n],r):r}}return e}function DS(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 OS(e){return typeof e==`function`}function kS(e,t){return OS(e)?e(t):e??bS}function AS(e,t){return t?e?(...n)=>{let r=n[0];if(PS(r)){let i=r;MS(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:jS(t):e}function jS(e){return e&&((...t)=>{let n=t[0];return PS(n)&&MS(n),e(...t)})}function MS(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function NS(e,t){return t?e?t+` `+e:t:e}function PS(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function FS(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=zS(r));let i=IS(t,n,r);if(n.enabled===!1)return null;let a=n.state??cv;return BS(e,r,i,a)}function IS(e,t,n){let{className:r,style:i}=e,{state:a=cv,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?vS(r,a):void 0,d=l?yS(i,a):void 0,f=l?_S(a,c):cv,p=l&&s?LS(s):void 0,m=l?gS(f,p)??{}:cv;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?bb([m.ref,hS(n),...o]):yb(m.ref,hS(n),o):yb(null,null)),l?(u!==void 0&&(m.className=NS(m.className,u)),d!==void 0&&(m.style=gS(m.style,d)),m):cv}function LS(e){return Array.isArray(e)?SS(e):xS(void 0,e)}var RS=Symbol.for(`react.lazy`);function zS(e){if(e?.$$typeof!==RS)return e;let t=W.Children.toArray(e)[0];return W.isValidElement(t)?t:e}function BS(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=xS(n,t.props);return e.ref=n.ref,W.cloneElement(t,e)}if(e&&typeof e==`string`)return VS(e,n);throw Error(uv(8))}function VS(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 HS={style:{transition:`none`}},US=`data-base-ui-click-trigger`,WS=`data-base-ui-swipe-ignore`,GS=`data-swipe-ignore`,KS=`[${WS}]`;`${GS}`;var qS={fallbackAxisSide:`none`},JS={fallbackAxisSide:`end`},YS={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},XS=c(m(),1),ZS=W.createContext(null),QS=()=>W.useContext(ZS),$S=Jx(`portal`);function eC(e={}){let{ref:t,container:n,componentProps:r=cv,elementProps:i}=e,a=fS(),o=QS()?.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&&(Vv(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=FS(`div`,r,{ref:[t,d],props:[{id:a,[$S]:``},i]}),m=s&&p?XS.createPortal(p,s):null;return{node:l,nodeId:W.isValidElement(p)?p.props.id:void 0,subtree:m}}var tC=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}=eC({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&&Ux(e)&&(e.type===`focusin`?v.current&&=(Gx(l),!1):(Wx(l),v.current=!0))}return vb(_b(l,`focusin`,e,!0),_b(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)(ZS.Provider,{value:S,children:[x&&l&&(0,Z.jsx)(Bb,{"data-type":`outside`,ref:f,onFocus:e=>{Ux(e,l)?m.current?.focus():zx(g?g.domReference:null)?.focus()}}),x&&l&&(0,Z.jsx)(`span`,{role:s,"aria-owns":u,style:YS}),l&&XS.createPortal(a,l),x&&l&&(0,Z.jsx)(Bb,{"data-type":`outside`,ref:p,onFocus:e=>{Ux(e,l)?h.current?.focus():(Rx(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,pb(`focus-out`,e.nativeEvent)))}})]})]})});function nC(){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 rC=class{nodesRef={current:[]};events=nC();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)}},iC=W.createContext(null),aC=W.createContext(null),oC=()=>W.useContext(iC)?.id||null,sC=e=>{let t=W.useContext(aC);return e??t};function cC(e){let t=fS(),n=sC(e),r=oC();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function lC(e){let{children:t,id:n}=e,r=oC();return(0,Z.jsx)(iC.Provider,{value:W.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function uC(e){let{children:t,externalTree:n}=e,r=Q_(()=>n??new rC).current;return(0,Z.jsx)(aC.Provider,{value:r,children:t})}function dC(e){return e==null?e:`current`in e?e.current:e}function fC(e,t){let n=zv(uy(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 pC=20,mC=[];function hC(){mC=mC.filter(e=>e.deref()?.isConnected)}function gC(e){hC(),e&&Rv(e)!==`body`&&(mC.push(new WeakRef(e)),mC.length>pC&&(mC=mC.slice(-20)))}function _C(){return hC(),mC[mC.length-1]?.deref()}function vC(e){return e?Px(e)?e:Ix(e)[0]||e:null}function yC(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Fx(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Px(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 bC(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=Hy(_)&&S,w=Tb(i),T=Tb(a),E=Tb(l),D=Tb(g),O=sC(p),k=QS(),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=yb(I,f,k?.beforeInsideRef),ee=yb(L,k?.afterInsideRef),z=gv(),te=gv(),ne=Fb(),re=k!=null,B=Wy(v),ie=Q((e=B)=>e?Ix(e):[]),ae=Q(()=>m?.().filter(e=>e!=null)??[]);W.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&ly(B,cy(Ib(B)))&&ie().length===0&&!C&&jv(e)}return _b(Ib(B),`keydown`,e)},[r,B,s,C,ie]),W.useEffect(()=>{if(r||!g)return;let e=Ib(B);function t(){M.current=!1}function n(e){let t=uy(e),n=ae(),r=ly(v,t)||ly(_,t)||ly(k?.portalNode,t)||n.some(e=>e===t||ly(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 vb(_b(e,`pointerdown`,n,!0),_b(e,`pointerup`,t,!0),_b(e,`pointercancel`,t,!0),_b(e,`keydown`,i,!0),t)},[r,v,_,B,g,k,te,ae]),W.useEffect(()=>{if(r||!c)return;let e=Ib(B);function t(){j.current=!0,te.start(0,()=>{j.current=!1})}function n(e){let t=uy(e);Px(t)&&(N.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=uy(t);s&&n==null&&i!=null&&ly(v,i)&&gC(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=ae(),f=n?.hasAttribute(Jx(`focus-guard`))&&[I.current,L.current,k?.beforeInsideRef.current,k?.afterInsideRef.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,dC(d),dC(u)].includes(n),p=!(ly(_,n)||ly(v,n)||ly(n,v)||ly(k?.portalNode,n)||l.some(e=>e===n||ly(e,n))||c.hasMatchingElement(e=>ly(e,n))||f||O&&(Kx(O.nodesRef.current,a).find(e=>ly(e.context?.elements.floating,n)||ly(e.context?.elements.domReference,n))||qx(O.nodesRef.current,a).find(e=>[e.context?.elements.floating,Wy(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&B&&yC(B),o&&r!==_&&!bx(i)&&cy(e)===e.body){if(Uv(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;Uv(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!s)&&n&&p&&!j.current&&(C||n!==_C())&&(A.current=!0,h.setOpen(!1,pb(rb,t)))})}function a(){M.current||(b.current.insideReactTree=!0,z.start(0,()=>{b.current.insideReactTree=!1}))}let l=Uv(_)?_:null;if(v||l)return vb(l&&_b(l,`focusout`,i),l&&_b(l,`pointerdown`,t),v&&_b(v,`focusin`,n),v&&_b(v,`focusout`,i),v&&k&&_b(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(`[${Jx(`portal`)}]`)||[]),t=(O?qx(O.nodesRef.current,x()):[]).find(e=>Hy(e.context?.elements.domReference||null))?.context?.elements.domReference,n=cS([v,...e,I.current,L.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,...ae(),t,dC(d),dC(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=cS([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,k,C,O,x,u,d,ae]),X(()=>{if(!g||r||!Uv(B))return;P.current=``,F.current=``;let e=Ib(B),t=cy(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||ly(B,t))return;let i=null,a=()=>(i??=ie(B),i[0]||B),o;o=r===!0||r===null?a():dC(r),o||=a();let s=ly(B,cy(e));Xx(o,{preventScroll:o===B,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=cy(e);return!(t!==o&&ly(B,t))}})})},[r,g,B,ie,w,E,D]),X(()=>{if(r||!B)return;let e=Ib(B),t=cy(e),n=E.current==null;gC(t);function i(e){if(e.open||(P.current=fC(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(Nv(e.nativeEvent)||Pv(e.nativeEvent))A.current=!1;else{let e=!1;Ib(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&&Rv(t)!==`body`?t:null,s=n?o||a:a||o;return s||=_C()||null,typeof i==`boolean`?s:dC(i)||s||null}return()=>{y.off(`openchange`,i);let t=cy(e),n=ae(),r=ly(v,t)||n.some(e=>e===t||ly(e,t))||O&&Kx(O.nodesRef.current,x(),!1).some(e=>ly(e.context?.elements.floating,t)),o=T.current,s=P.current,c=a(s);queueMicrotask(()=>{let n=vC(c),i=typeof o!=`boolean`;if(o&&!A.current&&Uv(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(!Ov||g||!v)return;let e=cy(Ib(v));Uv(e)&&By(e)&&ly(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 yC(B),()=>{queueMicrotask(hC)}},[r,B]);let oe=!r&&(!s||!C)&&(re||s);return(0,Z.jsxs)(W.Fragment,{children:[oe&&(0,Z.jsx)(Bb,{"data-type":`inside`,ref:R,onFocus:e=>{if(s){let e=ie();Xx(e[e.length-1])}else k?.portalNode&&(A.current=!1,Ux(e,k.portalNode)?Rx(_)?.focus():dC(d??k.beforeOutsideRef)?.focus())}}),n,oe&&(0,Z.jsx)(Bb,{"data-type":`inside`,ref:ee,onFocus:e=>{s?Xx(ie()[0]):k?.portalNode&&(c&&(A.current=!0),Ux(e,k.portalNode)?zx(_)?.focus():dC(u??k.afterOutsideRef)?.focus())}})]})}function xC(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Zy}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=W.useRef(void 0),f=Fb(),p=gv(),m=W.useMemo(()=>{function e(e,t,n,r){let i=pb(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=Fv(e.pointerType,!0)&&Pv(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||Fv(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=uy(o);if(By(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}Fv(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}:cv,[n,m])}function SC(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 CC(e){return e!=null&&e.clientX!=null}function wC(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||CC(c.current.openEvent))&&i.set(`positionReference`,SC(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=Fv(d)?o:a;W.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=zv(o);function r(t){let n=uy(t);ly(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||CC(c.current.openEvent)?u.current=_b(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 TC(){return!1}function EC(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function DC(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=TC,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=sC(c),h=Q(typeof i==`function`?i:()=>!1),g=typeof i==`function`?h:i,_=g!==!1,v=Q(()=>a),{escapeKey:y,outsidePress:b}=EC(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=gv(),k=gv(),A=Q(()=>{k.clear(),f.current.insideReactTree=!1}),j=Q(e=>{let t=f.current.floatingContext?.nodeId;return(m?Kx(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=Q(e=>Ry(e,l.select(`floatingElement`))||Ry(e,l.select(`domReferenceElement`))),N=Q(e=>{o()&&l.setOpen(!1,pb(Zy,e.nativeEvent))}),P=Q(e=>{if(!u||!n||!r||e.key!==`Escape`||T.current||!y&&j(`__escapeKeyBubbles`))return;let t=pb(ib,Mv(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=uy(e.nativeEvent);ly(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 hv,t=new hv,i=Ib(d);function a(){e.clear(),T.current=!0}function o(){e.start(Ov?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&&Kx(m.nodesRef.current,t).some(t=>Ry(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=uy(e),r=`[${Jx(`inert`)}]`,i=Hv(n)?n.getRootNode():null,a=Array.from((Wv(i)?i:Ib(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>ly(e,n))))return;let s=Hv(n)?n:null;for(;s&&!ty(s);){let e=iy(s);if(ty(e)||!Hv(e))break;s=e}if(!(a.length&&Hv(n)&&!zy(n)&&!ly(n,l.select(`floatingElement`))&&a.every(e=>!ly(s,e)))){if(Uv(n)&&!(`touches`in e)){let t=ty(n),r=ny(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&&!Nv(e)&&!w.current)return;if(C.current){t.clear(),C.current=!1;return}}(typeof g!=`function`||g(e))&&(j(`__outsidePressBubbles`)||(l.setOpen(!1,pb(eb,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=uy(e);if(!n)return;let r=_b(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=vb(r&&vb(_b(i,`keydown`,P),_b(i,`compositionstart`,a),_b(i,`compositionend`,o)),_&&vb(_b(i,`click`,ee,!0),_b(i,`pointerdown`,ee,!0),_b(i,`pointerup`,z,!0),_b(i,`pointercancel`,z,!0),_b(i,`mousedown`,ee,!0),_b(i,`mouseup`,z,!0),_b(i,`touchstart`,R,{capture:!0,passive:!0}),_b(i,`touchmove`,ne,{capture:!0,passive:!0}),_b(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 OC(e,t,n){let{reference:r,floating:i}=e,a=$b(t),o=ex(t),s=Qb(o),c=Yb(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 kC(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}=Jb(t,e),p=fx(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=px(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=px(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 AC=50,jC=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:kC},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=OC(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<AC&&(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}=OC(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},MC=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}=Jb(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Yb(r),_=$b(o),v=Yb(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[ux(o)]:nx(o)),x=p!==`none`;!d&&x&&b.push(...lx(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=tx(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`||_===$b(t)||T.every(e=>$b(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=$b(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{}}}},NC=new Set([`left`,`top`]);async function PC(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Yb(n),s=Xb(n),c=$b(n)===`y`,l=NC.has(o)?-1:1,u=a&&c?-1:1,d=Jb(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 FC=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 PC(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}}}}},IC=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}=Jb(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=$b(i),p=Zb(f),m=u[p],h=u[f],g=(e,t)=>qb(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}=Jb(e,t),u={x:n,y:r},d=$b(i),f=Zb(d),p=u[f],m=u[d],h=Jb(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=NC.has(Yb(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}}}},RC=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}=Jb(e,t),c=await i.detectOverflow(t,s),l=Yb(n),u=Xb(n),d=$b(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=Vb(p-c[m],g),y=Vb(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*Hb(c.left,c.right):S=p-2*Hb(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 zC(e){let t=ny(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Uv(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Ub(n)!==a||Ub(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function BC(e){return Hv(e)?e:e.contextElement}function VC(e){let t=BC(e);if(!Uv(t))return Gb(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=zC(t),o=(a?Ub(n.width):n.width)/r,s=(a?Ub(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var HC=Gb(0);function UC(e){let t=zv(e);return!ey()||!t.visualViewport?HC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function WC(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===zv(e)}function GC(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=BC(e),o=Gb(1);t&&(r?Hv(r)&&(o=VC(r)):o=VC(e));let s=WC(a,n,r)?UC(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=zv(a),t=Hv(r)?zv(r):r,n=e,i=sy(n);for(;i&&t!==n;){let e=VC(i),t=i.getBoundingClientRect(),r=ny(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=zv(i),i=sy(n)}}return px({width:u,height:d,x:c,y:l})}function KC(e,t){let n=ry(e).scrollLeft;return t?t.left+n:GC(Bv(e)).left+n}function qC(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-KC(e,n),y:n.top+t.scrollTop}}function JC(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Bv(r),s=t?qv(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Gb(1),u=Gb(0),d=Uv(r);if((d||!a)&&((Rv(r)!==`body`||Gv(o))&&(c=ry(r)),d)){let e=GC(r);l=VC(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?qC(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 YC(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function XC(e){let t=ry(e),n=e.ownerDocument.body,r=Hb(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Hb(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+KC(e),o=-t.scrollTop;return ny(n).direction===`rtl`&&(a+=Hb(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var ZC=25;function QC(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=zv(e),a=Bv(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ey()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(KC(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<=ZC&&(s-=o)}return{width:s,height:c,x:l,y:u}}function $C(e,t){let n=GC(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=VC(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function ew(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=QC(e,n,t);else if(t===`document`)r=XC(Bv(e));else if(Hv(t))r=$C(t,n);else{let n=UC(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return px(r)}function tw(e,t){let n=t.get(e);if(n)return n;let r=oy(e,[],!1).filter(e=>Hv(e)&&Rv(e)!==`body`),i=null,a=ny(e).position===`fixed`,o=a?iy(e):e;for(;Hv(o)&&!ty(o);){let e=ny(o),t=Qv(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=iy(o)}return t.set(e,r),r}function nw(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?qv(t)?[]:tw(t,this._c):[].concat(n),r],o=ew(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=ew(t,a[e],i);s=Hb(n.top,s),c=Vb(n.right,c),l=Vb(n.bottom,l),u=Hb(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function rw(e){let{width:t,height:n}=zC(e);return{width:t,height:n}}function iw(e,t,n){let r=Uv(t),i=Bv(t),a=n===`fixed`,o=GC(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Gb(0);if((r||!a)&&((Rv(t)!==`body`||Gv(i))&&(s=ry(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=KC(i));let l=i&&!r&&!a?qC(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 aw(e){return ny(e).position===`static`}function ow(e,t){if(!Uv(e)||ny(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Bv(e)===n&&(n=n.ownerDocument.body),n}function sw(e,t){let n=zv(e);if(qv(e))return n;if(!Uv(e)){let t=iy(e);for(;t&&!ty(t);){if(Hv(t)&&!aw(t))return t;t=iy(t)}return n}let r=ow(e,t);for(;r&&Kv(r)&&aw(r);)r=ow(r,t);return r&&ty(r)&&aw(r)&&!Qv(r)?n:r||$v(e)||n}var cw=async function(e){let t=this.getOffsetParent||sw,n=this.getDimensions,r=await n(e.floating);return{reference:iw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function lw(e){return ny(e).direction===`rtl`}var uw={convertOffsetParentRelativeRectToViewportRelativeRect:JC,getDocumentElement:Bv,getClippingRect:nw,getOffsetParent:sw,getElementRects:cw,getClientRects:YC,getDimensions:rw,getScale:VC,isElement:Hv,isRTL:lw};function dw(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function fw(e,t,n){let r=null,i,a=Bv(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=Wb(d),h=Wb(a.clientWidth-(u+f)),g=Wb(a.clientHeight-(d+p)),_=Wb(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Hb(0,Vb(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!dw(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=zv(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function pw(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=BC(e),u=i||a?[...l?oy(l):[],...t?oy(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?fw(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&&!dw(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 mw=FC,hw=IC,gw=MC,_w=RC,vw=LC,yw=(e,t,n)=>{let r=new Map,i=n??{},a={...uw,...i.platform,_c:r};return jC(e,t,{...i,platform:a})},bw=typeof document<`u`?W.useLayoutEffect:function(){};function xw(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(!xw(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)&&!xw(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Sw(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Cw(e,t){let n=Sw(e);return Math.round(t*n)/n}function ww(e){let t=W.useRef(e);return bw(()=>{t.current=e}),t}function Tw(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);xw(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=ww(c),D=ww(i),O=ww(l),k=W.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),yw(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!xw(w.current,t)&&(w.current=t,XS.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);bw(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=W.useRef(!1);bw(()=>(A.current=!0,()=>{A.current=!1}),[]),bw(()=>{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=Cw(M.floating,u.x),r=Cw(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Sw(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 Ew=(e,t)=>{let n=mw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dw=(e,t)=>{let n=hw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ow=(e,t)=>({fn:vw(e).fn,options:[e,t]}),kw=(e,t)=>{let n=gw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Aw=(e,t)=>{let n=_w(e);return{name:n.name,fn:n.fn,options:[e,t]}},jw=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})),Mw=o(((e,t)=>{t.exports=jw()})),Nw=o((e=>{var t=u(),n=Mw();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}})),Pw=o(((e,t)=>{t.exports=Nw()})),Fw=Mw(),Iw=Pw(),Lw=mS(19)?Bw:Vw;function Rw(e,t,n,r,i){return Lw(e,t,n,r,i)}function zw(e,t,n,r,i){let a=W.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,Fw.useSyncExternalStore)(e.subscribe,a,a)}nv({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,Fw.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Bw(e,t,n,r,i){let a=tv();if(!a)return zw(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 Vw(e,t,n,r,i){return(0,Iw.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Hw=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 Rw(this,e,t,n,r)}},Uw=class extends Hw{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),Rw(this,this.selectors[e],t,n,r)}useContextCallback(e,t){W.useDebugValue(e);let n=Q(t??ov);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)}})}},Ww={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 Uw{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:nC(),nested:n,triggerElements:i},Ww),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Iv(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 Kw(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};Hv(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 qw(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=Pb.request(()=>{a(`ending`)});return()=>{Pb.cancel(e)}}},[e,o,i,n]),X(()=>{if(!e||t)return;let n=Pb.request(()=>{a(void 0)});return()=>{Pb.cancel(n)}},[t,e]),X(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=Pb.request(()=>{a(`idle`)});return()=>{Pb.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var Jw=null;function Yw(e){if(!Jw){let e=[];Jw=e,queueMicrotask(()=>{Jw=null,XS.flushSync(()=>{for(let t of e)t()})})}Jw.push(e)}function Xw(e,t=!1,n=!1){let r=Fb();return Q((i,a=null)=>{r.cancel();let o=dC(e);if(o==null)return;let s=o,c=()=>{if(!n){XS.flushSync(i);return}Yw(()=>{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=_y;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 Zw(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 Qw={tabIndex:-1,[dy]:``};function $w(e){return t=>t!==`touch`||e.current}function eT(e,t=!1){let n=fS(),r=oC()!=null,i=Q_(()=>e(n,r)).current;return Kw({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function tT({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function nT(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function rT(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),nT(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),nT(t))})}function iT(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 aT(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function oT(e,t,n,r={}){let i=n.reason,a=i===Qy,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=aT(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=iT(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 sT(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=rT(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 cT(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=pb(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 lT(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=qw(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 Zw({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function uT(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:cv,inactiveTriggerProps:cv,popupProps:cv})},[e])}function dT(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 fT=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 pT(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:cv,inactiveTriggerProps:cv,popupProps:cv}}var mT=e=>e.triggerIdProp??e.activeTriggerId,hT=e=>e.openProp??e.open,gT=e=>(e.popupElement?.id??e.floatingId)||void 0;function _T(e,t){return t!==void 0&&hT(e)&&mT(e)===t}function vT(e,t){return _T(e,t)?!0:t!==void 0&&hT(e)&&mT(e)==null&&e.triggerCount===1}var yT={open:hT,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:mT,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:gT,isTriggerActive:(e,t)=>t!==void 0&&mT(e)===t,isOpenedByTrigger:(e,t)=>_T(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&mT(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>vT(e,t)?gT(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function bT(e){let t=W.useCallback(t=>e===void 0?ov:e.subscribeStore(t),[e]),n=W.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,Fw.useSyncExternalStore)(t,n,()=>e?.serverStore)}function xT(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=fS(),a=oC()!=null,o=Q_(()=>new Gw({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new fT,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=Hv(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 ST(e){return CT(e,e.rootContext)}function CT(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=sC(r),_=W.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=Tw({...e,elements:{..._,...l&&{reference:l}}}),y=Hv(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=Hv(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=W.useCallback(e=>{(Hv(e)||e===null)&&(h.current=e,f(e)),(Hv(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!Hv(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 wT=Ev&&Ov;function TT(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=gv();W.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=zv(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&Uv(e)&&e===cy(Ib(e))&&(s.current=!0,c.current=e)}function a(){l.current=!0}function o(){l.current=!1}return vb(_b(t,`blur`,r),wT&&_b(t,`keydown`,a,!0),wT&&_b(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`);Hv(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=uy(t.nativeEvent);if(Hv(a)){if(wT&&!t.relatedTarget){if(!l.current&&!By(a))return}else if(!Uy(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,pb($y,d,f));return}u.start(p,()=>{s.current||i.setOpen(!0,pb($y,d,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=Hv(n)&&n.hasAttribute(Jx(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=cy(Ib(e));(n||t!==e)&&(ly(o.current.floatingContext?.refs.floating.current,t)||ly(e,t)||a||Ly(n??t,i.context.triggerElements)||i.setOpen(!1,pb($y,r)))})}}},[o,r,i,u]);return W.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var ET=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 hv,this.restTimeout=new hv,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},DT=new WeakMap;function OT(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&DT.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),DT.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function kT(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=DT.get(n);a&&a!==e&&OT(a),OT(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,DT.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function AT(e){let t=e.context.dataRef.current,n=Q_(()=>t.hoverInteractionState??ET.create()).current;return t.hoverInteractionState||=n,pv(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function jT(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=sC(),d=oC(),f=AT(a),p=gv(),m=Q(()=>Jy(l.current.openEvent?.type,f.interactedInside)),h=Q(()=>Yy(l.current.openEvent?.type)),g=Q(()=>{OT(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()&&Hv(c)&&s){let e=c,t=s,n=Ib(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 kT(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&&Kx(u.nodesRef.current,d).length>0)}function t(e){let t=Ky(r,`close`,f.pointerType),n=()=>{a.setOpen(!1,pb(Qy,e)),u?.events.emit(`floating.closed`,e)};t?f.openChangeTimeout.start(t,n):(f.openChangeTimeout.clear(),n())}function o(e){let t=uy(e);if(!Vy(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&&Hv(o)&&Kx(u.nodesRef.current,r,!1).some(e=>ly(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,pb(Qy,t)),u.events.emit(`floating.closed`,t)})}let y=s;return vb(y&&_b(y,`mouseenter`,c),y&&_b(y,`mouseleave`,_),y&&_b(y,`pointerdown`,o,!0),()=>{u?.events.off(`floating.closed`,v)})},[n,s,a,l,r,i,h,m,g,f,u,d,p])}var MT={current:null};function NT(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=MT,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=sC(l),y=AT(h),b=W.useRef(!1),x=Tb(i),S=Tb(r),C=Tb(o),w=Tb(n),T=Tb(p),E=Tb(f),D=Q(()=>Jy(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||!ly(e,t);if(!Hv(n))return!1;let i=n;return r.hasMatchingElement(e=>ly(e,i))&&(!e||!ly(e,i))}),A=Q(()=>{y.handler&&=(Ib(h.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),j=Q(()=>{OT(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===Qy,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=Ky(S.current,`close`,y.pointerType);n?y.openChangeTimeout.start(n,()=>{h.setOpen(!1,pb(Qy,e)),v?.events.emit(`floating.closed`,e)}):t&&(y.openChangeTimeout.clear(),h.setOpen(!1,pb(Qy,e)),v?.events.emit(`floating.closed`,e))}let t=c.current??(u?h.select(`domReferenceElement`):null);if(!Hv(t))return;function r(e){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!Fv(y.pointerType))return;let t=qy(C.current),n=Ky(S.current,`open`,y.pointerType),r=uy(e),i=e.currentTarget??null,o=h.select(`domReferenceElement`),s=i;if(Hv(r)&&!h.context.triggerElements.hasElement(r)){for(let e of h.context.triggerElements.elements())if(ly(e,r)){s=e;break}}Hv(i)&&Hv(o)&&!h.context.triggerElements.hasElement(i)&&ly(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&&Hv(s)&&Hv(o)&&ly(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,g=!l||c;if(m){O()&&h.setOpen(!0,pb(Qy,e,s));return}p||(n?y.openChangeTimeout.start(n,()=>{g&&O()&&h.setOpen(!0,pb(Qy,e,s))}):g&&O()&&h.setOpen(!0,pb(Qy,e,s)))}function i(t){if(D()){j();return}A();let n=Ib(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`||!ly(h.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){ly(t,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let l=m?_b(t,`mouseout`,o):void 0;return s?vb(_b(t,`mousemove`,r,{once:!0}),_b(t,`mouseenter`,r),_b(t,`mouseleave`,i),l):vb(_b(t,`mouseenter`,r),_b(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&&!Fv(y.pointerType))return;if(i&&o&&y.handleCloseOptions?.blockPointerEvents){let e=h.select(`floatingElement`);if(e){let t=y.handleCloseOptions?.getScope?.()??n.ownerDocument.body;kT(y,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=qy(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,pb(Qy,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 PT=`Escape`;function FT(e){return Ov&&e.movementX===0&&e.movementY===0}function IT(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function LT(e,t){return IT(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function RT(e,t,n){return IT(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function zT(e,t,n){return IT(t,n?e===py:e===my,e===gy)}function BT(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===PT:IT(t,n?e===my:e===py,e===hy)}function VT(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=Wy(T),k=Hy(E),A=Tb(O),j=oC(),M=sC(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=Tb(h),B=Tb(w),ie=Tb(o),ae=Tb(y),oe=Fb(),se=Fb(),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||RT(F.current,g,u)||l?hx(n):gx(n),F.current=null,L())};t()}}else mx(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=cy(Ib(E??t??null)),r=e.some(e=>e.context&&ly(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(()=>hx(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&&BT(e.key,g,u,S)){LT(e.key,H())||jv(e),C.setOpen(!1,pb(ob,e.nativeEvent)),Uv(E)&&(d?M?.events.emit(`virtualfocus`,E):E.focus());return}let t=P.current,r=hx(n,h),i=gx(n,h);if(k||(e.key===`Home`&&(jv(e),P.current=r,L(e)),e.key===`End`&&(jv(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(jv(e),w&&!d&&cy(e.currentTarget.ownerDocument)===e.currentTarget){P.current=RT(e.key,g,u)?r:i,L(e);return}RT(e.key,g,u)?c?t>=i?s&&t!==n.current.length?P.current=-1:(z.current=!1,P.current=r):P.current=_x(n.current,{startingIndex:t,disabledIndices:h}):P.current=Math.min(i,_x(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=_x(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):P.current=Math.max(r,_x(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),mx(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){FT(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=cy(Ib(e));e&&ly(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=uy(e.nativeEvent);if(t&&!ly(A.current,t))return;jv(e),C.setOpen(!1,pb(rb,e.nativeEvent)),Uv(E)&&E.focus();return}de(e)},onPointerMove(e){FT(e)||(I.current=!0)}}),[U,de,A,k,C,w,d,E]),me=W.useMemo(()=>{function e(e){C.setOpen(!0,pb(ob,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&Nv(e.nativeEvent)&&(N.current=!d)}function n(e){N.current=f,f===`auto`&&Pv(e.nativeEvent)&&(N.current=!0)}return{onKeyDown(t){let n=C.select(`open`);I.current=!1;let r=t.key.startsWith(`Arrow`),i=zT(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&&(jv(t),n?(P.current=ue(),L(t)):e(t));return}a&&(ie.current!=null&&(P.current=ie.current),jv(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 HT(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=gv(),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&&!bx(n)||n?.matches(`:disabled`)?!1:o==null||!vx(sv,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===` `&&(jv(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!==` `&&(jv(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`);ly(n,t)||ly(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 UT=.1,WT=UT*UT,GT=.5;function KT(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function qT(e,t,n,r,i,a,o,s,c,l){let u=!1;return KT(e,t,n,r,i,a)&&(u=!u),KT(e,t,i,a,o,s)&&(u=!u),KT(e,t,o,s,c,l)&&(u=!u),KT(e,t,c,l,n,r)&&(u=!u),u}function JT(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function YT(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 hv,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*WT;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=uy(r),g=r.type===`mouseleave`,_=ly(u,h),v=ly(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Hv(r.relatedTarget)&&ly(u,r.relatedTarget))return;function y(){return!!(s&&Kx(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=YT(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=YT(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=YT(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=YT(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!JT(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=qT(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=qT(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=qT(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=qT(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 ZT={...yT,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},QT=class extends Uw{constructor(e,t,n){let r=new fT;super($T(e,r,t,n),eE(r),ZT)}setOpen=(e,t)=>{oT(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,pb(Zy,e))}};function $T(e,t,n,r=!1){return{...pT(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 eE(e){return{popupRef:W.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var tE=rv(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=eT((e,t)=>new QT({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}),cT(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=lT(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=W.useRef(null);X(()=>{m&&t&&p.setOpen(!1,pb(lb))},[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,pb(ub))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,Z.jsxs)(dv.Provider,{value:p,children:[l&&(0,Z.jsx)(tT,{handle:l,store:p}),T&&(0,Z.jsx)(nE,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function nE({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=DC(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=wC(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=W.useMemo(()=>xS(a.reference,i.reference),[a.reference,i.reference]);return uT(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??cv}),null}function rE(e){return fS(e,`base-ui`)}var iE=W.createContext(void 0);function aE(){return W.useContext(iE)}var oE=`data-base-ui-tooltip-trigger`;function sE(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(Hv(n))return n}}let t=e.target;return Hv(t)?t:null}function cE(e){let t=e;for(;t;){let e=t.closest(`[${oE}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&Hv(n.host)?n.host:null}return null}var lE=iv(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=fv(!0),m=bT(a)??p;if(!m)throw Error(uv(82));let h=rE(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}=sT(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=aE(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=gb(v,{open:_}),O=AT(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Tb(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=W.useRef(!1),F=gv(),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=cE(e);return n!==null&&n!==t&&ly(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=NT(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?XT():null,restMs:L,delay(){return u==null&&D?{close:Ky(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),te=TT(v,{enabled:!A}).reference,ne=e=>{let t=P.current,n=sE(e),r=ee(n),i=y.current,a=i&&n&&ly(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`){m.setOpen(!1,pb(Qy,e));return}if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&Fv(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,pb(Qy,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},re=m.useState(`triggerProps`,S);return FS(`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(sE(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,[Iy]:A?``:void 0,[oE]:A?void 0:``},f],stateAttributesMapping:My})}),uE=W.createContext(void 0);function dE(){let e=W.useContext(uE);if(e===void 0)throw Error(uv(70));return e}var fE=W.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=eC({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,Z.jsxs)(W.Fragment,{children:[l,c&&XS.createPortal(n,c)]})}),pE=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return fv().useState(`mounted`)||n?(0,Z.jsx)(uE.Provider,{value:n,children:(0,Z.jsx)(fE,{ref:t,...r})}):null}),mE=W.createContext(void 0);function hE(){let e=W.useContext(mE);if(e===void 0)throw Error(uv(71));return e}var gE=W.createContext(void 0);function _E(){return W.useContext(gE)?.direction??`ltr`}var vE=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`}=Jb(e,t)||{};if(l==null)return{};let f=fx(u),p={x:n,y:r},m=ex(i),h=Qb(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=qb(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}}}),yE=(e,t)=>{let{name:n,fn:r}=vE(e);return{name:n,fn:r,options:[e,t]}},bE={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}}}},xE={sideX:`left`,sideY:`top`},SE=`--available-width`,CE=`--available-height`,wE=`--anchor-width`,TE=`--anchor-height`,EE=`--transform-origin`,DE=SE,OE=CE;function kE(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 AE(e,t,n){let{rects:r,placement:i}=e;return{side:kE(t,Yb(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 jE(e){return ME(e,ST)}function ME(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=Tb(n),P=Tb(g),F=_E()===`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=Tb(a),ae=Tb(s),oe=typeof a==`function`?0:a,se=typeof s==`function`?0:s,ce=[];p&&ce.push(p),ce.push(Ew(e=>{let t=AE(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:kw({...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:Dw({...re,rootBoundary:k,mainAxis:E!==`none`,crossAxis:V,limiter:u||O?void 0:Ow(e=>{if(!B.current)return{};let{width:t,height:n}=B.current.getBoundingClientRect(),r=$b(Yb(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(Aw({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(DE,`${t}px`),i.setProperty(OE,`${n}px`);let a=zv(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(wE,`${u}px`),i.setProperty(TE,`${d}px`)}}),yE(e=>({element:B.current||Ib(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=Yb(r),u=Xb(r),d=$b(l)===`y`,f=B.current,p=typeof a==`function`?a(AE(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(EE,d?`${m} ${h}`:`${h} ${m}`),{}}},bE,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)=>pw(...e,de),nodeId:y,externalTree:S}),{sideX:xe,sideY:Se}=he.adaptiveOrigin||xE,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[DE]=`100vw`,e[OE]=`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=(NE(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`&&NE(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 pw(U.reference,U.floating,ge,de)},[m,g,U,ge,de]);let Ee=Yb(_e),De=kE(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 NE(e){return e!=null&&`current`in e}function PE(e){return e===`starting`?HS:cv}function FE(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),FS(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},PE(r),i],stateAttributesMapping:Py})}var IE=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=JS,style:g,..._}=e,v=fv(),y=dE(),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=jE({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=FE(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)(mE.Provider,{value:D,children:O})}),LE=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=fv(),{side:s,align:c}=hE(),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`);Zw({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),jT(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return FS(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[Qw,f,PE(d),a],stateAttributesMapping:Fy})});function RE(e){return mS(19)?e:e?`true`:void 0}function zE(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 BE(e){let t=W.useRef(!0);t.current&&(t.current=!1,e())}function VE(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function HE({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 UE=W.createContext(void 0),WE=W.createContext(void 0),GE=W.createContext(void 0);function KE(){let e=W.useContext(UE);if(e===void 0)throw Error(uv(60));return e}function qE(){let e=W.useContext(WE);if(e===void 0)throw Error(uv(101));return e}function JE(){let e=W.useContext(GE);if(e===void 0)throw Error(uv(61));return e}var YE=`data-valid`,XE=`data-invalid`,ZE={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},QE={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},$E={valid(e){return e===null?null:e?{[YE]:``}:{[XE]:``}}},eD={invalid:void 0,name:void 0,validityData:{state:ZE,errors:[],error:``,value:``,initialValue:null},setValidityData:ov,disabled:void 0,setTouched:ov,setDirty:ov,setFilled:ov,setFocused:ov,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:QE,registerFieldControl:ov,validation:{getValidationProps:(e,t=cv)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:ov,getInputControl:()=>null,commit:async()=>{},change:ov}},tD=W.createContext(eD);function nD(e=!0){let t=W.useContext(tD);if(t.setValidityData===ov&&!e)throw Error(uv(28));return t}function rD(e,t,n,r,i=!0,a){let{registerFieldControl:o}=nD(),s=Q_(()=>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 iD=W.createContext({controlId:void 0,registerControlId:ov,resetControlId:ov,labelId:void 0,setLabelId:ov,messageIds:[],setMessageIds:ov,getDescriptionProps:e=>e});function aD(){return W.useContext(iD)}function oD(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=aD(),o=rE(),s=Q_(()=>Symbol()),c=W.useRef(!1),l=W.useRef(!1),u=Q(()=>{c.current&&i!==ov&&(c.current=!1,i(s.current,void 0))});return X(()=>{if(!n||i===ov){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 sD(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 cD=(e,t)=>Object.is(e,t);function lD(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function uD(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!sD(e,t,(e,t)=>lD(e,t,n)):e!==t}function dD(e,t,n){return e?e.some(e=>e!==void 0&&lD(t,e,n)):!1}function fD(e,t,n){return e?e.findIndex(e=>e!==void 0&&lD(e,t,n)):-1}function pD(e,t){if(t!==cD)return n=>dD(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 mD(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(pD(t,n)):fD(e,t,n);return i===-1?null:i}function hD(e,t,n,r,i,a){return dD(r,t,i)?a!=null&&e>a&&dD(r,n[a],i)?a:e:e===a?mD(n,r,i,!0):a}function gD(e,t,n){return e.filter(e=>!lD(t,e,n))}function _D(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function vD(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function yD(e){return vD(e?.[0])}function bD(e){return yD(e)?e.flatMap(e=>e.items):e}function xD(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(yD(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 SD(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 _D(e)}function CD(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?_D(e.value):_D(e)}function wD(e,t,n){function r(){return SD(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=bD(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 TD(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Z.jsx)(W.Fragment,{children:wD(r,t,n)},i)),e),[])}var ED={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:CD(t,r)!==``},hasNullItemLabel:(e,t)=>t?xD(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=>lD(t,e,n)):lD(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},DD=W.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:ov,validationMode:`onSubmit`,submitCountRef:{current:0}});function OD(){return W.useContext(DD)}function kD(e,t){let n=W.useRef(e),r=Q(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function AD(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 jD(e,t){let{onClick:n,onPointerDown:r}=AD(Q((n,r)=>{(typeof e==`function`?e():e)||t(r||(Cv?`touch`:``))}));return W.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function MD(e){let[t,n]=W.useState(null),r=jD(e,n);return kD(e,t=>{t&&!e&&n(null)}),W.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function ND(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function PD(e,t){return Math.max(0,e-t)}function FD(e,t){if(t<=0)return 0;let n=ND(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 ID(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=cD,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=OD(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=nD(),F=oD({id:t}),I=M||d,L=j??c,[R,ee]=HE({controlled:n,default:y?r??sv:r,name:`Select`,state:`value`}),[z,te]=HE({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}=qw(z),{openMethod:me,triggerProps:he}=MD(z),ge=Q_(()=>new Uw({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:cv,triggerProps:cv,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:ov,setOpen:ov,handleScrollArrowVisibility:ov,onOpenChangeComplete:ov,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},ED)).current,_e=ge.useState(`activeIndex`),ve=ge.useState(`selectedIndex`),ye=ge.useState(`triggerElement`),be=ge.useState(`positionerElement`),xe=zE(me),Se=me??xe,Ce=W.useMemo(()=>y?``:CD(R,x),[y,R,x]),we=W.useMemo(()=>y&&Array.isArray(R)?R.map(e=>CD(e,x)):CD(R,x),[y,R,x]);rD(Tb(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=mD(se.current,R,S,y);e===null&&(V.current=null),!z&&ge.set(`selectedIndex`,e)},[y,z,R,S,ge]),kD(R,()=>{T(L),E(uD(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)});Zw({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=PD(e.scrollHeight,e.clientHeight),n=FD(e.scrollTop,t),r=n>0,i=n<t;ge.set(`scrollUpArrowVisible`,r),ge.set(`scrollDownArrowVisible`,i)}),Ae=xT({open:z,onOpenChange:Ee,elements:{reference:ye,floating:be}}),je=xC(Ae,{enabled:!I,event:`mousedown`}),Me=DC(Ae),Ne=VT(Ae,{enabled:!I,listRef:ne,activeIndex:_e,selectedIndex:ve,disabledIndices:sv,onNavigate(e){(e!==null||z)&&ge.set(`activeIndex`,e)},focusItemOnHover:C}),Pe=HT(Ae,{enabled:!I&&(z||!f&&!y),listRef:re,activeIndex:_e,selectedIndex:ve,disabledIndices:e=>VE(ne.current[e]),onMatch(e){z?ge.set(`activeIndex`,e):Oe(se.current[e],pb(Xy))},onTyping(e){ce.current=e}}),Fe=W.useMemo(()=>xS(Pe.reference,Ne.reference,Me.reference,je.reference,he),[je.reference,Pe.reference,Ne.reference,Me.reference,he]),Ie=W.useMemo(()=>xS(Qw,Pe.floating,Ne.floating,Me.floating),[Pe.floating,Ne.floating,Me.floating]),Le=Ne.item??cv;ge.useContextCallback(`setValue`,Oe),ge.useContextCallback(`setOpen`,Ee),ge.useContextCallback(`handleScrollArrowVisibility`,ke),ge.useContextCallback(`onOpenChangeComplete`,_),BE(()=>{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=yb(g,N.inputRef),Be=y?void 0:L,Ve=W.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=CD(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)(UE.Provider,{value:ge,children:[(0,Z.jsx)(WE.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=pb(Xy,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=se.current.findIndex(t=>CD(t,x).toLowerCase()===e||SD(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?zb:Rb,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ve]})}function LD(e,t){return e??t}var RD=5;function zD(e,t){let n=BD(t);return e.clientX>=n.left-RD&&e.clientX<=n.right+RD&&e.clientY>=n.top-RD&&e.clientY<=n.bottom+RD}function BD(e){let t=e.getBoundingClientRect(),n=zv(e);if(Av)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 VD=W.createContext(void 0);function HD(e=!1){let t=W.useContext(VD);if(t===void 0&&!e)throw Error(uv(16));return t}function UD(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 WD(e,t,{detail:n=0}={}){e.dispatchEvent(new(zv(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=HD(!0),c=a??s!==void 0,{props:l}=UD({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=W.useCallback(()=>{let e=o.current;KD(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 xS({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(MS(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=KD(r),s=!i&&qD(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(),WD(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),WD(r,e)))},onKeyUp(e){if(!t){if(MS(e),a?.(e),e.target===e.currentTarget&&i&&c&&KD(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),WD(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 KD(e){return Uv(e)&&e.tagName===`BUTTON`}function qD(e){return Uv(e)&&e.tagName===`A`&&!!e.href}var JD=`data-popup-side`,YD=400,XD={...Ny,...$E,popupSide:e=>e?{[JD]:e}:null,value:()=>null},ZD=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}=nD(),{labelId:h}=aD(),g=KE(),{readOnly:_,required:v,disabled:y}=qE(),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);oD({id:i});let P=Tb(T),F=W.useRef(null),{getButtonProps:I,buttonRef:L}=GD({disabled:b,native:o}),R=g.useStateSetter(`triggerElement`),ee=gv(),z=gv(),te=gv();W.useEffect(()=>{if(x)return te.start(YD,()=>{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=xS(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??Wy(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,pb(Xy,e.nativeEvent)),ee.start(0,()=>{g.set(`forceMount`,!0)})},onBlur(e){ly(T,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&f.commit(C))},onMouseDown(e){if(x)return;let t=Ib(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;ly(F.current,t)||ly(P.current,t)||zD(e,F.current)||g.context.setOpen(!1,pb(sb,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 FS(`button`,e,{ref:[t,F,L,R],state:B,stateAttributesMapping:XD,props:re})}),QD={value:()=>null},$D=W.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=KE(),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)?TD(l,u,d):wD(l,u,d)),FS(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:QD})}),eO=W.forwardRef(function(e,t){let n=KE(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Z.jsx)(tC,{ref:t,...e}):null}),tO=W.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function nO(){return W.useContext(tO)}function rO(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Q(i),[,o]=W.useState(!1),s=Q_(aO).current,c=Q_(iO).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(!cO(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&lO(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=sO(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Q(()=>{let[e,t]=oO(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)(tO.Provider,{value:b,children:t})}function iO(){return new Map}function aO(){return new Set}function oO(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)=>lO(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 sO(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function cO(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 lO(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var uO=W.createContext(void 0);function dO(){let e=W.useContext(uO);if(!e)throw Error(uv(59));return e}var fO=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 pO(e,t){e&&Object.assign(e.style,t)}var mO={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},hO={},gO={},_O=``;function vO(e,t){return Gv(e)?e:t}function yO(e,t,n){return/hidden|clip/.test(e.getComputedStyle(vO(t,n)).overflowY)}function bO(e){if(typeof document>`u`)return!1;let t=Ib(e);return zv(t).innerWidth-t.documentElement.clientWidth>0}function xO(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Ib(e),n=t.documentElement,r=t.body,i=vO(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 SO(e){let t=Ib(e),n=t.documentElement,r=t.body,i=vO(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 CO(e){let t=Ib(e),n=t.documentElement,r=t.body,i=zv(n),a=0,o=0,s=!1,c=Pb.create();if(Ov&&(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,hO={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},_O=n.style.scrollBehavior,gO={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=vO(n,r);if(s=xO(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,hO),Object.assign(r.style,gO),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=_O)}function d(){u(),c.request(l)}l();let f=_b(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var wO=new class{lockCount=0;restore=null;timeoutLock=hv.create();timeoutUnlock=hv.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=Ib(e),n=t.documentElement,r=t.body,i=zv(n);if(yO(i,n,r)){let t=new i.MutationObserver(()=>{yO(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=Cv||!bO(e);this.restore=a?SO(e):CO(e)}};function TO(e=!0,t=null){X(()=>{if(e)return wO.acquire(t)},[e,t])}var EO=20;function DO(e,t,n,r){let[i,a]=W.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=Ib(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-EO)},[e,t,n]),TO(e&&(!t||i),r)}var OO={position:`fixed`},kO=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=qS,style:_,...v}=e,y=KE(),b=JE(),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),DO((P||C)&&x,T===`touch`,E,D);let F=jE({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?OO:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};X(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=FE(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=pb(Xy);if(t!==0&&!y.state.multiple&&w!==null&&fD(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&fD(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=>fD(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:``};pO(E,e),pO(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)(rO,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:te,children:(0,Z.jsxs)(uO.Provider,{value:ne,children:[S&&C&&(0,Z.jsx)(fO,{inert:RE(!x),cutout:D}),ee]})})}),AO=`base-ui-disable-scrollbar`,jO={className:AO,getElement(e){return(0,Z.jsx)(`style`,{nonce:e,href:AO,precedence:`base-ui:low`,children:`.${AO}{scrollbar-width:none}.${AO}::-webkit-scrollbar{display:none}`})}},MO=W.createContext(void 0);function NO(e){let t=W.useContext(MO);if(t===void 0&&!e)throw Error(uv(69));return t}var PO=`ArrowUp`,FO=`ArrowDown`,IO=`ArrowLeft`,LO=`ArrowRight`,RO=new Set([PO,FO,IO,LO,`Home`,`End`]),zO=[`Shift`,`Control`,`Alt`,`Meta`];function BO(e){return Uv(e)&&e.tagName===`INPUT`}function VO(e){return!!(BO(e)&&e.selectionStart!=null||Uv(e)&&e.tagName===`TEXTAREA`)}function HO(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=UO(e,t,`left`),a=WO(e),o=WO(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=UO(e,t,`top`),r=WO(e),i=WO(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 UO(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 WO(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),KO={disableStyleElements:!1};function qO(){return W.useContext(GO)??KO}var JO=`--transform-origin`,YO={...Py,...xy},XO=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=KE(),{multiple:c,readOnly:l,highlightItemOnHover:u}=qE(),d=JE(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=dO(),_=NO(!0)!=null,v=_E(),{nonce:y,disableStyleElements:b}=qO(),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=Fb(),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=$O(O),i=ek(O.getBoundingClientRect().height,`y`,r),a=Ib(O),o=zv(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=ZO(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=QO(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=ND(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=ND(g,0,QO(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]),Zw({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,pO(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(JO),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=rk(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=zv(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=Ib(D),c=$O(D),l=tk(D.getBoundingClientRect(),c),d=tk(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=ZO(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=tk(n.getBoundingClientRect(),c);T=tk(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=`${ND(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=QO(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&&Ov;if(z||te){pO(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=QO(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=ND(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(JO,`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=zv(O);function t(e){s.context.setOpen(!1,pb(fb,e))}return _b(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){_&&RO.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:mO},className:!k&&m?jO.className:void 0},L=FS(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:YO,props:[T,I,PE(E),o]});return(0,Z.jsxs)(W.Fragment,{children:[!b&&jO.getElement(y),(0,Z.jsx)(bC,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:L})]})});function ZO(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function QO(e){return PD(e.scrollHeight,e.clientHeight)}function $O(e){return uw.getScale(e)}function ek(e,t,n){return e/n[t]}function tk(e,t){return px({x:ek(e.x,`x`,t),y:ek(e.y,`y`,t),width:ek(e.width,`x`,t),height:ek(e.height,`y`,t)})}var nk=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function rk(e){let{style:t}=e,n={};for(let[e,r]of nk)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of nk){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}function ik(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=nO(),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 ak=W.createContext(void 0);function ok(){let e=W.useContext(ak);if(!e)throw Error(uv(57));return e}var sk=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=ik({guess:!0,label:o,textRef:u}),f=KE(),{itemProps:p,multiple:m,disabled:h,readOnly:g}=qE(),_=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=hD(C,a,f.context.valuesRef.current,e,S,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&lD(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?gD(n,a,S):[...n,a];f.context.setValue(r,pb(tb,e))}else f.context.setValue(a,pb(tb,e)),f.context.setOpen(!1,pb(tb,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&&Nv(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=FS(`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)(ak.Provider,{value:P,children:N})})),ck=W.memo(W.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=ok(),a=KE(),{render:o,className:s,style:c,...l}=e;return FS(`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})})),lk=e=>Symbol.iterator in e,uk=e=>`entries`in e,dk=(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},fk=(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 pk(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:lk(e)&&lk(t)?uk(e)&&uk(t)?dk(e,t):fk(e,t):dk({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function mk(e){let t=W.useRef(void 0);return n=>{let r=e(n);return pk(t.current,r)?t.current:t.current=r}}function hk(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=hk(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function gk(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=hk(e))&&(r&&(r+=` `),r+=t);return r}var _k=W.createContext(void 0);function vk(){return W.useContext(_k)}function yk(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=HD(),{ref:i,index:a}=ik(e),o=n===a,s=W.useRef(null),c=yb(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 bk(e){let{render:t,className:n,style:r,state:i=cv,props:a=sv,refs:o=sv,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=yk({metadata:s});return FS(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var xk=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=rE(u||void 0),h=vk(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=HE({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=pb(Xy,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=FS(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=W.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,Z.jsx)(bk,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T});function Sk(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=sv}=e,[p,m]=W.useState(0),h=r!=null,g=W.useRef(null),_=yb(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];HO(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||vx(e,x,d)?S(Ck(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(vx(t,x,d)){let e=_x(t,{disabledIndices:d});mx(t,e)||S(e)}HO(g.current,r,a,n)});X(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(vx(e,x,d)){let t=_x(e,{disabledIndices:d});mx(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(!RO.has(e.key)||!l&&o||wk(e,f)||!g.current)return;let s=a===`rtl`,c=s?IO:LO,p=s?LO:IO,m=n===`vertical`?FO:c,_=n===`vertical`?PO:p,y=uy(e.nativeEvent);if(y!=null&&VO(y)&&!VE(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=hx(v,d),T=gx(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=_x(v.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==x&&!mx(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=uy(e.nativeEvent);t&&n!=null&&VO(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:v,onMapChange:C,relayKeyboardEvent:T}}function Ck(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!vx(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function wk(e,t){for(let n of zO)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Tk(e){let{render:t,className:n,style:r,refs:i=sv,props:a=sv,state:o=cv,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}=Sk({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:_E(),disabledIndices:v,modifierKeys:y}),k=FS(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)(VD.Provider,{value:A,children:(0,Z.jsx)(rO,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var Ek=W.createContext(void 0);function Dk(){return W.useContext(Ek)}var Ok=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=NO(!0),m=Dk(),h=n??sv,g=c!==void 0||n!==void 0,_=(p?.disabled??!1)||(m?.disabled??!1)||r,[v,y]=HE({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=FS(`div`,e,{enabled:!!p,state:x,ref:t,props:[C,f]});return(0,Z.jsx)(_k.Provider,{value:S,children:p?w:(0,Z.jsx)(Tk,{render:u,className:l,style:d,state:x,refs:[t],props:[C,f],loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})});function kk(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=HE({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=qw(a,!0,!0),u=rE(),[d,f]=W.useState(),p=d===null?void 0:d??u,m=Q(e=>{let t=!a,n=pb(Zy,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 Ak=W.createContext(void 0);function jk(){let e=W.useContext(Ak);if(e===void 0)throw Error(uv(15));return e}var Mk=`data-open`,Nk=`data-closed`,Pk=_y,Fk=`data-panel-open`,Ik={[Mk]:``},Lk={[Nk]:``},Rk={open(e){return e?{[Fk]:``}:null}},zk={open(e){return e?Ik:Lk},...xy},Bk=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=kk({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=FS(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:zk});return(0,Z.jsx)(Ak.Provider,{value:p,children:m})}),Vk={...Rk,...xy},Hk=W.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=jk(),{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 FS(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:Vk})}),Uk={height:void 0,width:void 0};function Wk(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(Uk),h=W.useRef(Uk),g=W.useRef(!1),_=W.useRef(s),v=W.useRef(!1),[y,b]=W.useState(!1),x=W.useRef(null),S=yb(t,d),C=Tb(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=Kk(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=Yk(e);if(A(Gk(e)),!n)return t;let r=Jk(e,`transition-duration`,`0s`);return M(r),b(!0),t}A(Gk(e));let r=Jk(e,`animation-name`,`none`);if(!n){r();return}let i=Jk(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(Uk,!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`&&Jk(e,`animation-name`,`none`)()},[a,s,j,A,c,M,D,u]),Zw({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&A(Uk,!1)}}),W.useEffect(()=>{if(s||!a||E!==`ending`||!d.current)return;let e=new AbortController,t=-1;function n(){C.current||(c(!1),A(Uk,!1))}return t=Pb.request(()=>{w(n,e.signal)}),()=>{Pb.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=pb(Xy,e);o(!0,t),!t.isCanceled&&(g.current=!0,l(!0))}return _b(e,`beforematch`,t)},[o,l]);let P=i||n||a||s;return{height:O.height,props:{...k?{[Pk]:``}: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 Kk(e,t){let n=zv(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&qk(n.animationDuration),i=qk(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function qk(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Jk(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 Yk(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=Pb.request(n);return()=>{Pb.cancel(r),n()}}var Xk=`--collapsible-panel-height`,Zk=`--collapsible-panel-width`,Qk=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:_}=jk(),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}=Wk({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=yS(s,k),j=FS(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[Xk]:S===void 0?`auto`:`${S}px`,[Zk]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:zk});return E?j:null}),$k=W.createContext(void 0);function eA(e=!0){let t=W.useContext($k);if(t===void 0&&!e)throw Error(uv(25));return t}var tA=W.createContext(void 0);function nA(e){let t=W.useContext(tA);if(t===void 0&&!e)throw Error(uv(33));return t}var rA=W.createContext(void 0);function iA(e){let t=W.useContext(rA);if(t===void 0&&!e)throw Error(uv(36));return t}function aA(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=eA(!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:tb})},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&&!Ev&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&WD(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var oA={type:`regular-item`};function sA(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=aA({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=W.useCallback(e=>xS(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=yb(u,f);return W.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var cA=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=ik({guess:!0,label:a}),f=nA(!0),p=rE(i),{store:m}=iA(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=sA({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:oA});return FS(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),lA=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=iA(),{side:c,align:l}=nA(),u=NO(!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`;Zw({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),W.useEffect(()=>{function e(e){s.setOpen(!1,pb(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),jT(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),O=FS(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:Fy,props:[p,{onKeyDown(e){u&&RO.has(e.key)&&e.stopPropagation()}},PE(f),o,{"data-rootownerid":y}]}),k=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(k=!0),(0,Z.jsx)(bC,{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})}),uA=W.createContext(void 0);function dA(){let e=W.useContext(uA);if(e===void 0)throw Error(uv(32));return e}var fA=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=iA();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Z.jsx)(uA.Provider,{value:n,children:(0,Z.jsx)(tC,{ref:t,...r,portalOwnerRole:o})})}),pA=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=qS,style:g,..._}=e,{store:v}=iA(),y=dA(),b=eA(!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??JS):x.type===`menubar`&&(B??=x.context.orientation===`vertical`?`inline-end`:`bottom`,ie??=`start`);let ae=x.type===`context-menu`,oe=jE({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,pb(cb)))}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,pb(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let se=gv();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,pb(cb))}):v.setOpen(!1,pb(cb))}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;DO(T&&(le||E&&N!==`trigger-hover`),D===`touch`,A,O);let V=FE(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)(tA.Provider,{value:oe,children:[H&&(0,Z.jsx)(fO,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:RE(!T),cutout:ue}),(0,Z.jsx)(lC,{id:P,children:(0,Z.jsx)(rO,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:V})})]})}),mA=W.createContext(null);function hA(e){let t=W.useContext(mA);if(t===null&&!e)throw Error(uv(5));return t}var gA={...yT,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`)}},_A=class extends Uw{constructor(e,t,n=!1){let r=new fT,i=yA(r,t,n,e);super(i,vA(r),gA),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 vA(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 yA(e,t,n=!1,r){return{...pT(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 rC,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:cv,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var bA=W.createContext(void 0);function xA(){return W.useContext(bA)}var SA=rv(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=eA(!0),_=iA(!0),v=hA(!0),y=xA(),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=fS(),S=fS(),C=oC(),w=b.type===`menu`?b.store:void 0,T=(n??a)&&w?.state.transitionStatus===`starting`,E=Q_(()=>T?w?.state.instantType:void 0).current,D=CA({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=cC(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=gv(),re=W.useRef(!0),B=gv(),ie=ee!=null,{openMethod:ae,triggerProps:oe}=MD(A);D.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:I.type===void 0?s:void 0,openMethod:ae,rootId:x}),cT(D);let{forceUnmount:se,transitionStatus:ce}=lT(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=aT(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=iT(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=Kw({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,pb(ub))},[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=DC(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=_E(),me=W.useCallback(e=>{D.select(`activeIndex`)!==e&&D.set(`activeIndex`,e)},[D]),he=VT(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:sv,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=HT(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=xS(_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=xS(he.trigger,U.trigger,oe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[he.trigger,U.trigger,oe]);Q_(()=>(D.update({inactiveTriggerProps:ye}),null)),uT(D,{floatingRootContext:H,activeTriggerProps:ve,inactiveTriggerProps:ye,popupProps:W.useMemo(()=>xS(Qw,{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??cv});let be=W.useMemo(()=>({store:D,parent:b}),[D,b]),xe=(0,Z.jsxs)(rA.Provider,{value:be,children:[f&&(0,Z.jsx)(tT,{handle:f,store:D}),typeof t==`function`?t({payload:R}):t]});return I.type===void 0||I.type===`context-menu`?(0,Z.jsx)(uC,{externalTree:O,children:xe}):xe});function CA(e,t,n){return Q_(()=>new _A(e,t,n)).current}function wA(e){if(Uv(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!ty(e))return wA(iy(e))}function TA(e,t){let n=W.useRef(null);function r(t){XS.flushSync(()=>{e.setOpen(!1,pb(rb,t.nativeEvent,t.currentTarget))}),Hx(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&Ux(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{XS.flushSync(()=>{e.setOpen(!1,pb(rb,n.nativeEvent,n.currentTarget))});let i=Vx(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&ly(r,i);){let e=i;if(i=Rx(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function EA(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=fS(),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)($k.Provider,{value:u,children:(0,Z.jsx)(rA.Provider,{value:void 0,children:(0,Z.jsx)(SA,{...e})})})}var DA=500,OA=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}=eA(!1),{store:m}=iA(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=W.useRef(null),v=W.useRef(null),y=gv(),b=gv(),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,pb(Zy,n)),b.start(DA,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,jv(e),C(e.clientX,e.clientY,e.nativeEvent);let t=Ib(_.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=uy(e);ly(u.current,t)||p&&t&&wA(t)===p||s.current?.setOpen(!1,pb(sb,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(DA,()=>{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=uy(e);(ly(_.current,t)||ly(c.current,t)||ly(l.current,t))&&e.preventDefault()}return _b(Ib(_.current),`contextmenu`,e)},[l,g,c]),FS(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:Ny})}),kA=pA,AA=W.createContext(void 0);function jA(){let e=W.useContext(AA);if(e===void 0)throw Error(uv(53));return e}function MA(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 NA=`data-has-overflow-x`,PA=`data-has-overflow-y`,FA=`data-overflow-x-start`,IA=`data-overflow-x-end`,LA=`data-overflow-y-start`,RA=`data-overflow-y-end`,zA=e=>t=>t?{[e]:``}:null,BA={hasOverflowX:zA(NA),hasOverflowY:zA(PA),overflowXStart:zA(FA),overflowXEnd:zA(IA),overflowYStart:zA(LA),overflowYEnd:zA(RA),cornerHidden:()=>null},VA=`--scroll-area-corner-height`,HA=`--scroll-area-corner-width`,UA=`data-orientation`,WA={x:0,y:0},GA={width:0,height:0},KA={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},qA={x:!0,y:!0,corner:!0},JA=W.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=YA(i),d=rE(),f=gv(),p=gv(),{nonce:m,disableStyleElements:h}=qO(),[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(KA),[M,N]=W.useState(qA),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(WA),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(UA);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=MA(i,`padding`,a),s=MA(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=ly(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`,[VA]:`${E.height}px`,[HA]:`${E.width}px`}},he=FS(`div`,e,{state:pe,ref:[t,P],props:[me,o],stateAttributesMapping:BA}),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)(AA.Provider,{value:ge,children:[!h&&jO.getElement(m),he]})});function YA(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),ZA=`--scroll-area-overflow-x-start`,QA=`--scroll-area-overflow-x-end`,$A=`--scroll-area-overflow-y-start`,ej=`--scroll-area-overflow-y-end`,tj=`--scroll-area-thumb-height`,nj=`--scroll-area-thumb-width`,rj=[ZA,QA,$A,ej],ij=!1;function aj(){ij||Ov||(typeof CSS<`u`&&`registerProperty`in CSS&&rj.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),ij=!0)}var oj=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}=jA(),T=_E(),E=W.useRef(!0),D=W.useRef([NaN,NaN,NaN,NaN]),O=gv(),k=gv(),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=sj(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=FD(T===`rtl`?-w:w,P),L=P-I);let R=A?0:FD(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=MA(n,`padding`,`x`),se=MA(t,`padding`,`y`),ce=MA(i,`margin`,`x`),le=MA(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=>cj(e,{width:fe,height:U})),t&&r){let e=lj(r,tj,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=lj(i,nj,T===`rtl`?-w:w,P,_,fe,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let pe=[I,L,R,ee];rj.forEach((t,n)=>{e.style.setProperty(t,`${pe[n]}px`)}),a&&p(e=>cj(e,{width:ne,height:re})),g(e=>cj(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=>cj(e,me))});X(()=>{aj()},[]),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:jO.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=FS(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:BA}),P=W.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,Z.jsx)(XA.Provider,{value:P,children:N})});function sj(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function cj(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function lj(e,t,n,r,i,a,o){let s=ND(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 uj=W.createContext(void 0);function dj(){let e=W.useContext(uj);if(e===void 0)throw Error(uv(54));return e}var fj=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}=jA(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=_E(),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 _b(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=uy(e.nativeEvent),n=T?h.current:g.current;if(n&&ly(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=MA(n,`margin`,a),s=MA(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(${VA})`,insetInlineEnd:0,[tj]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${HA})`,bottom:0,[nj]:`${S.width}px`}}},M=FS(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:BA});return A?(0,Z.jsx)(uj.Provider,{value:i,children:M}):null}),pj=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}=jA(),m=dj(),h=m===`vertical`;return FS(`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]})}),mj=W.createContext(void 0);function hj(e){let t=W.useContext(mj);if(!e&&t===void 0)throw Error(uv(27));return t}var gj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=hj(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return FS(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:Fy,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),_j=W.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=hj(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=GD({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,pb(nb,e.nativeEvent))}return FS(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),vj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=hj(),c=rE(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),FS(`p`,e,{ref:t,props:[{id:c},o]})}),yj=W.createContext(void 0);function bj(){let e=W.useContext(yj);if(e===void 0)throw Error(uv(26));return e}var xj=`--nested-dialogs`,Sj=`data-nested-dialog-open`,Cj={...Py,...xy,nestedDialogOpen(e){return e?{[Sj]:``}:null}},wj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=hj(),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`);bj(),Zw({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?$w(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=FS(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Qw,hidden:!m,onKeyDown(e){RO.has(e.key)&&e.stopPropagation()},style:{[xj]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Cj});return(0,Z.jsx)(bC,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Tj=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=hj(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Z.jsx)(yj.Provider,{value:n,children:(0,Z.jsxs)(tC,{ref:t,...r,children:[a&&o===!0&&(0,Z.jsx)(fO,{ref:i.context.internalBackdropRef,inert:RE(!s)}),e.children]})}):null});function Ej({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=DC(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=uy(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||ly(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return TO(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]),uT(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var Dj={...yT,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},Oj=class extends Uw{constructor(e,t,n){let r=new fT,i=kj(e,r,t,n);super(i,Aj(r),Dj)}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(iT(this.state,e,t.trigger)))}};function kj(e,t,n,r=!1){return{...pT(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 Aj(e){return{popupRef:W.createRef(),backdropRef:W.createRef(),internalBackdropRef:W.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function jj(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=hj(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=eT((e,t)=>new Oj({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`);dT(b,x),cT(b);let{forceUnmount:w}=lT(x,b);W.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,pb(ub))}),[w,b]);let T=x||S;return(0,Z.jsxs)(mj.Provider,{value:b,children:[u&&(0,Z.jsx)(tT,{handle:u,store:b}),T&&(0,Z.jsx)(Ej,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var Mj=rv(function(e){return jj(`dialog`,e)}),Nj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=bj(),c=hj(),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 FS(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:Cj,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),Pj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=hj(),c=rE(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),FS(`h2`,e,{ref:t,props:[{id:c},o]})}),Fj=iv(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=hj(!0),f=bT(l)??d;if(!f)throw Error(uv(79));let p=rE(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=W.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=sT(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=GD({disabled:a,native:o}),S=xC(m),C=jD(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return FS(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[US]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:My})}),Ij=`--nested-drawers`,Lj=`--drawer-height`,Rj=`--drawer-frontmost-height`,zj=`--drawer-swipe-movement-x`,Bj=`--drawer-swipe-movement-y`,Vj=`--drawer-snap-point-offset`,Hj=`--drawer-swipe-strength`,Uj=`--drawer-swipe-progress`,Wj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=hj(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return FS(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:Fy,props:[{role:`presentation`,hidden:!u,style:{pointerEvents:c?void 0:`none`,userSelect:`none`,WebkitUserSelect:`none`,[Uj]:`0`,[Hj]:`1`}},o],enabled:a||!l})}),Gj=_j,Kj=`data-drawer-content`,qj=vj,Jj=W.createContext(void 0);function Yj(){return W.useContext(Jj)}var Xj=`data-expanded`,Zj=`data-nested-drawer-open`,Qj=`data-nested-drawer-swiping`,$j=`data-swipe-dismiss`,eM=`data-swipe-direction`,tM=`data-swiping`,nM=W.createContext(void 0);function rM(e){let t=W.useContext(nM);if(e!==!0&&t===void 0)throw Error(uv(90));return t}function iM(e,t){let n=e+t;return n>=0?t:-Math.sqrt(-n)-e}function aM(e,t,n){if(!Number.isFinite(t)||t<=0)return null;if(typeof e==`number`)return Number.isFinite(e)?e<=1?ND(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 oM(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 sM(){let e=hj(),{snapPoints:t,activeSnapPoint:n,setActiveSnapPoint:r,popupHeight:i}=rM(),a=e.useState(`viewportElement`),[o,s]=W.useState(0),[c,l]=W.useState(16),u=Q(()=>{let e=Ib(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=aM(t,o,c);if(n===null)return null;let r=ND(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=aM(n,o,c);if(r===null)return;let a=ND(r,0,t);return d[oM(d.map(e=>e.height),a)]},[n,i,d,c,o])?.offset??null}}var cM=W.createContext(null);function lM(){return W.useContext(cM)}var uM=!1;function dM(){uM||=(typeof CSS<`u`&&`registerProperty`in CSS&&([zj,Bj,Vj].forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),[{name:Uj,initialValue:`0`},{name:Hj,initialValue:`1`}].forEach(({name:e,initialValue:t})=>{try{CSS.registerProperty({name:e,syntax:`<number>`,inherits:!1,initialValue:t})}catch{}})),!0)}var fM={...Fy,expanded(e){return e?{[Xj]:``}:null},nestedDrawerOpen(e){return e?{[Zj]:``}:null},nestedDrawerSwiping(e){return e?{[Qj]:``}:null},swipeDirection(e){return{[eM]:e}},swiping(e){return e?{[tM]:``}:null}},pM=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=hj(),l=c.context.popupRef,{swipeDirection:u,frontmostHeight:d,hasNestedDrawer:f,nestedSwiping:p,nestedSwipeProgressStore:m,onPopupHeightChange:h,notifyParentFrontmostHeight:g,notifyParentHasNestedDrawer:_}=rM(),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=lM();bj();let{snapPoints:P,activeSnapPoint:F,activeSnapPointOffset:I}=sM(),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||(dM(),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(Uj,`${t}`):e.style.setProperty(Uj,`0`)};e();let t=m.subscribe(e),n=l.current;return()=>{t(),n&&n.style.setProperty(Uj,`0`)}},[m,l]),X(()=>{if(D)return g?.(d),()=>{g?.(0)}},[d,D,g]),X(()=>{if(_)return _(D||E===`ending`),()=>{_(!1)}},[_,D,E]),Zw({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():cv;if(se&&u===`down`){let e=I??0,t=Number.parseFloat(String(le[Bj]));le=R&&Number.isFinite(t)?{...le,transform:void 0,[Bj]:`${iM(e,t)}px`}:{...le,transform:void 0}}let V=FS(`div`,e,{state:ae,props:[x,{id:M,"aria-labelledby":k,"aria-describedby":v,role:A,...Qw,hidden:!C,onKeyDown(e){RO.has(e.key)&&e.stopPropagation()},style:{...le,[Uj]:`0`,[Ij]:T,[Lj]:oe,[Vj]:typeof ce==`number`?`${ce}px`:`0px`,[Rj]:d?`${d}px`:void 0,[Hj]:typeof ee==`number`&&Number.isFinite(ee)&&ee>0?`${ee}`:`1`}},s],ref:[t,l,ie],stateAttributesMapping:fM});return(0,Z.jsx)(bC,{context:b,openInteractionType:O,disabled:!C,closeOnFocusOut:!y,initialFocus:B,returnFocus:a,modal:S!==!1,restoreFocus:`popup`,children:V})}),mM=Tj,hM,gM;function _M(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=rM(!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(vM),M=g===void 0?m?.[0]??null:g,N=h!==void 0,[P,F]=HE({controlled:h,default:M,name:`Drawer`,state:`snapPoint`}),I=W.useRef(!1),L=W.useRef(!1),R=Q((e,t)=>{let n=t??pb(`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,pb(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=jj(`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:[hM||=(0,Z.jsx)(yM,{}),t(e)]}):(0,Z.jsxs)(W.Fragment,{children:[gM||=(0,Z.jsx)(yM,{}),t]})});return(0,Z.jsx)(nM.Provider,{value:ae,children:oe})}function vM(){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 yM(){let e=Yj(),t=hj(!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||!Tv)return;let e=zv(o).CloseWatcher;if(!e)return;function n(e){t.select(`open`)&&t.setOpen(!1,pb(ab,e))}let r=new e,a=_b(r,`close`,n);return()=>{a(),r.destroy()}},[t,s,i,o]),null}function bM(e,t=!1){let{overflowY:n}=ny(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function xM(e,t=!1){let{overflowX:n}=ny(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientWidth>0:e.scrollWidth>e.clientWidth}function SM(e,t,n=!1){return t===`vertical`?bM(e,n):xM(e,n)}function CM(e,t,n){let r=e;for(;Uv(r)&&r!==t&&!ty(r);){for(let e of n)if(SM(r,e))return!0;r=iy(r)}return!1}function wM(e,t,n=`vertical`,r=!1){let i=Uv(e)?e:null;for(;Uv(i)&&i!==t&&!ty(i);){if(SM(i,n,r))return i;i=iy(i)}return SM(t,n,r)?t:null}function TM(e,t,n){return typeof e?.elementFromPoint==`function`?e.elementFromPoint(t,n):null}function EM(e,t){let n=(t??zv(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 DM=40,OM=10,kM=1,AM=50,jM=16,MM=80,NM=`button,a,input,select,textarea,label,[role="button"]`;function PM(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 FM(e){return Number.isFinite(e)&&e>0?e:null}function IM(e,t){return`translate3d(${e.x}px,${e.y}px,0) scale(${t})`}function LM(e){return e%2==1}function RM(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 zM(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=NM,_=n.length===1?n[0]:void 0,v=Math.max(0,typeof c==`number`?c:DM),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)?ND(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=IM(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,jM);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 TM(n,e.x,e.y)??uy(t)}function xe(e,t){let n=n=>{let r=wM(e,t,n),i=Ib(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=Ib(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)&&CM(a,p,T))return!1;if(R.current=!1,I.current=void 0,L.current=0,M.current=t,le.current=FM(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=EM(p);F.current=t,N.current={x:t.x,y:t.y},ge({x:t.x,y:t.y},le.current),`touches`in e||RM(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&&RM(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=uy(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=FM(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)>=kM&&(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=PM(m,l,u),D(m),pe(m));else{let e=I.current,t=PM(e,f,d);t>se.current?(R.current=!1,D(e)):!(y&&b)&&!(x&&S)&&L.current-t>=OM&&(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},FM(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=PM(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||RM(u,e.pointerId,`releasePointerCapture`));let d=o,f=s,m=le.current,h=FM(e.timeStamp),g=m!==null&&h!==null&&h>m?h-m:0,v=g>0?Math.max(g,AM):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<=MM){let t=Math.max(e,jM),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(PM(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=Ib(a).body,s=o?xe(r,o):null;if(s&&(ly(a,s)||ly(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?IM(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 BM=Pj,VM=`data-nested-dialog-open`,HM=W.createContext(void 0);function UM(){return W.useContext(HM)}var WM=10,GM=.5,KM=.5,qM=300,JM=4,YM=.2,XM=4,ZM=80,QM=360,$M=.1,eN=6,tN=2,nN=`[${Kj}]`,rN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=hj(),c=s.context.popupRef,l=s.context.backdropRef,{swipeDirection:u,notifyParentSwipingChange:d,notifyParentSwipeProgressChange:f,frontmostHeight:p,snapToSequentialPoints:m,swipeAreaActiveRef:h}=rM(),g=Yj(),{snapPoints:_,resolvedSnapPoints:v,activeSnapPoint:y,activeSnapPointOffset:b,setActiveSnapPoint:x,popupHeight:S}=sM(),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=Fb(),ee=W.useRef(!1),z=W.useRef(!1),te=W.useRef(``),ne=W.useRef(!1),re=W.useRef(!1),B=W.useRef(null),ie=UM(),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:ND((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($j,e),l.current?.toggleAttribute($j,e)}),le=Q(()=>{ce(!1),c.current?.removeAttribute(vy),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(Uj,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=sN(e,t);if(c<=0)return null;let l=((t===`down`||t===`up`)&&_&&_.length>0?b??0:0)+PM(t,n,r),u=Math.max(0,c-l);if(u<=0)return null;let d=PM(t,o,s),f=Math.abs(d)>0?d:PM(t,i,a);return f<=YM?null:$M+(ND(u/ND(f,YM,XM),ZM,QM)-ZM)/280*.9}function de(e){if(z.current||!e)return;let t=PM(e.direction??u,e.deltaX,e.deltaY);Math.abs(t)<WM||(z.current=!0,d?.(!0))}let fe=zM({enabled:w&&!A,directions:se,elementRef:s.context.popupRef,ignoreSelectorWhenTouch:!1,ignoreScrollableAncestors:!0,movementCssVars:{x:zj,y:Bj},onSwipeStart(e){if(`touches`in e||e.pointerType===`touch`)return;let t=c.current,n=Ib(t).getSelection?.();if(!n||n.isCollapsed)return;let r=Hv(n.anchorNode)?n.anchorNode:n.anchorNode?.parentElement,i=Hv(n.focusNode)?n.focusNode:n.focusNode?.parentElement;(ly(t,r)||ly(t,i))&&n.removeAllRanges()},onSwipingChange(e){ee.current=e,iN(s.context.backdropRef.current,e),!e&&!f&&V()},swipeThreshold({element:e,direction:t}){return cN(e,t)},canStart(e,t){let n=s.context.popupRef.current;if(!n)return!1;let r=n.ownerDocument,i=TM(n.getRootNode(),e.x,e.y);if(!i||!ly(n,i))return!1;let a=t.nativeEvent;return!((`touches`in a||a.pointerType===`touch`)&&fN(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(Bj,`${iM(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=>ND((e-ae.minOffset)/ae.range,0,1))(ND(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(vy,``),XS.flushSync(()=>{F(ue(d,e,t,n,i,a,o,c))})}if(!_||_.length===0){if(!r){le();return}let e=PM(r,t,n);if(e<=0)return le(),!1;if(PM(r,i,a)>=GM)return f(r),!0;let o=e>cN(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)>=WM){let e=Math.sign(w);e!==0&&e!==h&&(w=C)}let T=b??0,E=ND(T+p,0,S),D=Math.abs(w)>=KM?ND(w,-4,JM)*qM:0,O=m?E:ND(E+D,0,S),k=pb(db,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=oM(t,T),r=e[oM(t,O)],i=Math.sign(w),a=h!==0&&i!==0&&i===h&&Math.abs(w)>=KM,o=O;if(a){let t=ND(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[oM(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(Uj,`0`),t.style.removeProperty(Lj));let n=pb(db,e);if(s.setOpen(!1,n),n.isCanceled){let t=I.current;t!==void 0&&x(t,pb(db,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,pb(db,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=Ib(t);function r(e,r,i){let a=M?i.clientY-r.lastY:i.clientX-r.lastX;if(e.touches.length===2||fN(n,t)||!C||!w||A||gN(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(!_N(o,j)){e.cancelable&&e.preventDefault(),e.stopPropagation();return}if(a!==0){let t=bN(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),hN(t,n))}return _b(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}),iN(e,!1);let t=l.current;t!==e&&iN(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)(Nj,{ref:t,className:r,style:i,render:n,...xS(o,{onPointerDown(e){if(te.current=e.pointerType,ne.current=e.pointerType===`pen`,!C||!w||A)return;let t=TM(e.currentTarget.getRootNode(),e.clientX,e.clientY);aN(t)||oN(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(mN(e)){_e(!1);return}let n=e.currentTarget,r=TM(n.getRootNode(),t.clientX,t.clientY),i=uy(e.nativeEvent),a=Hv(i)?i:n;if(!ly(n,a)){_e(!0);return}if(ie?.onTouchStart(e),aN(r)){_e(!0);return}re.current=!1;let o=wM(a,n,j),s=wM(a,n,N)!=null,c=null;o&&(c=yN(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)},[VM]:void 0}),children:(0,Z.jsx)(cM.Provider,{value:ge,children:a})})});function iN(e,t){e?.toggleAttribute(tM,t)}function aN(e){return!!e?.closest(KS)}function oN(e){return!!e?.closest(nN)}function sN(e,t){return t===`left`||t===`right`?e.offsetWidth:e.offsetHeight}function cN(e,t){return Math.max(sN(e,t)*.5,WM)}function lN(e,t){return e instanceof t.HTMLInputElement&&e.type===`range`}function uN(e){return e.tagName===`INPUT`||e.tagName===`TEXTAREA`}function dN(e,t){let n=Hv(e.anchorNode)?e.anchorNode:e.anchorNode?.parentElement,r=Hv(e.focusNode)?e.focusNode:e.focusNode?.parentElement;return e.containsNode(t,!0)||ly(t,n)||ly(t,r)}function fN(e,t){let n=cy(e);if(n&&ly(t,n)&&uN(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:dN(r,t)}function pN(e,t){return e.composedPath().some(e=>lN(e,t))}function mN(e){return pN(e.nativeEvent,zv(e.currentTarget))}function hN(e,t){e.lastX=t.clientX,e.lastY=t.clientY}function gN(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>=eN&&s>o+tN?(e.preserveNativeCrossAxisScroll=!0,!0):o>=eN?(e.drawerAxisAttributed=!0,!1):!0}function _N(e,t){return vN(e,t).max>0}function vN(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 yN(e,t,n){let r=xN(n,t),{offset:i,max:a}=vN(e,t);return r?i<=0:i>=a}function bN(e,t,n,r){return(xN(n,t)?r>0:r<0)&&yN(e,t,n)}function xN(e,t){return t===`vertical`?e===`down`:e===`right`}var SN=W.createContext(void 0);function CN(e){let t=W.useContext(SN);if(t===void 0&&!e)throw Error(uv(47));return t}var wN={...yT,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},TN=class extends Uw{constructor(e,t,n){let r=new fT;super(EN(e,r,t,n),DN(r),wN)}setOpen=(e,t)=>{let n=t.reason===Qy,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=aT(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=iT(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 EN(e,t,n,r=!1){let i={...pT(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 DN(e){return{popupRef:W.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:W.createRef(),beforeContentFocusGuardRef:W.createRef(),stickIfOpenTimeout:new hv,triggerElements:e}}var ON=rv(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=AN(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),dT(u,d),cT(u);let{forceUnmount:m}=lT(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,pb(ub))}),[m,u]);let h=d||f;return(0,Z.jsxs)(SN.Provider,{value:u,children:[s&&(0,Z.jsx)(tT,{handle:s,store:u}),h&&(0,Z.jsx)(jN,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function kN(e){return CN(!0)?(0,Z.jsx)(ON,{props:e}):(0,Z.jsx)(uC,{children:(0,Z.jsx)(ON,{props:e})})}function AN(e,t){let n=eT((e,n)=>new TN(t,e,n));return W.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function jN({store:e,modal:t}){let n=DC(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return uT(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var MN=iv(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=CN(!0),h=bT(s)??m;if(!h)throw Error(uv(74));let g=rE(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}=sT(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=NT(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=xC(v,{stickIfOpen:T}),A=jD(()=>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`?Ny.open(e):My.open(e)}},{preFocusGuardRef:F,handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=TA(h,x),R=FS(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,O,j,A,{[US]:``,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)(Bb,{ref:F,onFocus:I}),ee,(0,Z.jsx)(Bb,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):ee}),NN=W.createContext(void 0);function PN(){let e=W.useContext(NN);if(e===void 0)throw Error(uv(45));return e}var FN=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return CN().useState(`mounted`)||n?(0,Z.jsx)(NN.Provider,{value:n,children:(0,Z.jsx)(tC,{ref:t,...r})}):null}),IN=W.createContext(void 0);function LN(){let e=W.useContext(IN);if(!e)throw Error(uv(46));return e}var RN=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=JS,..._}=e,v=CN(),y=PN(),b=cC(),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=jE({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`;DO(C&&I,D===`touch`,O,T);let L=v.useStateSetter(`positionerElement`),R=FE(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)(IN.Provider,{value:P,children:[S&&I&&(0,Z.jsx)(fO,{inert:RE(!C),cutout:T}),(0,Z.jsx)(lC,{id:b,children:R})]})}),zN=W.createContext(void 0);function BN(){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 VN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=CN(),l=LN(),u=NO(!0)!=null,{context:d,hasClosePart:f}=BN(),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`);Zw({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),jT(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?$w(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=FS(`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`,...Qw,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&RO.has(e.key)&&e.stopPropagation()}},PE(g),s],stateAttributesMapping:Fy});return(0,Z.jsx)(bC,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:Uv(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Z.jsx)(zN.Provider,{value:d,children:M})})}),HN=(0,W.createContext)(void 0),UN=e=>({className:t})=>(0,W.createElement)($o,{icon:e,"aria-hidden":!0,...t===void 0?{}:{className:t}}),WN={arrowLeft:UN(bo),arrowsExpand:UN(vo),arrowsToCenter:UN(So),bulletList:UN(Io),buttonCursor:UN(Do),chatBubble:UN(wo),chevronDown:UN(_o),chevronLeft:UN(yo),chevronRight:UN(xo),chevronUp:UN(Co),dividerY:UN(Ko),download:UN(Oo),envelope:UN(Lo),eye:UN(Zo),files:UN(ko),frame:UN(Ao),gridLayoutRows:UN(Fo),heading1:UN(jo),image:UN(Mo),layers:UN(No),message:UN(Ro),mobile:UN(Jo),monitor:UN(Eo),moon:UN(zo),palette:UN(Bo),paragraph:UN(Go),sidebarLeft:UN(Ho),sidebarLeftHide:UN(Vo),sidebarRight:UN(Wo),sidebarRightHide:UN(Uo),sliders:UN(qo),sparkle:UN(Yo),sun:UN(Xo),textColumns:UN(Po),xmark:UN(To)},GN=(0,W.createContext)(WN),KN=GN.Provider,qN=()=>(0,W.useContext)(GN),JN=(0,W.createContext)(null);function YN(){let e=(0,W.useContext)(JN);if(e===null)throw Error(`useEditorBundle must be used within an EditorProvider`);return e}function $(e){return rs(YN().store,e)}function XN(){return YN().store}var ZN=e=>`${e.fileName}:${e.lineNumber}:${e.columnNumber}`,QN=e=>e.occurrences>1?`${e.tag} ${e.occurrence} of ${e.occurrences}`:e.tag,$N=(e,t)=>{let n=e.origins[0];if(n===void 0)return QN(e);let r=t.split(`
|
|
30
30
|
`)[n.lineNumber-1];return r===void 0?QN(e):r.slice(Math.max(0,n.columnNumber-1)).match(/<([A-Za-z][A-Za-z0-9_.:-]*)/)?.[1]??QN(e)},eP=(e,t)=>{let n=t.slice(e.start,e.end).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,` `).replace(/<[^>]+>/g,` `).replace(/ /gi,` `).replace(/&/gi,`&`).replace(/</gi,`<`).replace(/>/gi,`>`).replace(/"/gi,`"`).replace(/'/gi,`'`).replace(/\s+/g,` `).trim();if(n!==``)return n.length>72?`${n.slice(0,69).trimEnd()}…`:n},tP=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},nP=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}},rP=(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},iP=(e,t)=>[...rP(e,t),t].flatMap(t=>{let n=e.index.get(t);return n===void 0?[]:[{instancePath:t,label:QN(n)}]}),aP=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},oP={kind:`document`},sP={kind:`envelope`},cP=e=>new TextEncoder().encode(e).length,lP=e=>Math.max(1,Math.round(e/1024)),uP=e=>e.render===null?0:e.channel===`email`?lP(cP(e.render.html)):e.channel===`sms`?lP(cP(e.render.text)):lP(cP(JSON.stringify(e.render))),dP=(e,t)=>({outline:e.channel===`email`&&e.render!==null?nP(e.render.selections):null,sizeKb:uP(e),checks:CP(e,t)}),fP=(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}),pP=(e,t)=>e.tag===t.tag&&e.authored===t.authored&&e.occurrence===t.occurrence&&e.occurrences===t.occurrences&&fP(e,t),mP=(e,t,n)=>{if(e.kind!==`element`)return e;if(t===null||t.channel!==`email`)return oP;let{render:r,fixture:i}=t;if(r===null||i===null)return oP;let a=r.selections.find(t=>t.instancePath===e.instancePath);if(a===void 0)return oP;if(e.revision===r.revision&&e.fixture===i)return e;let o=n?.index.get(e.instancePath);return o===void 0||!pP(o,a)?oP:{kind:`element`,instancePath:e.instancePath,revision:r.revision,fixture:i}},hP=(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}:{}}},gP=104448,_P=e=>e.severity===`error`?`error`:e.severity===`warning`?`warn`:`info`,vP=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(`-`,` `),yP=(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])=>bP(`${t}:${e}`,[...n.values()]))},bP=(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:_P(i),label:i.compatibility?.title??vP(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}},xP=e=>{let t=cP(e.html);return t<=gP?{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.`}},SP={id:`build:no-render`,severity:`error`,label:`No render`,detail:`The template entry did not produce a render at this revision.`},CP=(e,t)=>{let n=[...yP(e.diagnostics,`diagnostic`),...e.channel===`email`?yP(e.incompatibilities,`compat`):[]];return e.render===null?[...n.length===0?[SP]:n,...t]:e.channel===`email`?[...n,xP(e.render),...t]:[...n,...t]},wP=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}},TP=e=>j(e,`_tag`)&&e._tag===`DocumentUnavailable`&&j(e,`reason`)&&typeof e.reason==`string`,EP=e=>TP(e)?e.reason:e instanceof Error?e.message:`The document session failed.`,DP=(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(TP(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(EP(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(EP(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}}},OP={desktop:600,mobile:375},kP=`samva.editor.leftWidth`,AP=`samva.editor.assistantWidth`,jP=`samva.editor.rightWidth`,MP=260,NP=360,PP=320,FP=200,IP=420,LP=300,RP=520,zP=260,BP=440,VP=(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}},HP=(e,t)=>{try{localStorage.setItem(e,String(t))}catch{}},UP=e=>e!==null&&e.channel===`email`?e.render:null,WP=(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=dP(t,e.hostChecks),i=!e.layersSeeded&&r.outline!==null;return{doc:t,pendingAuthoredSource:n,...r,render:UP(t),expandedLayers:i?aP(r.outline):e.expandedLayers,layersSeeded:e.layersSeeded||i,selection:mP(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:oP,renameActive:!1,expandedLayers:new Set,layersSeeded:!1,leftCollapsed:!1,rightCollapsed:!1,designView:`layers`,focusedPane:`assistant`,leftWidth:VP(kP,MP),assistantWidth:Math.min(RP,Math.max(LP,VP(AP,NP))),rightWidth:VP(jP,PP),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:oP};let{render:n,doc:r}=t;if(n===null||r?.channel!==`email`||r.fixture===null||!n.selections.some(t=>t.instancePath===e))return{selection:oP};let i=new Set(t.expandedLayers);if(t.outline!==null)for(let n of rP(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:oP}),selectEnvelope:()=>s({selection:sP}),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(IP,Math.max(FP,Math.round(e)));HP(kP,t),s({leftWidth:t})},setAssistantWidth:e=>{let t=Math.min(RP,Math.max(LP,Math.round(e)));HP(AP,t),s({assistantWidth:t})},setRightWidth:e=>{let t=Math.min(BP,Math.max(zP,Math.round(e)));HP(jP,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?[]:rP(t,e)},breadcrumbOf:e=>{let{outline:t}=c();return t===null?[]:iP(t,e)},setHovered:e=>s({hoveredCandidatePath:e}),setHostChecks:e=>{Object.is(c().hostChecks,e)||s(t=>({hostChecks:e,checks:t.doc===null?e:CP(t.doc,e)}))}}}}),c=(e,t)=>{s.setState(n=>{if(n.doc===null)return n;let r=t?n.pendingAuthoredSource:null,i=hP(n.doc,e,r),a=e.authoredSource!==void 0&&e.authoredSource===i.origin.authoredSource;return o(n,i,a?null:r)})};return n=DP(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}}},GP=[];function KP({host:e,checks:t=GP,icons:n,onSelectElement:r,preparePreviewDocument:i,children:a}){let[o,s]=(0,W.useState)(()=>WP(e,{hostChecks:t}));o.host!==e&&s(WP(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?WN:{...WN,...n},[n]);return(0,Z.jsx)(JN.Provider,{value:o,children:(0,Z.jsx)(HN.Provider,{value:i,children:(0,Z.jsx)(KN,{value:c,children:a})})})}var qP=e=>{let t=({className:t})=>{let n=qN()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})};return t.displayName=`EditorIcon(${e})`,t},JP=qP(`arrowsExpand`),YP=qP(`arrowsToCenter`),XP=qP(`bulletList`),ZP=qP(`buttonCursor`),QP=qP(`chevronDown`),$P=qP(`chevronLeft`),eF=qP(`chevronRight`),tF=qP(`chevronUp`),nF=qP(`dividerY`),rF=qP(`download`),iF=qP(`envelope`),aF=qP(`eye`),oF=qP(`files`),sF=qP(`frame`),cF=qP(`gridLayoutRows`),lF=qP(`heading1`),uF=qP(`image`),dF=qP(`layers`),fF=qP(`mobile`),pF=qP(`monitor`),mF=qP(`palette`),hF=qP(`paragraph`),gF=qP(`sidebarLeft`),_F=qP(`sidebarLeftHide`),vF=qP(`sidebarRight`),yF=qP(`sidebarRightHide`),bF=qP(`sliders`),xF=qP(`sparkle`),SF=qP(`textColumns`),CF=qP(`xmark`);function wF(...e){return gk(e)}var TF=`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,EF=wF(`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`,TF),DF=wF(`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`,TF,`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)]`),OF=wF(`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`,TF),kF=new Set([`frame.start`,`document.switcher`,`rail.assistant`,`rail.review`,`statusbar.headline`]),AF=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(kF.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]}},jF=(0,W.createContext)(AF([])),MF=jF.Provider,NF=e=>(0,W.useContext)(jF).one(e),PF=e=>(0,W.useContext)(jF).all(e),FF=(0,W.createContext)(null),IF=FF.Provider;function LF(){let e=NF(`rail.assistant`),t=NF(`rail.review`),n=(0,W.useContext)(FF),r=XN(),{doc:i,render:a,outline:o,selection:s,originIndex:c,checks:l,diagnosticAssistance:u,layout:d,canFix:f}=$(mk(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=wP(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:QN(m)},g=i?.channel===`email`?i.fixture:null,_=o===null||g===null||a===null||i===null?[]:tP(o).map(({depth:e,node:t})=>{let n=eP(t.selection,a.html);return{instancePath:t.instancePath,fixture:g,...t.selection.origins[c]===void 0?{}:{originIndex:c},label:$N(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 RF({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:wF(`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)(xF,{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 zF(){let e=LF(),{rightCollapsed:t,rightWidth:n,layoutMode:r}=$(mk(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:wF(`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 BF=(0,W.createContext)(void 0),VF=()=>(0,W.useContext)(BF);function HF({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:wF(`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 UF(){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)(HF,{label:`Authored TSX · ${e.origin.file}`,source:e.origin.authoredSource,editable:t,testId:`source-workspace.authored-tsx`,onChange:t?n:void 0})})}function WF(e){let t=XN(),{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 GF(e,t){return`${e}-view-tab-${t}`}var KF=wF(DF,`h-7 px-2.5 text-[12px] capitalize`);function qF({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)(Ok,{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)(xk,{id:GF(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:KF,children:t},t))}),r===void 0&&(0,Z.jsx)(`div`,{role:`tabpanel`,id:s,"aria-labelledby":GF(o,e),className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:n})]})}function JF({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 XF({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 ZF({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 QF({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 $F({text:e,className:t}){let n=J_(e);return(0,Z.jsxs)(`p`,{"data-testid":`sms-counter`,className:wF(`text-muted-foreground`,t),children:[n.encoding.toUpperCase(),` · `,n.characterCount,` character`,n.characterCount===1?``:`s`,` · `,n.segmentCount,` segment`,n.segmentCount===1?``:`s`]})}function eI({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 tI=`none`;function nI({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 rI({form:e,editable:t,onEdit:n}){let r=VF(),i=e.category.kind===`literal`?e.category.value:void 0;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(JF,{label:`Category`,children:(0,Z.jsxs)(ID,{value:i??tI,disabled:!t||e.category.kind===`expression`,onValueChange:e=>n({kind:`category`,value:po.find(t=>t.value===e)?.value}),children:[(0,Z.jsx)(ZD,{"data-testid":`sms-workspace.category`,className:OF,children:(0,Z.jsx)($D,{})}),(0,Z.jsx)(eO,{container:r,children:(0,Z.jsx)(kO,{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)(sk,{value:tI,"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)(ck,{children:`Not set`})}),po.map(e=>(0,Z.jsx)(sk,{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)(ck,{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:`${OF} resize-y py-2`},`text-${r}`))]}),(0,Z.jsx)(QF,{variables:e.variables})]})}function iI(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=WF(P_),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>N_(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)(qF,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(UF,{}):(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)(ZF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(eI,{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)(rI,{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)(nI,{segments:s.segments,editable:t,onChange:(e,t)=>a({kind:`text`,segment:e,text:t},`sms-${e}`)}),c!==null&&(0,Z.jsx)($F,{text:c.text,className:`mt-4 text-center text-[11.5px]`})]})}),(0,Z.jsx)(zF,{})]})})})}var aI=[{kind:`text`,text:``,start:0,end:0}],oI=e=>e.kind===`literal`?e.value:e.kind===`expression`?e.source:``;function sI({value:e,options:t,disabled:n,ariaLabel:r,onChange:i}){let a=VF();return(0,Z.jsxs)(ID,{value:e,disabled:n,onValueChange:e=>{let n=t.find(t=>t.value===e);n!==void 0&&i(n.value)},children:[(0,Z.jsx)(ZD,{"aria-label":r,className:OF,children:(0,Z.jsx)($D,{})}),(0,Z.jsx)(eO,{container:a,children:(0,Z.jsx)(kO,{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)(sk,{value:e.value,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(ck,{children:e.label})},e.value))})})})]})}function cI({label:e,part:t,segments:n,editable:r,onEdit:i}){let a=n??aI,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)(XF,{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:`${OF} min-w-[8ch] flex-1`},`text-${a}`))})]})}function lI({ariaLabel:e,state:t,editable:n,onChange:r,testId:i}){return(0,Z.jsx)(`input`,{"aria-label":e,"data-testid":i,value:oI(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:OF})}function uI({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)(sI,{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:OF}),e.type===`url`&&(0,Z.jsx)(lI,{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)(lI,{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)(sI,{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 dI({form:e,editable:t,onEdit:n}){let r=oI(e.category),i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(JF,{label:`Language`,children:(0,Z.jsx)(lI,{ariaLabel:`Language`,state:e.language,editable:t,onChange:e=>n({kind:`attribute`,name:`language`,value:e},`whatsapp-language`)})}),(0,Z.jsx)(JF,{label:`Category`,children:(0,Z.jsx)(sI,{value:r,options:mo,disabled:!t||e.category.kind!==`literal`,onChange:e=>n({kind:`attribute`,name:`category`,value:e})})}),(0,Z.jsx)(JF,{label:`Header type`,children:(0,Z.jsx)(sI,{value:i,options:ho,disabled:!t||e.header===null||e.headerType.kind===`expression`,onChange:e=>n({kind:`headerType`,value:e})})}),(0,Z.jsx)(cI,{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:`${OF} resize-y py-2`},`body-text-${r}`))]}),(0,Z.jsx)(cI,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,onEdit:n}),(0,Z.jsx)(uI,{buttons:e.buttons,editable:t,onEdit:n}),(0,Z.jsx)(QF,{variables:e.variables})]})}function fI({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??aI).map((n,s)=>n.kind===`locked`?(0,Z.jsx)(XF,{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 pI=e=>e.type===`copy-code`?`Copy code`:e.text;function mI({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)(fI,{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)(XF,{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(`
|
|
31
|
-
`).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)(fI,{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:pI(e)},`${pI(e)}-${t}`))]}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-4 text-center text-[11.5px] capitalize`,children:[n?.category??(oI(e.category)||`utility`),` template`]})]})}function hI(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=WF(W_),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>B_(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)(qF,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(UF,{}):(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)(ZF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(eI,{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)(dI,{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)(mI,{form:s,editable:t,render:c,onEdit:a})}),(0,Z.jsx)(zF,{})]})})})}var gI=e=>({top:e.top,left:e.left,width:e.width,height:e.height}),_I=(e,t)=>{let n=e.querySelectorAll(`[${Gc}="${CSS.escape(t)}"]`),r=null;for(let e of n){let t=gI(e.getBoundingClientRect());if(r??=t,t.width>0&&t.height>0)return t}return r},vI=`a[href],button,input[type="button"],input[type="submit"],input[type="image"]`,yI=e=>e!==null&&`closest`in e&&typeof e.closest==`function`,bI=e=>yI(e)&&e.closest(vI)!==null,xI=e=>yI(e)?e.closest(`[data-samva-instance]`)?.getAttribute(`data-samva-instance`)??null:null,SI=`html,body{margin:0;padding:0;overflow:hidden}`,CI={"--editor-canvas-hover":`#93c5fd`,"--editor-canvas-selected":`#2563eb`,"--editor-canvas-selected-fg":`#fff`,"--editor-canvas-generated":`#a855f7`},wI=e=>`:root{${Object.entries(CI).map(([t,n])=>`${t}:${e[t]?.trim()||n}`).join(`;`)}}`,TI=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(CI).map(e=>(n.style.color=`var(${e})`,[e,getComputedStyle(n).color])));return n.remove(),r},EI=/@media\s*\(\s*prefers-color-scheme:\s*dark\s*\)/g,DI=(e,t)=>e.replace(EI,t===`dark`?`@media all`:`@media not all`),OI=e=>e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.button!==0,kI=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},AI=({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,kI(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=`${SI}${wI(TI(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}),kI(n)},m=e=>{!OI(e)&&bI(e.target)&&e.preventDefault(),d.current.onSelect?.(xI(e.target))},h=e=>d.current.onHover?.(xI(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:xI(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,XS.createPortal)(i,l):null})},jI=({html:e,forceColorScheme:t,...n})=>{let r=(0,W.useContext)(HN),i=t===void 0?e:DI(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)(AI,{document_:c,mount:a?.mount,dark:t===`dark`,...n},`${o.generation}:${t??``}:${e}`)},MI=(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}),NI=({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:_I(e,c)),s(l===null||l===c?null:_I(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:MI(o,`var(--editor-canvas-hover)`,1)}),i!==null&&t!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:MI(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?QN(t):`${QN(t)} · generated`})]}):null]})},PI=(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=qg(t,s,`_blank`);c!==null&&r.set(c.start,c)}return[...r.values()].sort((e,t)=>e.start-t.start)};function FI({check:e}){let t=NF(`rail.assistant`)!==void 0,{doc:n,sourceEditable:r,pending:i,conflict:a,lifecycleBusy:o}=$(mk(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=PI(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 II={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,` ·`,` `,II[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(ZN).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 RI=e=>e===void 0?`No default sender`:e.name?`${e.name} <${e.email}>`:e.email;function zI(){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 BI({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 VI(){let{doc:e,render:t,selected:n,layoutMode:r}=$(mk(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)(Bk,{open:!p||a,onOpenChange:e=>{e||(c.current=!0),o(e)},children:[p&&!a&&(0,Z.jsxs)(Hk,{ref:s,"aria-label":`Expand envelope`,"data-testid":`envelope.expand`,onClick:e=>{e.stopPropagation(),i()},className:wF(`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)(QP,{className:`text-muted-foreground size-4 shrink-0`})]}),(0,Z.jsx)(Qk,{children:(0,Z.jsxs)(`div`,{onClick:e=>{e.stopPropagation(),i()},className:wF(`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)(Hk,{"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)(tF,{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:RI(l)}),(0,Z.jsx)(zI,{})]}),(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)(zI,{})]})]}),(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)(BI,{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)(BI,{value:f,placeholder:`No preview text`,testId:`envelope.preview-value`})]})]})]})})]})}var HI=wF(`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 UI({children:e,ancestors:t,onSelect:n,onOpenChange:r,portalContainer:i,open:a,anchor:o}){return(0,Z.jsxs)(EA,{open:a,onOpenChange:r,children:[(0,Z.jsx)(OA,{render:e}),(0,Z.jsx)(fA,{container:i,children:(0,Z.jsx)(kA,{anchor:o,sideOffset:2,children:(0,Z.jsxs)(lA,{"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)(cA,{className:HI,"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 WI({name:e,className:t}){return(0,Z.jsx)(`span`,{className:wF(`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 GI({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 KI({children:e,className:t,title:n,help:r=n,pressed:i,onClick:a,disabled:o,testId:s}){let c=VF();return(0,Z.jsxs)(tE,{disabled:o,children:[(0,Z.jsx)(lE,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":n,"aria-pressed":i,disabled:o,"data-testid":s,onClick:a,className:wF(`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`,TF,t)}),children:e}),(0,Z.jsx)(pE,{container:c,children:(0,Z.jsx)(IE,{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 qI({ariaLabel:e,options:t,value:n,onChange:r,size:i=`md`,testId:a}){let o=VF();return(0,Z.jsx)(Ok,{"aria-label":e,value:[n],"data-testid":a,onValueChange:e=>{let t=e[0];t!==void 0&&r(t)},className:wF(`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)(xk,{type:`button`,"aria-label":e.title,"data-testid":e.testId,value:e.value,className:wF(DF,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)(tE,{children:[(0,Z.jsx)(lE,{render:t}),(0,Z.jsx)(pE,{container:o,children:(0,Z.jsx)(IE,{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 JI({children:e,className:t,overridden:n,testId:r}){return(0,Z.jsxs)(`span`,{"data-testid":r,className:wF(`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}=$(mk(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=VF(),m=PF(`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=[...rP(r,t.instancePath),t.instancePath].toReversed().flatMap(e=>{let t=r.index.get(e);return t===void 0?[]:[{instancePath:e,label:QN(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)(jI,{html:n.html,width:T,onSelect:s,onHover:l,onContextMenu:e?void 0:D,overlay:(0,Z.jsx)(NI,{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)(VI,{}),O===null?(0,Z.jsx)(XI,{}):e?O:(0,Z.jsx)(UI,{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)(qI,{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)(pF,{className:`size-[13px]`})},{value:`mobile`,title:`Preview mobile width`,testId:`canvas.device.mobile`,label:(0,Z.jsx)(fF,{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:wF(`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 XI(){let e=$(mk(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)(FI,{check:e})})},e.id))})]})}function ZI({checks:e,editable:t=!1}){let{actionable:n}=wP(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)(FI,{check:e}):void 0},e.id)),(0,Z.jsx)(QI,{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 QI({checks:e,editable:t=!1}){let n=VF(),r=Object.fromEntries(Object.keys(II).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?[]:[bP(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)(Mj,{onOpenChange:e=>{e&&(a(r.unverified>0?`unverified`:`all`),s(`all`))},children:[(0,Z.jsx)(Fj,{"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)(Tj,{container:n,children:[(0,Z.jsx)(gj,{className:`fixed inset-0 z-[130] bg-black/30`}),(0,Z.jsxs)(wj,{"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)(Pj,{className:`text-lg font-semibold`,children:`Compatibility report`}),(0,Z.jsx)(_j,{"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)(vj,{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(II).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(II).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)(FI,{check:e}):void 0})},e.id))})]})]})]})}var $I=wF(`border-border bg-background text-foreground w-full rounded border px-2 py-1.5 text-xs`,TF),eL=wF(`border-border hover:bg-muted rounded border px-2 py-1 text-xs disabled:opacity-50`,TF);function tL({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:[nL(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:$I,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:eL,disabled:qg(t,e,i)===null,onClick:()=>{let n=qg(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:$I,value:o,onChange:e=>s(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.review`,type:`button`,className:eL,onClick:()=>n(Jg(t,e,o)),children:`Review expression diff`})]})]})}var nL=e=>e===`children`||e.startsWith(`text.`)?`Text`:e===`className`?`Style classes`:e,rL=e=>e instanceof Error&&e.message!==``?e.message:`The host could not save this.`;function iL(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 aL(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 oL(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 sL({selection:e}){let{doc:t,pending:n,revision:r,editable:i,storeError:a,lifecycleBusy:o}=$(mk(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=NF(`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=iL(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(rL(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=r_(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)(GI,{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:$I,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}`,` · `,ZN(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.`:oL(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)(tL,{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:$I,value:S,onChange:e=>C(e.target.value)})]}),(0,Z.jsx)(`button`,{"data-testid":`source.classes-add`,type:`button`,className:eL,disabled:S.trim()===``,onClick:()=>{let e=r_(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:$I,onChange:e=>T(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.review-insert`,type:`button`,className:eL,disabled:R.contentEnd===null,onClick:()=>{let e=$g(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:eL,disabled:!R.structural,onClick:()=>{let e=$g(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:eL,disabled:!R.structural,onClick:()=>{let e=$g(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:eL,disabled:R.previous===null,onClick:()=>{let e=$g(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:eL,disabled:R.next===null,onClick:()=>{let e=$g(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:$I,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`:ZN(e.origins[0])]},e.instancePath))]})]}),(0,Z.jsx)(`button`,{"data-testid":`source.review-move`,type:`button`,className:eL,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:$g(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(`
|
|
31
|
+
`).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)(fI,{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:pI(e)},`${pI(e)}-${t}`))]}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-4 text-center text-[11.5px] capitalize`,children:[n?.category??(oI(e.category)||`utility`),` template`]})]})}function hI(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=WF(W_),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>B_(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)(qF,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(UF,{}):(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)(ZF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(eI,{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)(dI,{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)(mI,{form:s,editable:t,render:c,onEdit:a})}),(0,Z.jsx)(zF,{})]})})})}var gI=e=>({top:e.top,left:e.left,width:e.width,height:e.height}),_I=(e,t)=>{let n=e.querySelectorAll(`[${Gc}="${CSS.escape(t)}"]`),r=null;for(let e of n){let t=gI(e.getBoundingClientRect());if(r??=t,t.width>0&&t.height>0)return t}return r},vI=`a[href],button,input[type="button"],input[type="submit"],input[type="image"]`,yI=e=>e!==null&&`closest`in e&&typeof e.closest==`function`,bI=e=>yI(e)&&e.closest(vI)!==null,xI=e=>yI(e)?e.closest(`[data-samva-instance]`)?.getAttribute(`data-samva-instance`)??null:null,SI=`html,body{margin:0;padding:0;overflow:hidden}`,CI={"--editor-canvas-hover":`#93c5fd`,"--editor-canvas-selected":`#2563eb`,"--editor-canvas-selected-fg":`#fff`,"--editor-canvas-generated":`#a855f7`},wI=e=>`:root{${Object.entries(CI).map(([t,n])=>`${t}:${e[t]?.trim()||n}`).join(`;`)}}`,TI=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(CI).map(e=>(n.style.color=`var(${e})`,[e,getComputedStyle(n).color])));return n.remove(),r},EI=/@media\s*\(\s*prefers-color-scheme:\s*dark\s*\)/g,DI=(e,t)=>e.replace(EI,t===`dark`?`@media all`:`@media not all`),OI=e=>e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.button!==0,kI=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},AI=({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,kI(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=`${SI}${wI(TI(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}),kI(n)},m=e=>{!OI(e)&&bI(e.target)&&e.preventDefault(),d.current.onSelect?.(xI(e.target))},h=e=>d.current.onHover?.(xI(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:xI(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,XS.createPortal)(i,l):null})},jI=({html:e,forceColorScheme:t,...n})=>{let r=(0,W.useContext)(HN),i=t===void 0?e:DI(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)(AI,{document_:c,mount:a?.mount,dark:t===`dark`,...n},`${o.generation}:${t??``}:${e}`)},MI=(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}),NI=({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:_I(e,c)),s(l===null||l===c?null:_I(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:MI(o,`var(--editor-canvas-hover)`,1)}),i!==null&&t!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:MI(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?QN(t):`${QN(t)} · generated`})]}):null]})},PI=(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=qg(t,s,`_blank`);c!==null&&r.set(c.start,c)}return[...r.values()].sort((e,t)=>e.start-t.start)};function FI({check:e}){let t=NF(`rail.assistant`)!==void 0,{doc:n,sourceEditable:r,pending:i,conflict:a,lifecycleBusy:o}=$(mk(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=PI(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 II={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,` ·`,` `,II[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(ZN).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 RI=e=>e===void 0?`No default sender`:e.name?`${e.name} <${e.email}>`:e.email;function zI(){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 BI({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 VI(){let{doc:e,render:t,selected:n,layoutMode:r}=$(mk(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)(Bk,{open:!p||a,onOpenChange:e=>{e||(c.current=!0),o(e)},children:[p&&!a&&(0,Z.jsxs)(Hk,{ref:s,"aria-label":`Expand envelope`,"data-testid":`envelope.expand`,onClick:e=>{e.stopPropagation(),i()},className:wF(`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)(QP,{className:`text-muted-foreground size-4 shrink-0`})]}),(0,Z.jsx)(Qk,{children:(0,Z.jsxs)(`div`,{onClick:e=>{e.stopPropagation(),i()},className:wF(`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)(Hk,{"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)(tF,{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:RI(l)}),(0,Z.jsx)(zI,{})]}),(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)(zI,{})]})]}),(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)(BI,{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)(BI,{value:f,placeholder:`No preview text`,testId:`envelope.preview-value`})]})]})]})})]})}var HI=wF(`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 UI({children:e,ancestors:t,onSelect:n,onOpenChange:r,portalContainer:i,open:a,anchor:o}){return(0,Z.jsxs)(EA,{open:a,onOpenChange:r,children:[(0,Z.jsx)(OA,{render:e}),(0,Z.jsx)(fA,{container:i,children:(0,Z.jsx)(kA,{anchor:o,sideOffset:2,children:(0,Z.jsxs)(lA,{"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)(cA,{className:HI,"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 WI({name:e,className:t}){return(0,Z.jsx)(`span`,{className:wF(`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 GI({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 KI({children:e,className:t,title:n,help:r=n,pressed:i,onClick:a,disabled:o,testId:s}){let c=VF();return(0,Z.jsxs)(tE,{disabled:o,children:[(0,Z.jsx)(lE,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":n,"aria-pressed":i,disabled:o,"data-testid":s,onClick:a,className:wF(`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`,TF,t)}),children:e}),(0,Z.jsx)(pE,{container:c,children:(0,Z.jsx)(IE,{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 qI({ariaLabel:e,options:t,value:n,onChange:r,size:i=`md`,testId:a}){let o=VF();return(0,Z.jsx)(Ok,{"aria-label":e,value:[n],"data-testid":a,onValueChange:e=>{let t=e[0];t!==void 0&&r(t)},className:wF(`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)(xk,{type:`button`,"aria-label":e.title,"data-testid":e.testId,value:e.value,className:wF(DF,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)(tE,{children:[(0,Z.jsx)(lE,{render:t}),(0,Z.jsx)(pE,{container:o,children:(0,Z.jsx)(IE,{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 JI({children:e,className:t,overridden:n,testId:r}){return(0,Z.jsxs)(`span`,{"data-testid":r,className:wF(`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}=$(mk(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=VF(),m=PF(`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=[...rP(r,t.instancePath),t.instancePath].toReversed().flatMap(e=>{let t=r.index.get(e);return t===void 0?[]:[{instancePath:e,label:QN(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)(jI,{html:n.html,width:T,onSelect:s,onHover:l,onContextMenu:e?void 0:D,overlay:(0,Z.jsx)(NI,{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 [scrollbar-gutter:stable] 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)(VI,{}),O===null?(0,Z.jsx)(XI,{}):e?O:(0,Z.jsx)(UI,{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)(qI,{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)(pF,{className:`size-[13px]`})},{value:`mobile`,title:`Preview mobile width`,testId:`canvas.device.mobile`,label:(0,Z.jsx)(fF,{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:wF(`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 XI(){let e=$(mk(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)(FI,{check:e})})},e.id))})]})}function ZI({checks:e,editable:t=!1}){let{actionable:n}=wP(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)(FI,{check:e}):void 0},e.id)),(0,Z.jsx)(QI,{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 QI({checks:e,editable:t=!1}){let n=VF(),r=Object.fromEntries(Object.keys(II).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?[]:[bP(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)(Mj,{onOpenChange:e=>{e&&(a(r.unverified>0?`unverified`:`all`),s(`all`))},children:[(0,Z.jsx)(Fj,{"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)(Tj,{container:n,children:[(0,Z.jsx)(gj,{className:`fixed inset-0 z-[130] bg-black/30`}),(0,Z.jsxs)(wj,{"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)(Pj,{className:`text-lg font-semibold`,children:`Compatibility report`}),(0,Z.jsx)(_j,{"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)(vj,{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(II).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(II).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)(FI,{check:e}):void 0})},e.id))})]})]})]})}var $I=wF(`border-border bg-background text-foreground w-full rounded border px-2 py-1.5 text-xs`,TF),eL=wF(`border-border hover:bg-muted rounded border px-2 py-1 text-xs disabled:opacity-50`,TF);function tL({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:[nL(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:$I,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:eL,disabled:qg(t,e,i)===null,onClick:()=>{let n=qg(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:$I,value:o,onChange:e=>s(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.review`,type:`button`,className:eL,onClick:()=>n(Jg(t,e,o)),children:`Review expression diff`})]})]})}var nL=e=>e===`children`||e.startsWith(`text.`)?`Text`:e===`className`?`Style classes`:e,rL=e=>e instanceof Error&&e.message!==``?e.message:`The host could not save this.`;function iL(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 aL(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 oL(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 sL({selection:e}){let{doc:t,pending:n,revision:r,editable:i,storeError:a,lifecycleBusy:o}=$(mk(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=NF(`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=iL(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(rL(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=r_(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)(GI,{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:$I,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}`,` · `,ZN(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.`:oL(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)(tL,{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:$I,value:S,onChange:e=>C(e.target.value)})]}),(0,Z.jsx)(`button`,{"data-testid":`source.classes-add`,type:`button`,className:eL,disabled:S.trim()===``,onClick:()=>{let e=r_(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:$I,onChange:e=>T(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.review-insert`,type:`button`,className:eL,disabled:R.contentEnd===null,onClick:()=>{let e=$g(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:eL,disabled:!R.structural,onClick:()=>{let e=$g(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:eL,disabled:!R.structural,onClick:()=>{let e=$g(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:eL,disabled:R.previous===null,onClick:()=>{let e=$g(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:eL,disabled:R.next===null,onClick:()=>{let e=$g(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:$I,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`:ZN(e.origins[0])]},e.instancePath))]})]}),(0,Z.jsx)(`button`,{"data-testid":`source.review-move`,type:`button`,className:eL,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:$g(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(`
|
|
32
32
|
`)}),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:eL,disabled:O.refusal!==null,onClick:()=>{ne(O.edits),k(null)},children:`Apply structural change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:eL,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(`
|
|
33
33
|
`)}),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:eL,disabled:A.refusal!==null,onClick:()=>{ne(A.edits),j(null)},children:`Apply reviewed change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:eL,onClick:()=>j(null),children:`Cancel`})]})]}):(0,Z.jsx)(`p`,{"data-testid":`source.unavailable`,className:`text-muted-foreground mt-2 text-xs`,children:aL({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:eL,onClick:c,children:`Open source`}),p&&(0,Z.jsx)(`button`,{type:`button`,className:eL,onClick:()=>l(m),children:`Ask agent`})]})]})}function cL(){let{undo:e,redo:t,error:n,editable:r}=$(mk(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:eL,disabled:!r||e===0,onClick:i.undo,children:`Undo`}),(0,Z.jsx)(`button`,{"data-testid":`source.redo`,type:`button`,className:eL,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 lL(){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=t_(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)(GI,{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:eL,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:$I,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:eL,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:eL,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:eL,onClick:()=>{o(null),c(!1)},children:`Cancel`})]})]})]})}function uL({selection:e}){let t=$(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(sL,{selection:e},t)}function dL(){let e=$(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(lL,{},e)}var fL=[],pL=[],mL=[];function hL({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 gL(){let e=$(e=>e.doc?.variables??pL);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(GI,{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)(WI,{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 _L(){let e=$(e=>e.checks),t=$(e=>e.sourceEditable);return(0,Z.jsx)(`div`,{className:`py-3`,children:(0,Z.jsx)(ZI,{checks:e,editable:t})})}function vL(){let{deviceWidth:e,entryFile:t,fixture:n,fixtures:r}=$(mk(e=>({deviceWidth:OP[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:fL})));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(GI,{children:`Document`}),(0,Z.jsx)(hL,{label:`Width`,children:(0,Z.jsxs)(JI,{children:[e,` `,(0,Z.jsx)(`span`,{className:`text-placeholder text-[10.5px]`,children:`px`})]})}),t!==null&&(0,Z.jsx)(hL,{label:`Entry`,children:(0,Z.jsx)(JI,{children:t})}),n!==null&&(0,Z.jsx)(hL,{label:`Fixture`,title:`${r.length} declared`,children:(0,Z.jsx)(JI,{children:n})})]}),(0,Z.jsx)(dL,{},`${n}:${t}`),(0,Z.jsx)(gL,{}),(0,Z.jsx)(_L,{})]})}function yL({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:wF(`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`,TF)})}function bL(){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)(GI,{children:`Defaults · per send`}),(0,Z.jsx)(hL,{label:`From name`,children:(0,Z.jsx)(yL,{value:i,onChange:a,onCommit:u,placeholder:`Sender name`})}),(0,Z.jsx)(hL,{label:`From email`,children:(0,Z.jsx)(yL,{type:`email`,value:o,onChange:s,onCommit:u,placeholder:`you@domain.com`,testId:`inspector.envelope.from-email`})}),(0,Z.jsx)(hL,{label:`Reply-To`,children:(0,Z.jsx)(yL,{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 xL(){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)(GI,{children:`Rendered`}),(0,Z.jsx)(hL,{label:`Subject`,children:(0,Z.jsx)(JI,{children:t?.subject??`No subject`})}),(0,Z.jsx)(hL,{label:`Preview`,children:(0,Z.jsx)(JI,{children:t?.preheader??`No preview text`})})]}),e?(0,Z.jsx)(bL,{}):(0,Z.jsx)(`p`,{className:`text-muted-foreground py-3 text-xs`,children:`This host does not edit sender defaults.`})]})}function SL({selection:e}){let t=$(e=>e.render?.selections??mL),{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)(GI,{children:`Element`}),(0,Z.jsx)(hL,{label:`Tag`,children:(0,Z.jsx)(JI,{testId:`inspector.element.tag`,children:e.tag})}),(0,Z.jsx)(hL,{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)(JI,{testId:`inspector.element.provenance`,children:e.authored?`Authored`:`Generated`})}),(0,Z.jsx)(hL,{label:`Instance`,children:(0,Z.jsx)(JI,{testId:`inspector.element.instance`,children:e.instancePath})})]}),(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(GI,{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)(hL,{label:`Written at`,children:(0,Z.jsx)(JI,{testId:`inspector.authoring.origin`,children:ZN(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)(uL,{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)(GI,{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:ZN(e)},`${ZN(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)(GI,{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:wF(`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 CL({embedded:e=!1}={}){let t=VF(),{outline:n,selection:r,rightCollapsed:i,rightWidth:a,layoutMode:o}=$(mk(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:wF(`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?QN(d):`${d.tag} · generated`}),!e&&(0,Z.jsxs)(tE,{children:[(0,Z.jsx)(lE,{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)(yF,{className:`size-[15px]`})}),(0,Z.jsx)(pE,{container:t,children:(0,Z.jsx)(IE,{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)(JA,{"data-samva-scroll-area":`inspector`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(oj,{className:`size-full`,children:(0,Z.jsxs)(`div`,{className:`samva-inspector-content pb-4`,children:[f===`document`&&(0,Z.jsx)(vL,{}),f===`envelope`&&(0,Z.jsx)(xL,{}),d!==null&&(0,Z.jsx)(SL,{selection:d})]})}),(0,Z.jsx)(fj,{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)(pj,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}var wL={body:iF,div:sF,table:cF,tbody:cF,tr:cF,td:SF,th:SF,h1:lF,h2:lF,h3:lF,h4:lF,h5:lF,h6:lF,p:hF,span:hF,a:ZP,button:ZP,img:uF,hr:nF,br:JP,ul:XP,ol:XP,li:XP},TL=e=>wL[e.toLowerCase()]??sF;function EL({node:e,depth:t}){let{selectedPath:n,expandedLayers:r}=$(mk(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:wF(`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`} ${QN(u)}`,className:wF(`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)(eF,{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)(TL(u.tag),{className:wF(`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:QN(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)(EL,{node:e,depth:t+1},e.instancePath))})]})}function DL(){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)(EL,{node:e,depth:0},e.instancePath))})}function OL(){let e=VF(),{leftCollapsed:t,leftWidth:n,layoutMode:r}=$(mk(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:wF(`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)(tE,{children:[(0,Z.jsx)(lE,{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)(_F,{className:`size-[15px]`})}),(0,Z.jsx)(pE,{container:e,children:(0,Z.jsx)(IE,{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)(JA,{"data-samva-scroll-area":`layers`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(oj,{className:`size-full`,children:(0,Z.jsx)(`div`,{className:`px-2 pt-2.5 pb-5`,children:(0,Z.jsx)(DL,{})})}),(0,Z.jsx)(fj,{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)(pj,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}function kL({embedded:e=!1}={}){let t=VF(),{checks:n,doc:r,readonlyReason:i,rightCollapsed:a,rightWidth:o}=$(mk(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)(tE,{children:[(0,Z.jsx)(lE,{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)(yF,{className:`size-[15px]`})}),(0,Z.jsx)(pE,{container:t,children:(0,Z.jsx)(IE,{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)(ZI,{checks:n})})]})]})}var AL=wF(`flex flex-1 items-center justify-center gap-1.5 px-2 text-[12px]`,DF),jL={layers:{label:`Layers`,Icon:dF},inspector:{label:`Inspector`,Icon:bF},review:{label:`Review`,Icon:oF}},ML=[`layers`,`inspector`,`review`];function NL({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)(DL,{})}):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)(CL,{embedded:!0}):(0,Z.jsx)(kL,{embedded:!0})}function PL({focused:e=!1}){let t=$(e=>e.sourceEditable),n=$(e=>e.rightWidth),r=$(e=>e.designView),i=$(e=>e.actions.setDesignView),a=NF(`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:wF(`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)(Ok,{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:ML.filter(e=>e!==`review`||a!==null).map(e=>{let{Icon:t,label:n}=jL[e];return(0,Z.jsxs)(xk,{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:AL,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)(NL,{view:o,sourceEditable:t,review:a})})]})}function FL({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:wF(`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 IL={assistant:{label:`Assistant`,tip:`Show the assistant`,Icon:xF},preview:{label:`Preview`,tip:`Show the preview`,Icon:aF},design:{label:`Design`,tip:`Show designs, layers, and inspector`,Icon:dF}};function LL(){let e=$(e=>e.sourceEditable),t=$(e=>e.leftCollapsed),n=$(e=>e.rightCollapsed),r=$(e=>e.layoutMode),i=NF(`rail.assistant`)!==void 0,a=NF(`rail.review`),o=$(e=>e.workspaceView),s=$(e=>e.focusedPane),c=$(e=>e.actions.setFocusedPane),l=XN(),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)(qF,{value:o,onChange:e=>{u(e),m&&c(`preview`)},idBase:d,panelId:`${d}-view-panel`}),m&&(0,Z.jsx)(Ok,{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}=IL[e];return(0,Z.jsxs)(xk,{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:wF(DF,`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:wF(!m&&`contents`,m&&g===`assistant`&&`flex h-full min-h-0 min-w-0 flex-1`),children:(0,Z.jsx)(RF,{hidden:m&&g!==`assistant`})}),!m&&(0,Z.jsx)(FL,{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:wF(`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":GF(d,o),className:`flex min-h-0 min-w-0 flex-1`,children:o===`source`?(0,Z.jsx)(UF,{}):(0,Z.jsx)(YI,{pointing:!0})})}),!m&&(0,Z.jsx)(FL,{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:wF(!m&&`contents`,m&&g===`design`&&`flex h-full min-h-0 min-w-0 flex-1`),children:p?null:(0,Z.jsx)(PL,{focused:m})})]})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(cL,{}),(0,Z.jsx)(qF,{value:o,onChange:u,children:o===`source`?(0,Z.jsx)(UF,{}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(OL,{}),!t&&(0,Z.jsx)(FL,{side:`left`}),(0,Z.jsx)(YI,{}),!n&&(0,Z.jsx)(FL,{side:`right`}),e?(0,Z.jsx)(CL,{}):(0,Z.jsx)(kL,{})]})})]})}var RL=RegExp(`\\s${Gc}="[^"]*"`,`g`),zL=e=>e.replace(RL,``),BL=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t===``?`email`:t},VL=(e,t)=>{let n=new Blob([zL(e)],{type:`text/html;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${BL(t)}.html`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)},HL=`image/png,image/jpeg,image/gif,image/webp,.woff2`,UL=1048576,WL=(e,t)=>{let n=e?.lastIndexOf(`/`)??-1;return`${e===void 0||n<0?``:e.slice(0,n+1)}assets/${t}`},GL=e=>{let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(t):``},KL=e=>j(e,`_tag`)&&e._tag===`ProjectFileExists`,qL=e=>j(e,`reason`)&&typeof e.reason==`string`?e.reason:`The template project operation failed.`,JL=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:wF(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs disabled:opacity-50`,TF),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:wF(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,TF),children:`Apply file`})]})]})}function XL({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:wF(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,TF),children:`Keep draft`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`main`),className:wF(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,TF),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:wF(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium`,TF),children:`Use edited source`})]})]})}function ZL({open:e,onClose:t,onLockedAction:n}){return e?(0,Z.jsx)(QL,{onClose:t,onLockedAction:n}):null}function QL({onClose:e,onLockedAction:t}){let n=VF(),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(qL(t))}).finally(()=>{e||y(null)}),()=>{e=!0}},[r,s,i]),i===void 0)return null;if(i.status===`locked`)return(0,Z.jsx)(Mj,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsxs)(Tj,{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)(Nj,{className:`fixed inset-0 z-[111] grid place-items-center p-4`,children:(0,Z.jsxs)(wj,{className:`border-border bg-popover w-full max-w-lg rounded-xl border p-5 shadow-[var(--shadow-floating)]`,children:[(0,Z.jsx)(Pj,{className:`text-base font-semibold`,children:`Publishing is unavailable`}),(0,Z.jsx)(vj,{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:wF(`bg-primary text-primary-foreground mt-4 inline-flex rounded-md px-3 py-2 text-sm font-medium`,TF),href:i.upsell.cta.href,onClick:e=>{t!==void 0&&(e.preventDefault(),t())},children:i.upsell.cta.label}),(0,Z.jsx)(_j,{className:wF(`border-border hover:bg-muted mt-4 ml-2 inline-flex rounded-md border px-3 py-2 text-sm font-medium`,TF),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(qL(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(qL(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(qL(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(qL(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=>{KL(n)?C({path:e,bytes:t}):T(qL(n))}).finally(()=>y(null)))},ie=e=>{let t=b.current;t!==null&&(x.current=e===null?null:{replacePath:e},t.accept=e===null?HL:GL(e),t.value=``,t.click())},ae=e=>{let t=x.current;if(x.current=null,e===void 0||u===null)return;if(e.size>UL){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??WL(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(qL(e)))};return(0,Z.jsx)(_M,{open:!0,onOpenChange:t=>!t&&e(),swipeDirection:`right`,children:(0,Z.jsxs)(mM,{container:n,children:[(0,Z.jsx)(Wj,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(rN,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(pM,{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)(BM,{className:`text-base font-semibold`,children:`Publish and saved versions`}),(0,Z.jsx)(qj,{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:wF(`hover:bg-muted rounded-md px-2 py-1 text-sm`,TF),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:wF(`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:wF(`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:HL,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:wF(`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:wF(`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:wF(`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)(XL,{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:wF(`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:JL(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:wF(`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 $L({container:e,children:t}){return(0,Z.jsx)(BF,{value:e,children:t})}var eR={desktop:600,mobile:375},tR=`▤`,nR=`Copy code`;function rR({open:e,onClose:t}){return e?(0,Z.jsx)(iR,{onClose:t}):null}function iR({onClose:e}){let t=VF(),{doc:n,render:r,checks:i,previewDevice:a}=$(mk(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)(Mj,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsx)(Tj,{container:t,children:(0,Z.jsxs)(wj,{className:`samva-editor-shell fixed inset-0 z-[100] flex flex-col bg-[var(--editor-canvas-bg)] outline-none`,children:[(0,Z.jsx)(Pj,{className:`sr-only`,children:`Template preview`}),(0,Z.jsx)(vj,{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)(qI,{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)(qI,{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)(qI,{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)(QI,{checks:i})]}),(0,Z.jsxs)(_j,{"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:wF(`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:wF(`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)(jI,{html:r.html,width:eR[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)($F,{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`?nR:e.type===`flow`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"aria-hidden":`true`,children:[tR,` `]}),e.text]}):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 aR({saveVersionStatus:e,saveVersionState:t,onSaveVersion:n,saveVersionBusy:r,saveVersionBlocked:i,guestHeadline:a}){let o=VF(),{doc:s,checks:c,sizeKb:l,deviceWidth:u,layoutMode:d}=$(mk(e=>({doc:e.doc,checks:e.checks,sizeKb:e.sizeKb,deviceWidth:OP[e.previewDevice],layoutMode:e.layoutMode}))),{selectDocument:f}=$(e=>e.actions),p=$(e=>e.sourceEditable),m=$(e=>e.pendingAuthoredSource),h=$(mk(e=>({storageError:e.storageError,conflict:e.conflict}))),[g,_]=(0,W.useState)(!1),{errorCount:v,warnCount:y}=wP(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)(kN,{open:g,onOpenChange:_,children:[(0,Z.jsxs)(MN,{"data-testid":`statusbar.checks-trigger`,"aria-label":d===`narrow`?S:void 0,onClick:()=>f(),className:wF(`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:wF(`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)(FN,{container:o,children:(0,Z.jsx)(RN,{side:`top`,align:`start`,sideOffset:8,collisionPadding:12,className:`z-[80] outline-none`,children:(0,Z.jsx)(VN,{"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)(ZI,{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:wF(`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 oR=`theme.css`,sR=`starter.css`,cR=`samva:brand`,lR=`@import "./${sR}";`,uR=`@import "${cR}";`,dR=/@import(?![\w-])/iy,fR=(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===`
|
|
34
34
|
`)return r+1;else r+=1}return e.length},pR=(e,t)=>{let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2},mR=e=>{let t=``,n=0;for(;n<e.length;)if(e.startsWith(`/*`,n))n=pR(e,n),t+=` `;else if(e[n]===`"`||e[n]===`'`){let r=fR(e,n);t+=e.slice(n,r),n=r}else t+=e[n],n+=1;return t},hR=e=>{let t=e[0];if(!(t!==`"`&&t!==`'`||e.length<2||e.at(-1)!==t))return e.slice(1,-1)},gR=e=>{let t=mR(e).trim(),n=/^url\(\s*(.*?)\s*\)$/is.exec(t);if(n!==null){let e=n[1]??``;return hR(e)??(/^[^\s"'()]+$/.test(e)?e:void 0)}return hR(t)},_R=e=>{let t=[],n=0,r=0;for(;r<e.length;){let i=e[r];if(i===`/`&&e[r+1]===`*`){r=pR(e,r);continue}if(i===`"`||i===`'`){r=fR(e,r);continue}if(i===`{`)n+=1;else if(i===`}`)n=Math.max(0,n-1);else if(i===`@`&&n===0&&(dR.lastIndex=r,dR.test(e))){let n=dR.lastIndex,i=n;for(;i<e.length&&e[i]!==`;`;)e.startsWith(`/*`,i)?i=pR(e,i):e[i]===`"`||e[i]===`'`?i=fR(e,i):i+=1;let a=Math.min(i+1,e.length);t.push({target:gR(e.slice(n,i)),end:a}),r=a;continue}r+=1}return t},vR=e=>{if(e===cR)return{slug:null};let t=`${cR}/`;if(e===void 0||!e.startsWith(t))return;let n=e.slice(t.length);return n.length===0?void 0:{slug:n}},yR=e=>{let t=e?.replace(/[?#].*$/,``);return t===`./starter.css`||t===`/starter.css`},bR=e=>{for(let{target:t}of _R(e)){let e=vR(t);if(e!==void 0)return e}return null},xR=e=>{let t=e.theme??``;if(bR(t)!==null)return t;let n=_R(t).find(({target:e})=>yR(e));if(n!==void 0)return`${t.slice(0,n.end)}\n${uR}${t.slice(n.end)}`;let r=[...e.starter?[lR]:[],uR].join(`
|