@valbuild/ui 0.97.1 → 0.97.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/valbuild-ui.cjs.js +1 -1
- package/dist/valbuild-ui.esm.js +1 -1
- package/package.json +1 -1
- package/server/.tmp/assets/{index-DuKOwBys.js → index-DP-ZM58p.js} +1 -1
- package/server/.tmp/index.html +1 -1
- package/server/dist/valbuild-ui-server.cjs.js +2 -2
- package/server/dist/valbuild-ui-server.esm.js +2 -2
|
@@ -52,7 +52,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
52
52
|
Error: `.concat(s instanceof Error?s.message:String(s)),`
|
|
53
53
|
All routes will be filtered out due to malformed include pattern.`)}if(n)try{i=new RegExp(n.source,n.flags)}catch(s){console.warn("[Val] Invalid exclude pattern: /".concat(n.source,"/").concat(n.flags),`
|
|
54
54
|
Error: `.concat(s instanceof Error?s.message:String(s)),`
|
|
55
|
-
All routes will be filtered out due to malformed exclude pattern.`)}return t.filter(function(s){return!(e&&(!r||!r.test(s))||n&&(!i||i.test(s)))})}function Hle(t,e,n){if(e)try{var r=new RegExp(e.source,e.flags);if(!r.test(t))return{valid:!1,message:"Route '".concat(t,"' does not match include pattern: /").concat(e.source,"/").concat(e.flags)}}catch(s){return{valid:!1,message:"Invalid include pattern: ".concat(s instanceof Error?s.message:String(s))}}if(n)try{var i=new RegExp(n.source,n.flags);if(i.test(t))return{valid:!1,message:"Route '".concat(t,"' matches exclude pattern: /").concat(n.source,"/").concat(n.flags)}}catch(s){return{valid:!1,message:"Invalid exclude pattern: ".concat(s instanceof Error?s.message:String(s))}}return{valid:!0}}var Su="This is most likely a Val version mismatch or Val bug.";function Kle(t,e){var n=new Map;for(var r in t){var i=r,s=t[i],o=e[i];if(s&&s.type==="record"&&s.router&&o&&fi(o)==="object"&&!Array.isArray(o))for(var a in o)n.has(a)||n.set(a,i)}var l=Array.from(n.entries()).map(function(c){var u=Qm(c,2),O=u[0],h=u[1];return{route:O,moduleFilePath:h}});return l.sort(function(c,u){return c.route.localeCompare(u.route)})}var Jle=function(e,n){var r=[e.length,n.length],i=r[0],s=r[1];if(!i||!s)return Math.max(i,s);for(var o=Array.from({length:i+1},function(O,h){return h}),a=1;a<=s;a++){var l=o[0];o[0]=a;for(var c=1;c<=i;c++){var u=o[c];o[c]=e[c-1]===n[a-1]?l:Math.min(l+1,o[c-1]+1,o[c]+1),l=u}}return o[i]};function H4(t,e){return e.map(function(n){return{target:n,distance:Jle(t,n)}}).sort(function(n,r){return n.distance-r.distance})}function ece(t,e){var n=pe.splitModuleFilePathAndModulePath(t),r=Qm(n,2),i=r[0],s=r[1],o=e.sources[i],a=e.schemas[i];if(!a||o===void 0)return{source:void 0,schema:void 0};if(!s)return{source:o,schema:a};var l=o,c=a,u=nS(pe.splitModulePath(s)),O;try{for(u.s();!(O=u.n()).done;){var h=O.value;l&&fi(l)==="object"&&!Array.isArray(l)&&h in l?l=l[h]:l=void 0,c&&c.type==="object"&&c.items[h]?c=c.items[h]:c&&c.type==="record"?c=c.item:c=void 0}}catch(m){u.e(m)}finally{u.f()}return{source:l,schema:c}}function tce(t,e,n){var r=ece(e,n),i=r.source,s=r.schema;if(s&&s.type!=="record")return{error:!0,message:"Expected key at ".concat(e," to be of type 'record'")};if(i&&fi(i)==="object"&&!Array.isArray(i)&&t in i)return{error:!1};if(!i||fi(i)!=="object"||Array.isArray(i))return{error:!0,message:"Expected ".concat(e," to be a truthy object")};var o=H4(t,Object.keys(i));return o.length===0?{error:!0,message:"Key '".concat(t,"' does not exist in ").concat(e,".")}:{error:!0,message:"Key '".concat(t,"' does not exist in ").concat(e,". Closest match: '").concat(o[0].target,"'. Other similar: ").concat(o.slice(1,4).map(function(a){return"'".concat(a.target,"'")}).join(", ")).concat(o.length>4?", ...":"")}}function nce(t,e,n,r){var i={};for(var s in r.schemas){var o=s,a=r.schemas[o];if(a?.type==="record"&&a.router){var l=r.sources[o];l&&fi(l)==="object"&&!Array.isArray(l)&&(i[o]=Object.keys(l))}}for(var c=Object.entries(i),u=null,O=0,h=c;O<h.length;O++){var m=Qm(h[O],2),g=m[0],y=m[1];if(y.includes(t)){u=g;break}}if(!u){var v=c.flatMap(function(P){var R=Qm(P,2),j=R[1];return j});if(v.length===0)return{error:!0,message:"Route '".concat(t,"' could not be validated: No router modules found in the project. Use s.record(...).router(...) to define router modules.")};v=Ble(v,e,n);var x=H4(t,v);return{error:!0,message:"Route '".concat(t,"' does not exist in any router module. ").concat(x.length>0?"Closest match: '".concat(x[0].target,"'. Other similar: ").concat(x.slice(1,4).map(function(P){return"'".concat(P.target,"'")}).join(", ")).concat(x.length>4?", ...":""):"No similar routes found.")}}var b=Hle(t,e,n);return b.valid?{error:!1}:{error:!0,message:b.message}}function rce(t,e){var n,r=(n=t.fixes)!==null&&n!==void 0?n:[];if(r.includes("keyof:check-keys")){if(!t.value)return{status:"remaining",error:ur(ur({},t),{},{message:"Could not find a value for keyOf. ".concat(Su),typeError:!0,fixes:void 0})};if(fi(t.value)!=="object")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected keyOf validation error to have a 'value' property of type 'object'. Found: ".concat(fi(t.value),". ").concat(Su),typeError:!0,fixes:void 0})};var i=t.value,s=i.key,o=i.sourcePath;if(typeof s!="string")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ".concat(fi(s),". ").concat(Su),typeError:!0,fixes:void 0})};if(typeof o!="string")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ".concat(fi(o),". ").concat(Su),typeError:!0,fixes:void 0})};var a=tce(s,o,e);return a.error?{status:"remaining",error:ur(ur({},t),{},{message:a.message,fixes:void 0})}:{status:"resolved"}}if(r.includes("router:check-route")){if(!t.value)return{status:"remaining",error:ur(ur({},t),{},{message:"Could not find a value for route. ".concat(Su),typeError:!0,fixes:void 0})};if(fi(t.value)!=="object")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected route validation error to have a 'value' property of type 'object'. Found: ".concat(fi(t.value),". ").concat(Su),typeError:!0,fixes:void 0})};var l=t.value,c=l.route;if(typeof c!="string")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected route validation error 'value' to have property 'route' of type 'string'. Found: ".concat(fi(c),". ").concat(Su),typeError:!0,fixes:void 0})};var u=Yz(l.include),O=Yz(l.exclude),h=nce(c,u,O,e);return h.error?{status:"remaining",error:ur(ur({},t),{},{message:h.message,fixes:void 0})}:{status:"resolved"}}return null}function Yz(t){if(t&&fi(t)==="object"&&"source"in t&&"flags"in t&&typeof t.source=="string"&&typeof t.flags=="string")return t}function K4(t,e){var n={};for(var r in t){var i=r,s=[],o=nS(t[i]),a;try{for(o.s();!(a=o.n()).done;){var l=a.value,c=rce(l,e);c===null?s.push(l):c.status==="remaining"&&s.push(c.error)}}catch(u){o.e(u)}finally{o.f()}s.length>0&&(n[i]=s)}return n}function Nu(t){return Array.isArray(t)}const J4=I().uuid().refine(t=>!0),ice=pg(["openai-gpt-5.1"]);D({id:I(),systemPrompt:I(),model:ice,tools:Ue(D({name:I(),description:I(),parameters:D({type:J("object"),properties:as(I(),oO()),required:Ue(I()).optional()})})).optional(),description:I().optional()});const sce=Ae([D({type:J("patches"),patches:Ue(J4)}),D({type:J("deployment"),deployment:F4}),D({type:J("commit"),commit:kR}),D({type:J("subscribed")})]);D({type:Ae([J("did-change"),J("no-change"),J("request-again"),J("use-websocket")]),profileId:I().nullable(),config:D({project:I().optional(),ai:D({chat:D({experimental:D({enable:Ve().optional()}).optional()}).optional()}).optional(),files:D({directory:I()}).optional()}),commitSha:I().optional(),sourcesSha:I(),schemaSha:I(),baseSha:I(),patches:Ue(J4),commits:Ue(kR).optional(),deployments:Ue(F4).optional(),mode:Ae([J("fs"),J("http")])});function oce(t){const[e,n]=$.useState({status:"not-asked"}),r=$.useRef(null),i=$.useRef(crypto.randomUUID()),{authenticationState:s,setAuthenticationLoadingIfNotAuthenticated:o,setIsAuthenticated:a}=ace(),[l,c]=$.useState(),u=$.useRef(0);return $.useEffect(()=>{if(e.status==="updated-request-again"||e.status==="error"||e.status==="ws-message-received")if(e.status==="error"&&console.error("Stat error",e.status,"error:",e.error),e.wait===0)console.debug("Executing stat immediately",e.status,e.status==="error"?e.error:"no error","Now:",Date.now()),TP(t,r,i,u,e,n,o,a,c);else{console.debug("Executing stat in ",e.wait," status: ",e.status,"Now:",Date.now());const O=setTimeout(()=>{TP(t,r,i,u,e,n,o,a,c)},e.wait);return()=>clearTimeout(O)}},[t,e]),$.useEffect(()=>{e.status==="not-asked"&&(n({status:"initializing"}),console.debug("Initializing stat"),TP(t,r,i,u,e,n,o,a,c))},[t,e.status]),[e,n,s,o,a,l]}const Gh=1200*1e3;async function TP(t,e,n,r,i,s,o,a,l){const c=++r.current;let u=null;return"data"in i&&i.data&&(u={schemaSha:i.data.schemaSha,sourcesSha:i.data.sourcesSha,baseSha:i.data.baseSha,patches:i.data.patches}),o(),t("/stat","POST",{body:u}).then(O=>{if(O.status===401){a("login-required");return}else a("authorized");if(O.status===503){l(!0),s(h=>({status:"error",error:"Service unavailable",retries:("retries"in h?h.retries:0)+1,waitStart:Date.now(),wait:5e3}));return}if(l(!1),!(r.current!==0&&r.current!==c))if(O.status===200){if(O.json.type==="did-change"||O.json.type==="no-change"||O.json.type==="request-again")s({status:"updated-request-again",data:O.json,waitStart:Date.now(),wait:e.current?Gh:0});else if(O.json.type==="use-websocket"){s(y=>({...y,status:"updated-request-again",data:O.json,waitStart:Date.now(),wait:Gh})),e.current&&(console.debug("Closing existing WebSocket"),e.current.close());const h=O.json.url;console.debug("Connecting to WebSocket",h),e.current=new WebSocket(h);const m=O.json.nonce;e.current.onopen=()=>{e.current?.send(JSON.stringify({nonce:m,type:"subscribe",connectionId:n.current}))},e.current.onmessage=y=>{try{const v=sce.safeParse(JSON.parse(y.data));if(!v.success){console.error("Could not parse WebSocket message",v.error);return}const x=v.data;x.type==="patches"?s(b=>"data"in b&&b.data?{status:"ws-message-received",data:{...b.data,patches:x.patches},waitStart:"waitStart"in b?b.waitStart:Date.now(),wait:"waitStart"in b?Math.max(0,Date.now()-b.waitStart):Gh}:b):x.type==="subscribed"?console.debug("Subscribed!"):x.type==="commit"?(console.debug("Commit",x.commit),s(b=>"data"in b&&b.data?{status:"ws-message-received",data:{...b.data,commits:(b.data.commits||[]).concat(x.commit)},waitStart:"waitStart"in b?b.waitStart:Date.now(),wait:"waitStart"in b?Math.max(0,Date.now()-b.waitStart):Gh}:b)):x.type==="deployment"?(console.debug("Deployment",x.deployment),s(b=>"data"in b&&b.data?{status:"ws-message-received",data:{...b.data,deployments:(b.data.deployments||[]).concat({commitSha:x.deployment.commitSha,deploymentId:x.deployment.deploymentId,deploymentState:x.deployment.deploymentState,createdAt:x.deployment.createdAt,updatedAt:x.deployment.updatedAt})},waitStart:"waitStart"in b?b.waitStart:Date.now(),wait:"waitStart"in b?Math.max(0,Date.now()-b.waitStart):Gh}:b)):console.warn("Unknown WebSocket message",x)}catch(v){console.error("Could not parse WebSocket message",v)}};const g=e.current;e.current.onclose=()=>{g===e.current&&(console.debug("WebSocket closed"),s(y=>Vy(y,"WebSocket closed")))},e.current.onerror=()=>{console.warn("WebSocket error"),s(y=>Vy(y,"Got an error while syncing with Val (reason: WebSocket error)"))}}}else s(h=>Vy(h,O.json.message))}).catch(O=>{r.current!==0&&r.current!==c||s(h=>Vy(h,O.message))})}function Vy(t,e){const n="retries"in t?t.retries+1:0,r=t.status==="error"&&t.retries>1?Math.min(500,t.retries*50+Math.floor(Math.random()*100))*10:0;return{status:"error",error:e,data:"data"in t?t.data:void 0,retries:n,waitStart:"waitStart"in t?t.waitStart:Date.now(),wait:r}}function ace(){const[t,e]=$.useState("not-asked"),n=$.useCallback(()=>{t==="not-asked"&&e("loading")},[t]);return{authenticationState:t,setIsAuthenticated:e,setAuthenticationLoadingIfNotAuthenticated:n}}function gp(t){if(t.type==="file")return!!t.remote;if(t.type==="image")return!!t.remote;if(t.type==="richtext")return!!(typeof t.options?.inline?.img!="boolean"&&t.options?.inline?.img?.remote);if(t.type==="array")return gp(t.item);if(t.type==="record")return t.mediaType&&t.remote?!0:gp(t.item);if(t.type==="union"){for(const e of t.items)if(gp(e))return!0;return!1}else if(t.type==="object"){for(const e in t.items)if(gp(t.items[e]))return!0;return!1}else{if(t.type==="boolean"||t.type==="number"||t.type==="string"||t.type==="date"||t.type==="dateTime"||t.type==="keyOf"||t.type==="route"||t.type==="literal")return!1;{const e=t;return console.error(`Val: requiresRemoteFiles: unexpected schema type ${typeof e=="object"&&"type"in e&&e.type}`,t),null}}}function zr(t){for(var e=t,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];for(var s=0,o=r;s<o.length;s++){var a=o[s];e=a(e)}return e}function eM(t){return hR(t)}function aO(t,e){if(t===e)return!0;if(Xe(t)==="object"&&Xe(e)==="object"&&t!==null&&e!==null){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;++n)if(!aO(t[n],e[n]))return!1;return!0}else if(!Array.isArray(t)&&!Array.isArray(e)){var r=Object.entries(t);if(r.length!==Object.keys(e).length)return!1;for(var i=0,s=r;i<s.length;i++){var o=xr(s[i],2),a=o[0],l=o[1],c=e[a];if(c===void 0||!aO(l,c))return!1}return!0}}return!1}function ji(t){return Array.isArray(t)?t.map(ji):Xe(t)==="object"&&t!==null?Object.fromEntries(Object.entries(t).map(function(e){var n=xr(e,2),r=n[0],i=n[1];return[r,ji(i)]})):t}function TR(t){return/^(0|[1-9][0-9]*)$/g.test(t)?ti(Number(t)):Qi(new Ms('Invalid array index "'.concat(t,'"')))}function lce(t,e){return t==="-"?ti(e.length):zr(TR(t),Fx(function(n){return n<=e.length},function(){return new Ms("Array index out of bounds")}))}function tM(t,e){return zr(TR(t),Fx(function(n){return n<e.length},function(){return new Ms("Array index out of bounds")}))}function cce(t,e,n){if(Array.isArray(t))return zr(tM(e,t),to(function(i){var s=t[i];return t[i]=n,s}));if(Xe(t)==="object"&&t!==null)if(Object.prototype.hasOwnProperty.call(t,e)){var r=t[e];return t[e]=n,ti(r)}else return Qi(new Ms("Cannot replace object element which does not exist"));return Qi(new Ms("Cannot replace in non-object/array"))}function uce(t,e,n){return eM(e)?zr(XR(t,e),iO(function(r){var i=xr(r,2),s=i[0],o=i[1];return cce(s,o,n)}),to(function(r){return[t,r]})):ti([n,t])}function nM(t,e){return Array.isArray(t)?zr(TR(e),iO(function(n){return n>=t.length?Qi(new Ms("Array index out of bounds")):ti(t[n])})):Xe(t)==="object"&&t!==null?Object.prototype.hasOwnProperty.call(t,e)?ti(t[e]):ti(void 0):Qi(new Ms("Cannot access non-object/array"))}function XR(t,e){for(var n=t,r=e[0],i=0;i<e.length-1;++i,r=e[i]){var s=nM(n,r);if(Lx(s))return s;if(s.value===void 0)return Qi(new Ms("Path refers to non-existing object/array"));n=s.value}return ti([n,r])}function XP(t,e){return zr(e,pR(function(n,r){return zr(nM(n,r),Fx(function(i){return i!==void 0},function(){return new Ms("Path refers to non-existing object/array")}))},t))}function Oce(t,e){if(Array.isArray(t))return zr(tM(e,t),to(function(r){var i=t.splice(r,1),s=xr(i,1),o=s[0];return o}));if(Xe(t)==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(t,e)){var n=t[e];return delete t[e],ti(n)}return Qi(new Ms("Cannot remove from non-object/array"))}function Vz(t,e){return zr(XR(t,e),iO(function(n){var r=xr(n,2),i=r[0],s=r[1];return Oce(i,s)}))}function dce(t,e,n){if(Array.isArray(t))return zr(lce(e,t),to(function(i){t.splice(i,0,n)}));if(Xe(t)==="object"&&t!==null){var r;return Object.prototype.hasOwnProperty.call(t,e)&&(r=t[e]),t[e]=n,ti(r)}return Qi(new Ms("Cannot add to non-object/array"))}function RP(t,e,n){return eM(e)?zr(XR(t,e),iO(function(r){var i=xr(r,2),s=i[0],o=i[1];return dce(s,o,n)}),to(function(r){return[t,r]})):ti([n,t])}function Zy(t){var e=xr(t,1),n=e[0];return n}var fce=(function(){function t(){wr(this,t)}return kr(t,[{key:"get",value:function(n,r){return XP(n,r)}},{key:"add",value:function(n,r,i){return zr(RP(n,r,i),to(Zy))}},{key:"remove",value:function(n,r){return zr(Vz(n,r),to(function(){return n}))}},{key:"replace",value:function(n,r,i){return zr(uce(n,r,i),to(Zy))}},{key:"move",value:function(n,r,i){return zr(Vz(n,r),iO(function(s){return RP(n,i,s)}),to(Zy))}},{key:"copy",value:function(n,r,i){return zr(XP(n,r),iO(function(s){return RP(n,i,ji(s))}),to(Zy))}},{key:"test",value:function(n,r,i){return zr(XP(n,r),to(function(s){return aO(i,s)}))}}])})();function hce(t,e,n){switch(n.op){case"add":return e.add(t,n.path,n.value);case"remove":return e.remove(t,n.path);case"replace":return e.replace(t,n.path,n.value);case"move":return e.move(t,n.from,n.path);case"copy":return e.copy(t,n.from,n.path);case"test":return e.test(t,n.path,n.value)?ti(t):Qi(new Ms("Test failed"));case"file":return Qi(new Ms("Cannot apply a file patch here"))}}function _P(t,e,n){return zr(n,pR(function(r,i){return hce(r,e,i)},t))}function pce(t,e){return!t||!e?!1:t.length===1&&t[0].op==="replace"&&e.length===1&&e[0].op==="replace"?t[0].path.join("/")===e[0].path.join("/"):!1}function gd(t,e){if(!e||e.length===0)return new Set([t.type]);const n=new Set;let r=t,i=-1;for(const s of e){if(i++,!r)break;if(r.type==="array")r=r.item;else if(r.type==="record")r=r.item;else if(r.type==="object")r=r.items[s];else{if(r.type==="richtext")break;if(r.type==="union")if(typeof r.key=="string"){const o=r.items;for(const a of o){const l=gd(a,e.slice(i));for(const c of Array.from(l.values()))n.add(c)}return n}else{if(i!==e.length-1)throw new Error("Found string union (primitive), but path has more parts: "+e.join("/")+" at "+s);break}else if(r.type==="boolean"||r.type==="number"||r.type==="string"||r.type==="date"||r.type==="dateTime"||r.type==="file"||r.type==="image"||r.type==="keyOf"||r.type==="route"||r.type==="literal"){if((r.type==="image"||r.type==="file")&&e[i]==="metadata")break;if(i!==e.length-1)throw new Error("Found "+r.type+" (primitive), but path has more parts: "+e.join("/")+" at "+s);break}else{const a=r.type;return console.error(`Unexecpted resolved schema type: ${a} in ${e.join("/")} at ${s}`),new Set([a])}}}return r&&(n.add(r.type),r.type==="union"&&(typeof r.key=="string"?n.add("object"):n.add("string"))),n}class Lh{constructor(){this.patchSetMetadata={},this.orderedInsertKeys=[],this.insertedPatches=new Set}reset(){this.patchSetMetadata={},this.orderedInsertKeys=[],this.insertedPatches=new Set}getInsertedPatches(){return this.insertedPatches}insertPath(e,n,r,i,s,o,a,l){let c=n.length>0?`${e}?${n.join("/")}`:e;const u=[];for(let O=this.orderedInsertKeys.length-1;O>=0;O--){const h=this.orderedInsertKeys[O];c!==h?c.startsWith(h)?(c=h,this.orderedInsertKeys.splice(O,1),this.orderedInsertKeys.unshift(c)):h.startsWith(c)&&u.push(O):(this.orderedInsertKeys.splice(O,1),this.orderedInsertKeys.unshift(c))}for(const O of u){const h=this.orderedInsertKeys[O];this.orderedInsertKeys.splice(O,1);const m=this.patchSetMetadata[h];if(this.patchSetMetadata[c]||(this.patchSetMetadata[c]={moduleFilePath:e,patchPath:n,patches:[],authors:[],opTypes:[],schemaTypes:Array.from(a),lastUpdated:i,lastUpdatedBy:s}),m)for(const g of m.patches.slice())this.patchSetMetadata[c].patches.unshift(g),g.author!==null&&this.patchSetMetadata[c].authors.unshift(g.author),this.patchSetMetadata[c].opTypes.unshift(g.opType);else throw new Error(`Could not find patch set metadata or patch metadata for (inserted) patch set path: ${h}`);h!==c&&delete this.patchSetMetadata[h]}this.patchSetMetadata[c]||(this.patchSetMetadata[c]={moduleFilePath:e,patchPath:n,patches:[],authors:[],opTypes:[],schemaTypes:a,lastUpdated:i,lastUpdatedBy:s}),s!==null&&!this.patchSetMetadata[c].authors.includes(s)&&this.patchSetMetadata[c].authors.unshift(s),this.patchSetMetadata[c].lastUpdatedBy=s,this.patchSetMetadata[c].lastUpdated=i,this.patchSetMetadata[c].opTypes.includes(o)||this.patchSetMetadata[c].opTypes.unshift(o),this.patchSetMetadata[c].patches.unshift({patchPath:l,patchId:r,author:s,createdAt:i,opType:o,schemaTypes:a}),this.orderedInsertKeys.includes(c)||this.orderedInsertKeys.unshift(c)}insert(e,n,r,i,s,o){if(!this.insertedPatches.has(i)){if(!n){this.insertPath(e,[],i,s,o,r.op,[],r.path);return}if(this.insertedPatches.add(i),!(r.op==="file"||r.op==="test"))try{if(r.op==="replace"){const a=gd(n,r.path);this.insertPath(e,r.path,i,s,o,r.op,Array.from(a),r.path)}else if(r.op==="add"||r.op==="remove"||r.op==="move"||r.op==="copy"){const a=r.path.slice(0,-1),l=gd(n,a);if(l.size===1&&l.has("array")){if(this.insertPath(e,a,i,s,o,r.op,Array.from(l),r.path),r.op==="move"){const c=r.from.slice(0,-1),u=gd(n,c);this.insertPath(e,c,i,s,o,r.op,Array.from(u),r.path)}}else if(l.size===1&&l.has("record")){const c=r.path,u=gd(n,c);if(this.insertPath(e,c,i,s,o,r.op,Array.from(u),r.path),r.op==="move"){const O=r.from,h=gd(n,O);this.insertPath(e,O,i,s,o,r.op,Array.from(h),r.path)}}else{if(l.size===1&&!(l.has("image")||l.has("file")))throw new Error(`Cannot perform op: '${r.op}' on non-array or non-record schema. Type: ${l.values().next().value}`);this.insertPath(e,a,i,s,o,r.op,[n.type],r.path)}}else{const a=r;throw new Error("Unreachable op: "+a)}}catch(a){a instanceof Error?console.error("Could not resolve path while creating patch set",a.message):console.error("Could not resolve path while creating patch set",a),this.insertPath(e,[],i,s,o,r.op,[n.type],r.path)}}}isInserted(e){return this.insertedPatches.has(e)}serialize(){return this.orderedInsertKeys.map(e=>{if(e in this.patchSetMetadata)return this.patchSetMetadata[e];throw new Error(`Could not find patch set metadata or patch metadata for (inserted) patch set path: ${e}`)})}}const mce="modulepreload",gce=function(t){return"/api/val/static/"+t},Zz={},$ce=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let l=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(O=>({status:"fulfilled",value:O}),O=>({status:"rejected",reason:O}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=o?.nonce||o?.getAttribute("nonce");i=l(n.map(c=>{if(c=gce(c),c in Zz)return;Zz[c]=!0;const u=c.endsWith(".css"),O=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${O}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":mce,u||(h.as="script"),h.crossOrigin="",h.href=c,a&&h.setAttribute("nonce",a),document.head.appendChild(h),u)return new Promise((m,g)=>{h.addEventListener("load",m),h.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})},Nz=typeof window<"u"&&typeof Worker<"u";class yce{constructor(e){this.onResult=e,this.worker=null,this.pending=Nz?[]:null,this.requestIdCounter=0,this.disposed=!1,this.latestRequestId=new Map,this.fallbackSchemaCache=new Map,Nz&&this.setupWorker()}async setupWorker(){try{const{createValidationWorker:e}=await $ce(async()=>{const{createValidationWorker:i}=await import("./createValidationWorker-Cu4Zom1o.js");return{createValidationWorker:i}},[]),n=e();if(this.disposed){n.terminate();return}n.onmessage=i=>{const s=i.data;this.latestRequestId.get(s.moduleFilePath)===s.id&&(s.type==="result"?this.onResult(s.moduleFilePath,s.errors):(console.error("Validation worker error:",s.moduleFilePath,s.error),this.onResult(s.moduleFilePath,!1)))},n.onerror=i=>{console.error("Validation worker crashed:",i.message)},this.worker=n;const r=this.pending;if(this.pending=null,r)for(const i of r)this.latestRequestId.get(i.moduleFilePath)===i.id&&n.postMessage(i)}catch(e){console.error("Failed to create validation worker:",e instanceof Error?e.message:String(e)),this.pending=null}}validate(e,n,r,i){const s=`val-${this.requestIdCounter++}`;this.latestRequestId.set(e,s);const o={type:"validate",id:s,moduleFilePath:e,schemaSha:i,serializedSchema:r,source:n};if(this.worker){this.worker.postMessage(o);return}if(this.pending){this.pending=this.pending.filter(a=>a.moduleFilePath!==e),this.pending.push(o);return}try{let a=this.fallbackSchemaCache.get(e);(!a||a.schemaSha!==i)&&(a={schemaSha:i,schema:Eo(r)},this.fallbackSchemaCache.set(e,a));const l=a.schema.executeValidate(e,n);this.onResult(e,l)}catch(a){console.error("Validation fallback failed:",e,a instanceof Error?a.message:String(a)),this.onResult(e,!1)}}dispose(){this.disposed=!0,this.worker&&(this.worker.terminate(),this.worker=null),this.pending=null,this.latestRequestId.clear(),this.fallbackSchemaCache.clear()}}function rM(t){const e={},n={};for(const r in t){const i=r;for(const s of t[i])Qce(s)?(n[i]??(n[i]=[])).push(s):(e[i]??(e[i]=[])).push(s)}return{surfaced:e,skipped:n}}function Qce(t){const e=t.fixes??[];return e.length===0?!1:e.every(vce)}function vce(t){switch(t){case"image:add-metadata":case"image:check-metadata":case"image:upload-remote":case"image:download-remote":case"image:check-remote":case"images:check-remote":case"file:add-metadata":case"file:check-metadata":case"file:upload-remote":case"file:download-remote":case"file:check-remote":case"files:check-remote":case"images:check-unique-folder":case"files:check-unique-folder":case"images:check-all-files":case"files:check-all-files":return!0;case"keyof:check-keys":case"router:check-route":return!1;default:return!1}}class xce{constructor(e,n=void 0){this.client=e,this.overlayEmitter=n,this.autoPublish=!1,this.setValModulesSeq=0,this.multipleSourcesSep="|",this.isSyncing=!1,this.MIN_WAIT_SECONDS=1,this.MAX_WAIT_SECONDS=5,this.initializedAt=null,this.forceSyncAllModules=!0,this.errors={},this.listeners={},this.syncStatus={},this.schemas=null,this.serverSideSchemaSha=null,this.clientSideSchemaSha=null,this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"absent"},this.schemaOutOfDate=!1,this.baseSha=null,this.sourcesSha=null,this.mode=null,this.serverSources=null,this.patchedSourcesCache=null,this.renders=null,this.globalServerSidePatchIds=[],this.syncedServerSidePatchIds=[],this.savedButNotYetGlobalServerSidePatchIds=[],this.patchIdsByCreatorId=new Map,this.patchIdsByModuleFilePath=new Map,this.pendingOps=[],this.pendingClientPatchIds=[],this.patchDataByPatchId={},this.isSyncing=!1,this.patchSets=new Lh,this.authorId=null,this.publishDisabled=!0,this.isPublishing=!1,this.commitSha=null,this.cachedSourceSnapshots=null,this.cachedServerSourceSnapshots=null,this.cachedBaseSourceSnapshots=null,this.cachedSchemaSnapshots=null,this.cachedRenderSnapshots=null,this.cachedPatchData=null,this.cachedSerializedPatchSetsSnapshot=null,this.cachedValidationErrors=null,this.cachedAllSchemasSnapshot=null,this.cachedDeserializedSchemas=null,this.cachedGlobalServerSidePatchIdsSnapshot=null,this.cachedPendingClientSidePatchIdsSnapshot=null,this.cachedSyncedServerSidePatchIdsSnapshot=null,this.cachedSavedServerSidePatchIdsSnapshot=null,this.cachedAllSourcesSnapshot=null,this.cachedAllRendersSnapshot=null,this.cachedSourcesSnapshot=null,this.cachedSyncStatus=null,this.cachedPendingOpsCountSnapshot=null,this.cachedInitializedAtSnapshot=null,this.cachedAutoPublishSnapshot=null,this.cachedPublishDisabledSnapshot=null,this.cachedSchemaOutOfDateSnapshot=null,this.cachedLocalModulesStatusSnapshot=null,this.cachedGlobalTransientErrorSnapshot=null,this.cachedParentRef=void 0,this.cachedPatchErrorsSnapshot=null,this.validationWorker=null}setAutoPublish(e,n){this.autoPublish=n;try{localStorage.setItem("val-auto-publish",n.toString())}catch{}return this.invalidateAutoPublish(),this.sync(e)}loadAutoPublish(){try{this.autoPublish=localStorage.getItem("val-auto-publish")==="true",this.invalidateAutoPublish()}catch{}}async init(e,n,r,i,s,o,a,l){this.mode=e,this.baseSha=n,this.commitSha=a,this.authorId=o;const c=Date.now();e==="fs"?this.loadAutoPublish():this.autoPublish=!1;const u=await this.syncWithUpdatedStat(e,n,r,i,s,o,a,l);return u.status==="done"&&(await this.syncPatches(!0,l),this.publishDisabled=!1,this.invalidatePublishDisabled(),this.initializedAt=l+(Date.now()-c),this.invalidateInitializedAt()),u}reset(){console.debug("Resetting ValSyncEngine"),this.initializedAt=null,this.forceSyncAllModules=!0,this.errors={},this.listeners={},this.syncStatus={},this.schemas=null,this.serverSideSchemaSha=null,this.clientSideSchemaSha=null,this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"absent"},this.schemaOutOfDate=!1,this.sourcesSha=null,this.serverSources=null,this.patchedSourcesCache=null,this.renders=null,this.globalServerSidePatchIds=[],this.syncedServerSidePatchIds=[],this.savedButNotYetGlobalServerSidePatchIds=[],this.patchIdsByCreatorId=new Map,this.patchIdsByModuleFilePath=new Map,this.pendingOps=[],this.pendingClientPatchIds=[],this.patchDataByPatchId={},this.isSyncing=!1,this.patchSets=new Lh,this.authorId=null,this.publishDisabled=!0,this.isPublishing=!1,this.commitSha=null,this.cachedSourceSnapshots=null,this.cachedServerSourceSnapshots=null,this.cachedBaseSourceSnapshots=null,this.cachedSchemaSnapshots=null,this.cachedRenderSnapshots=null,this.cachedPatchData=null,this.cachedSerializedPatchSetsSnapshot=null,this.cachedValidationErrors=null,this.cachedAllSchemasSnapshot=null,this.cachedDeserializedSchemas=null,this.cachedGlobalServerSidePatchIdsSnapshot=null,this.cachedPendingClientSidePatchIdsSnapshot=null,this.cachedSyncedServerSidePatchIdsSnapshot=null,this.cachedSavedServerSidePatchIdsSnapshot=null,this.cachedAllSourcesSnapshot=null,this.cachedAllRendersSnapshot=null,this.cachedSyncStatus=null,this.cachedPendingOpsCountSnapshot=null,this.cachedInitializedAtSnapshot=null,this.cachedAutoPublishSnapshot=null,this.cachedPublishDisabledSnapshot=null,this.cachedSchemaOutOfDateSnapshot=null,this.cachedLocalModulesStatusSnapshot=null,this.cachedGlobalTransientErrorSnapshot=null,this.cachedParentRef=void 0,this.cachedPatchErrorsSnapshot=null,this.validationWorker?.dispose(),this.validationWorker=null,this.invalidateInitializedAt()}subscribe(e,n){const r=n||xn;return i=>{const s=this.listeners;if(s[e]||(s[e]={}),Array.isArray(r)){const o=[];for(const a of r){s[e][a]||(s[e][a]=[]);const l=s[e][a].push(i)-1;o.push(l)}return()=>{for(const a of o)s[e]?.[r[a]]?.splice(a,1)}}else{s[e][r]||(s[e][r]=[]);const o=s[e][r].push(i)-1;return()=>{s[e]?.[r].splice(o,1)}}}}emit(e){if(e)for(const n of e)n()}setCommitSha(e){this.commitSha=e}invalidateInitializedAt(){this.cachedInitializedAtSnapshot=null,this.emit(this.listeners["initialized-at"]?.[xn])}invalidateSource(e){if(this.cachedSourceSnapshots!==null){const n=[];for(const r in this.cachedSourceSnapshots)(r===e||r.startsWith(e+"\0"))&&n.push(r);if(n.length>0){const r={...this.cachedSourceSnapshots};for(const i of n)delete r[i];this.cachedSourceSnapshots=r}}this.cachedServerSourceSnapshots!==null&&(this.cachedServerSourceSnapshots={...this.cachedServerSourceSnapshots,[e]:void 0}),this.cachedBaseSourceSnapshots!==null&&(this.cachedBaseSourceSnapshots={...this.cachedBaseSourceSnapshots,[e]:void 0}),this.invalidatePatchedSourcesCache(e),this.cachedAllSourcesSnapshot=null,this.cachedSourcesSnapshot=null,this.cachedValidationErrors=null,this.emit(this.listeners.sources?.[e]),this.emit(this.listeners.source?.[e]),this.emit(this.listeners["all-sources"]?.[xn]),this.emit(this.listeners["all-validation-errors"]?.[xn])}invalidatePatchErrors(e){this.cachedPatchErrorsSnapshot=null,this.emit(this.listeners["patch-errors"]?.[e])}invalidateRenders(e){this.cachedSourceSnapshots===null&&(this.cachedSourceSnapshots={}),this.cachedRenderSnapshots={...this.cachedRenderSnapshots,[e]:null},this.cachedAllRendersSnapshot=null,this.emit(this.listeners.render?.[e]),this.emit(this.listeners["all-renders"]?.[xn])}invalidateSyncStatus(e){this.cachedSyncStatus={...this.cachedSyncStatus,[e]:void 0},this.emit(this.listeners["sync-status"]?.[e])}invalidateValidationError(e){this.emit(this.listeners["validation-error"]?.[e])}invalidateAllValidationErrors(){this.cachedValidationErrors=null,this.emit(this.listeners["all-validation-errors"]?.[xn])}invalidateGlobalTransientErrors(){this.cachedGlobalTransientErrorSnapshot=null,this.emit(this.listeners["global-transient-errors"]?.[xn])}invalidateNetworkError(){this.cachedNetworkErrorSnapshot=void 0,this.emit(this.listeners["network-error"]?.[xn])}invalidateSchemaError(){this.cachedSchemaErrorSnapshot=void 0,this.emit(this.listeners["schema-error"]?.[xn])}invalidatePatchSets(){this.cachedSerializedPatchSetsSnapshot=null,this.emit(this.listeners["patch-sets"]?.[xn])}invalidatePendingOps(){this.cachedPendingOpsCountSnapshot=null,this.emit(this.listeners["pending-ops-count"]?.[xn])}invalidateAllPatches(){this.cachedPatchData=null,this.emit(this.listeners["all-patches"]?.[xn])}invalidateSchema(){this.cachedAllSchemasSnapshot=null,this.cachedDeserializedSchemas=null,this.cachedSchemaSnapshots=null,this.cachedAllSourcesSnapshot=null,this.emit(this.listeners.schema?.[xn]),this.invalidateAllValidationErrors();for(const e in this.listeners?.["validation-error"]||{}){const n=e;this.invalidateValidationError(n)}}invalidateParentRef(){this.cachedParentRef=void 0,this.emit(this.listeners["parent-ref"]?.[xn])}invalidateGlobalServerSidePatchIds(){this.cachedGlobalServerSidePatchIdsSnapshot=null,this.invalidateParentRef(),this.emit(this.listeners["global-server-side-patch-ids"]?.[xn])}invalidatePendingClientSidePatchIds(){this.cachedPendingClientSidePatchIdsSnapshot=null,this.emit(this.listeners["pending-client-side-patch-ids"]?.[xn])}invalidateSyncedServerSidePatchIds(){this.cachedSyncedServerSidePatchIdsSnapshot=null,this.emit(this.listeners["synced-server-side-patch-ids"]?.[xn])}invalidateSavedServerSidePatchIds(){this.cachedSavedServerSidePatchIdsSnapshot=null,this.invalidateParentRef(),this.emit(this.listeners["saved-server-side-patch-ids"]?.[xn])}invalidatePublishDisabled(){this.cachedPublishDisabledSnapshot=null,this.emit(this.listeners["publish-disabled"]?.[xn])}invalidateSchemaOutOfDate(){this.cachedSchemaOutOfDateSnapshot=null,this.emit(this.listeners["schema-out-of-date"]?.[xn])}invalidateLocalModulesStatus(){this.cachedLocalModulesStatusSnapshot=null,this.emit(this.listeners["local-modules-status"]?.[xn])}invalidateAutoPublish(){this.cachedAutoPublishSnapshot=null,this.emit(this.listeners["auto-publish"]?.[xn])}getSchemaSnapshot(e){if(this.cachedSchemaSnapshots===null&&(this.cachedSchemaSnapshots={}),this.cachedSchemaSnapshots[e]===void 0)if(!this.schemas)this.cachedSchemaSnapshots[e]={status:"no-schemas"};else{const n=this.schemas[e];n?this.cachedSchemaSnapshots[e]={status:"success",data:ji(n)}:this.cachedSchemaSnapshots[e]={status:"module-schema-not-found"}}return this.cachedSchemaSnapshots[e]}getRenderSnapshot(e){return this.cachedRenderSnapshots===null&&(this.cachedRenderSnapshots={}),this.cachedRenderSnapshots[e]===null&&(this.cachedRenderSnapshots[e]=this.renders?.[e]||null),this.cachedRenderSnapshots[e]}orderedPatchIdsForModule(e){const n=[],r=this.patchIdsByModuleFilePath.get(e);if(!r||r.size===0)return n;const i=s=>{r.has(s)&&this.patchDataByPatchId[s]&&n.push(s)};if(this.globalServerSidePatchIds)for(const s of this.globalServerSidePatchIds)i(s);for(const s of this.savedButNotYetGlobalServerSidePatchIds)i(s);for(const s of this.pendingClientPatchIds)i(s);return n}getPatchedSource(e){const n=this.serverSources?.[e];if(n===void 0)return;const r=this.orderedPatchIdsForModule(e);if(r.length===0)return n;this.patchedSourcesCache===null&&(this.patchedSourcesCache={});const i=this.patchedSourcesCache[e];let s,o;if(i&&this.isPrefix(i.patchIds,r)){if(i.source===void 0)return;if(s=i.source,o=i.patchIds.length,o===r.length)return s}else s=n,o=0;let a=o,l=s,c=!0;for(let u=o;u<r.length;u++){const O=r[u],h=this.patchDataByPatchId[O];if(!h){c=!1;continue}const m=h.patch.filter(y=>y.op!=="file");if(m.length===0){c&&(a=u+1,l=s);continue}const g=_P(ji(s),CP,m);SP.isOk(g)?(s=g.value,c&&(a=u+1,l=s)):(c=!1,console.debug("ValSyncEngine: skipping unappliable client-side patch",{patchId:O,moduleFilePath:e,message:g.error.message}))}return this.patchedSourcesCache[e]={patchIds:r.slice(0,a),source:l},s}isPrefix(e,n){if(e.length>n.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}invalidatePatchedSourcesCache(e){this.patchedSourcesCache!==null&&(e===void 0?this.patchedSourcesCache=null:this.patchedSourcesCache={...this.patchedSourcesCache,[e]:void 0})}getSourceSnapshot(e,n){this.cachedSourceSnapshots===null&&(this.cachedSourceSnapshots={});const r=n?`${e}\0${n}`:e;if(this.cachedSourceSnapshots[r]===void 0){const i=this.getPatchedSource(e);this.schemas===null?this.cachedSourceSnapshots[r]={status:"no-schemas"}:this.schemas[e]?i===void 0?this.cachedSourceSnapshots[r]={status:"source-not-found"}:this.cachedSourceSnapshots[r]={status:"success",data:ji(i),optimistic:this.isEditedByComponent(e,n)}:this.cachedSourceSnapshots[r]={status:"schema-not-found"}}return this.cachedSourceSnapshots[r]}getServerSourceSnapshot(e){if(this.cachedServerSourceSnapshots===null&&(this.cachedServerSourceSnapshots={}),this.cachedServerSourceSnapshots[e]===void 0)if(this.schemas===null)this.cachedServerSourceSnapshots[e]={status:"no-schemas"};else if(!this.schemas[e])this.cachedServerSourceSnapshots[e]={status:"schema-not-found"};else{const n=this.serverSources?.[e];n===void 0?this.cachedServerSourceSnapshots[e]={status:"source-not-found"}:this.cachedServerSourceSnapshots[e]={status:"success",data:ji(n)}}return this.cachedServerSourceSnapshots[e]}getBaseSourceSnapshot(e){if(this.cachedBaseSourceSnapshots===null&&(this.cachedBaseSourceSnapshots={}),this.cachedBaseSourceSnapshots[e]===void 0)if(this.schemas===null)this.cachedBaseSourceSnapshots[e]={status:"no-schemas"};else if(!this.schemas[e])this.cachedBaseSourceSnapshots[e]={status:"schema-not-found"};else{const n=this.serverSources?.[e];n===void 0?this.cachedBaseSourceSnapshots[e]={status:"source-not-found"}:this.cachedBaseSourceSnapshots[e]={status:"success",data:ji(n)}}return this.cachedBaseSourceSnapshots[e]}getAllSourcesSnapshot(){if(this.cachedAllSourcesSnapshot===null){this.cachedAllSourcesSnapshot={};for(const e in this.schemas||{}){const n=e,r=this.getPatchedSource(n);r!==void 0&&(this.cachedAllSourcesSnapshot[n]=ji(r))}}return this.cachedAllSourcesSnapshot}getAllRendersSnapshot(){if(this.cachedAllRendersSnapshot===null&&(this.cachedAllRendersSnapshot={},this.renders))for(const e in this.renders){const n=e;this.cachedAllRendersSnapshot[n]=this.renders[n]}return this.cachedAllRendersSnapshot}getSourcesSnapshot(e){const n=e.sort().map(r=>r+this.multipleSourcesSep).join(this.multipleSourcesSep);if(this.cachedSourcesSnapshot===null&&(this.cachedSourcesSnapshot={}),this.cachedSourcesSnapshot[n]===void 0)for(const r of e){const i=this.getPatchedSource(r);i!==void 0&&(this.cachedSourcesSnapshot[n]=[...this.cachedSourcesSnapshot[n]||[],ji(i)])}return this.cachedSourcesSnapshot[n]}getAllSchemasSnapshot(){this.cachedAllSchemasSnapshot===null&&(this.cachedAllSchemasSnapshot={});for(const e in this.schemas||{}){const n=e,r=this.schemas?.[n];r&&(this.cachedAllSchemasSnapshot[n]=ji(r))}return this.cachedAllSchemasSnapshot}getValidationErrorSnapshot(e){return this.getAllValidationErrorsSnapshot()?.[e]}getAllValidationErrorsSnapshot(){if(!this.cachedValidationErrors){const e={},n=this.errors.validationErrors||{};for(const s in n){const o=s,a=[];for(const l of n[o]||[])l&&a.push(l);a.length>0&&(e[o]=a)}const r=K4(e,{schemas:this.getAllSchemasSnapshot(),sources:this.getAllSourcesSnapshot()}),{surfaced:i}=rM(r);this.cachedValidationErrors=i}return this.cachedValidationErrors}getSyncStatusSnapshot(e){return this.cachedSyncStatus===null&&(this.cachedSyncStatus={}),this.cachedSyncStatus[e]===void 0&&(this.cachedSyncStatus[e]=this.syncStatus[e]||null),this.cachedSyncStatus[e]}getPendingOpsSnapshot(){return this.cachedPendingOpsCountSnapshot===null&&(this.cachedPendingOpsCountSnapshot=this.pendingOps.length),this.cachedPendingOpsCountSnapshot}getSerializedPatchSetsSnapshot(){return this.cachedSerializedPatchSetsSnapshot||(this.cachedSerializedPatchSetsSnapshot=this.patchSets.serialize()),this.cachedSerializedPatchSetsSnapshot}getInitializedAtSnapshot(){return this.cachedInitializedAtSnapshot===null&&(this.cachedInitializedAtSnapshot={data:this.initializedAt}),this.cachedInitializedAtSnapshot}getPatchErrorsSnapshot(e){const n=e.sort().join("|");if(this.cachedPatchErrorsSnapshot===null){this.cachedPatchErrorsSnapshot={};const r={};let i=!1;for(const s of e)this.errors.patchErrors?.[s]&&(r[s]={...r[s]||{},...ji(this.errors.patchErrors[s])},i=!0);i&&(this.cachedPatchErrorsSnapshot[n]=r)}return this.cachedPatchErrorsSnapshot[n]}getAllPatchesSnapshot(){if(!this.cachedPatchData){this.cachedPatchData={};for(const e in this.patchDataByPatchId){const n=e,r=this.patchDataByPatchId[n];r&&(this.cachedPatchData[n]=ji(r))}}return this.cachedPatchData}getGlobalServerSidePatchIdsSnapshot(){return this.cachedGlobalServerSidePatchIdsSnapshot===null&&(this.cachedGlobalServerSidePatchIdsSnapshot=this.globalServerSidePatchIds?.slice()||[]),this.cachedGlobalServerSidePatchIdsSnapshot}getPendingClientSidePatchIdsSnapshot(){return this.cachedPendingClientSidePatchIdsSnapshot===null&&(this.cachedPendingClientSidePatchIdsSnapshot=this.pendingClientPatchIds?.slice()||[]),this.cachedPendingClientSidePatchIdsSnapshot}getSyncedServerSidePatchIdsSnapshot(){return this.cachedSyncedServerSidePatchIdsSnapshot===null&&(this.cachedSyncedServerSidePatchIdsSnapshot=this.syncedServerSidePatchIds?.slice()||[]),this.cachedSyncedServerSidePatchIdsSnapshot}getSavedServerSidePatchIdsSnapshot(){return this.cachedSavedServerSidePatchIdsSnapshot===null&&(this.cachedSavedServerSidePatchIdsSnapshot=this.savedButNotYetGlobalServerSidePatchIds?.slice()||[]),this.cachedSavedServerSidePatchIdsSnapshot}getPublishDisabledSnapshot(){return this.cachedPublishDisabledSnapshot===null&&(this.cachedPublishDisabledSnapshot=this.publishDisabled),this.cachedPublishDisabledSnapshot}getSchemaOutOfDateSnapshot(){return this.cachedSchemaOutOfDateSnapshot===null&&(this.cachedSchemaOutOfDateSnapshot=this.schemaOutOfDate),this.cachedSchemaOutOfDateSnapshot}getLocalModulesStatusSnapshot(){return this.cachedLocalModulesStatusSnapshot===null&&(this.cachedLocalModulesStatusSnapshot=this.localModulesStatus),this.cachedLocalModulesStatusSnapshot}getAutoPublishSnapshot(){return this.cachedAutoPublishSnapshot===null&&(this.cachedAutoPublishSnapshot=this.autoPublish),this.cachedAutoPublishSnapshot}getGlobalTransientErrorsSnapshot(){return this.cachedGlobalTransientErrorSnapshot===null&&(this.cachedGlobalTransientErrorSnapshot=this.errors.globalTransientErrorQueue?.slice()||[]),this.cachedGlobalTransientErrorSnapshot}getNetworkErrorSnapshot(){return this.cachedNetworkErrorSnapshot===void 0&&(this.cachedNetworkErrorSnapshot=this.errors.hasNetworkErrorTimestamp||null),this.cachedNetworkErrorSnapshot}getSchemaErrorSnapshot(){return this.cachedSchemaErrorSnapshot===void 0&&(this.cachedSchemaErrorSnapshot=this.errors.hasSchemaErrorTimestamp||null),this.cachedSchemaErrorSnapshot}getParentRefSnapshot(){return this.cachedParentRef===void 0&&(this.cachedParentRef=this.getParentRef()),this.cachedParentRef}addPatchOnClientOnly(e,n,r){const[i]=pe.splitModuleFilePathAndModulePath(e);if(this.serverSources===null||this.serverSources?.[i]===void 0)return this.addGlobalTransientError(`Content at '${i}' is not yet initialized`,r),{status:"patch-error",message:`Content at '${i}' is not yet initialized`,moduleFilePath:i};const s=this.getPatchedSource(i);if(s===void 0)return{status:"patch-error",message:`Content at '${i}' is not yet initialized`,moduleFilePath:i};const o=n.filter(l=>l.op!=="file");if(o.length===0)return{status:"patch-applies",moduleFilePath:i,patch:n};const a=_P(ji(s),CP,o);return SP.isErr(a)?(console.error("Could not apply patch:",a.error),this.addGlobalTransientError(`Could not apply patch: ${a.error.message}`,r),{status:"patch-error",message:a.error.message,moduleFilePath:i}):{status:"patch-applies",moduleFilePath:i,patch:n}}ensureValidationWorker(){return this.validationWorker||(this.validationWorker=new yce((e,n)=>{this.applyValidationResult(e,n)})),this.validationWorker}requestModuleValidation(e){const n=this.clientSideSchemaSha;if(!n)return;const r=this.schemas?.[e];if(!r)return;const i=this.getPatchedSource(e);i!==void 0&&this.ensureValidationWorker().validate(e,i,r,n)}requestAllModuleValidation(){const e=this.schemas;if(e)for(const n of Object.keys(e))this.requestModuleValidation(n)}applyValidationResult(e,n){this.errors.validationErrors||(this.errors.validationErrors={});const r=new Set;for(const i in this.errors.validationErrors){const s=i;(s===e||s.startsWith(e+".")||s.startsWith(e+"?"))&&this.errors.validationErrors[s]!==void 0&&(this.errors.validationErrors[s]=void 0,r.add(s))}if(n!==!1)for(const i in n){const s=i;this.errors.validationErrors[s]=n[s],r.add(s)}if(r.size>0){this.invalidateAllValidationErrors();for(const i of r)this.invalidateValidationError(i)}}validatePatchResult(e,n){const r=this.getPatchedSource(e);if(r===void 0)return{status:"no-source",message:`Content at '${e}' is not yet initialized`};const i=this.schemas?.[e];if(!i)return{status:"no-schema",message:`Schema not found for '${e}'`};const s=n.filter(l=>l.op!=="file"),o=_P(ji(r),CP,s);return SP.isErr(o)?{status:"patch-error",message:o.error.message}:(this.cachedDeserializedSchemas||(this.cachedDeserializedSchemas={}),this.cachedDeserializedSchemas[e]||(this.cachedDeserializedSchemas[e]=Eo(i)),this.cachedDeserializedSchemas[e].executeValidate(e,o.value))}async addPatchAwaitable(e,n,r,i,s,o,a,l){const c=this.addPatchOnClientOnly(e,r,o);if(c.status!=="patch-applies")return c;const{moduleFilePath:u,patch:O}=c;this.patchDataByPatchId[i]={moduleFilePath:u,patch:O,isPending:!0,createdAt:new Date(o).toISOString(),authorId:this.authorId},this.pendingClientPatchIds.push(i),this.addToPatchIdsByModule(u,i),a&&this.addToCreatorId(a,i),this.invalidateAllPatches(),this.invalidatePendingClientSidePatchIds(),this.invalidateSource(u),this.requestModuleValidation(u);const h={type:"add-patches",data:{[u]:[{patch:O,patchId:i,type:n}]},createdAt:o};let m=0;this.syncStatus[e]="patches-pending",this.invalidateSyncStatus(e);let g=await this.executeAddPatches(h,{},o,l);for(;g.status==="retry"&&m<3&&(m++,await new Promise(y=>setTimeout(y,500*(m+1))),g=await this.executeAddPatches(h,{},o,l),g.status==="retry"););return this.syncStatus[e]="done",this.invalidateSyncStatus(e),g.status==="done"?{status:"patch-synced",patchId:i,parentRef:g.parentRef,moduleFilePath:u}:(this.invalidateSource(u),this.requestModuleValidation(u),{status:"patch-sync-error",message:"Could not sync patch. Tried 3 times.",moduleFilePath:u})}addPatch(e,n,r,i,s){const o=this.addPatchOnClientOnly(e,r,i);if(o.status!=="patch-applies")return o;const a=o.moduleFilePath;this.syncStatus[e]="patches-pending",this.invalidateSyncStatus(e);const l=this.pendingOps[this.pendingOps.length-1];if(l?.type==="add-patches"){const c=(l.data?.[a]?.length||0)-1,u=l.data?.[a]?.[c]?.patch,O=l.data?.[a]?.[c]?.patchId;if(pce(u,r)&&l.data?.[a]?.[c]?.type===n&&O&&this.patchDataByPatchId[O])return l.data[a][c].patch=r,l.updatedAt=i,this.invalidatePendingOps(),this.patchDataByPatchId[O].patch=r,this.invalidateAllPatches(),this.patchSetInsert(a,O,r,i),this.invalidateSyncStatus(e),this.invalidateSource(a),this.requestModuleValidation(a),{status:"patch-merged",patchId:O,moduleFilePath:a};{l.data[a]||(l.data[a]=[]);const h=this.createPatchId();return l.data[a].push({patch:r,type:n,patchId:h}),this.invalidatePendingOps(),this.pendingClientPatchIds.push(h),this.invalidatePendingClientSidePatchIds(),this.patchDataByPatchId[h]={moduleFilePath:a,patch:r,isPending:!0,createdAt:new Date(i).toISOString(),authorId:this.authorId},this.invalidateAllPatches(),this.addToPatchIdsByModule(a,h),this.patchSetInsert(a,h,r,i),s&&this.addToCreatorId(s,h),this.invalidateSyncStatus(e),this.invalidateSource(a),this.requestModuleValidation(a),{status:"patch-added",patchId:h,moduleFilePath:a}}}else{const c=this.createPatchId();return this.pendingOps.push({type:"add-patches",data:{[a]:[{patch:r,type:n,patchId:c}]},createdAt:i}),this.invalidatePendingOps(),this.pendingClientPatchIds.push(c),this.invalidatePendingClientSidePatchIds(),this.patchDataByPatchId[c]={moduleFilePath:a,patch:r,isPending:!0,createdAt:new Date(i).toISOString(),authorId:this.authorId},this.invalidateAllPatches(),this.addToPatchIdsByModule(a,c),this.patchSetInsert(a,c,r,i),s&&this.addToCreatorId(s,c),this.invalidateSyncStatus(e),this.invalidateSource(a),this.requestModuleValidation(a),{status:"patch-added",patchId:c,moduleFilePath:a}}}createPatchId(){return crypto.randomUUID()}addToCreatorId(e,n){let r=this.patchIdsByCreatorId.get(e);r||(r=[],this.patchIdsByCreatorId.set(e,r)),r.push(n)}addToPatchIdsByModule(e,n){let r=this.patchIdsByModuleFilePath.get(e);r||(r=new Set,this.patchIdsByModuleFilePath.set(e,r)),r.add(n)}removeFromPatchIdsByModule(e){const n=this.patchDataByPatchId[e];if(n){const r=this.patchIdsByModuleFilePath.get(n.moduleFilePath);r&&r.delete(e)}}rebuildPatchIdsByModule(){this.patchIdsByModuleFilePath=new Map;for(const e in this.patchDataByPatchId){const n=e,r=this.patchDataByPatchId[n];r&&this.addToPatchIdsByModule(r.moduleFilePath,n)}}isEditedByComponent(e,n){if(!n)return!1;this.patchIdsByModuleFilePath.get(e);const r=this.patchIdsByCreatorId.get(n);if(!r)return!1;const i=this.globalServerSidePatchIds&&r[r.length-1]===this.globalServerSidePatchIds[this.globalServerSidePatchIds.length-1],s=this.savedButNotYetGlobalServerSidePatchIds&&r[r.length-1]===this.savedButNotYetGlobalServerSidePatchIds[this.savedButNotYetGlobalServerSidePatchIds.length-1],o=this.pendingClientPatchIds&&r[r.length-1]===this.pendingClientPatchIds[this.pendingClientPatchIds.length-1];return!!(i||o||s)}patchSetInsert(e,n,r,i){const s=new Date(i).toISOString();for(const o of r)this.patchSets.insert(e,this.schemas?.[e]??void 0,o,n,s,this.authorId);this.invalidatePatchSets()}deletePatches(e,n){const r=this.pendingOps[this.pendingOps.length-1];if(r?.type==="delete-patches"){r.patchIds.push(...e),r.updatedAt=n;return}this.pendingOps.push({type:"delete-patches",patchIds:e,createdAt:n}),this.invalidatePendingOps()}markAllSyncStatusIn(e,n){for(const r in this.syncStatus)r.startsWith(e)&&(this.syncStatus[r]=n)}getParentRef(){if(this.baseSha===null||this.globalServerSidePatchIds===null)return null;const e=this.savedButNotYetGlobalServerSidePatchIds[this.savedButNotYetGlobalServerSidePatchIds.length-1]||this.globalServerSidePatchIds[this.globalServerSidePatchIds.length-1];return e?{type:"patch",patchId:e}:{type:"head",headBaseSha:this.baseSha}}async syncWithUpdatedStat(e,n,r,i,s,o,a,l){const c=this.localModulesStatus.type==="loaded",u=this.sourcesSha!==i;if(this.sourcesSha=i,this.baseSha=n,this.mode=e,this.serverSideSchemaSha!==r||this.commitSha!==a)if(c)this.serverSideSchemaSha=r,this.commitSha=a,this.recomputeSchemaOutOfDate();else return this.reset(),this.serverSideSchemaSha=r,this.commitSha=a,this.init(e,n,r,i,s,o,a,l);const O=this.globalServerSidePatchIds===null||!aO(this.globalServerSidePatchIds,s);if(O){this.globalServerSidePatchIds=s;const h=new Set(s);this.deletePendingPatchId(h),this.deleteSavedButNotYetGlobalServerSidePatchIds(h),await this.syncPatches(!1,l),this.invalidateGlobalServerSidePatchIds(),this.invalidateSyncedServerSidePatchIds(),this.invalidateSavedServerSidePatchIds(),this.invalidatePendingClientSidePatchIds()}return!this.forceSyncAllModules&&(u||O)&&(this.forceSyncAllModules=!0),this.sync(l)}async executeAddPatches(e,n,r,i){if(this.schemaOutOfDate)return this.addGlobalTransientError("Cannot save: a new version has been deployed. Reload to continue editing.",r),{status:"retry",reason:"schema-out-of-date"};const s=[],o=[];let a=!1;for(const[u,O]of Object.entries(e.data)){const h=u;for(const m of O)s.push({path:h,patchId:m.patchId,patch:m.patch}),o.push(m.patchId),n[h]||(n[h]=new Set),n[h].add(m.type)}const l=i??this.getParentRef();if(l===null)return this.addGlobalTransientError("Tried to update content with changes, but could not since Val is not yet initialized",r),{status:"retry",reason:"not-initialized"};const c=await this.client("/patches","PUT",{body:{patches:s,parentRef:l,sessionId:e.sessionId}});if(c.status!==null&&this.resetNetworkError(),c.status===null&&c.json.type==="network_error")return console.warn("Network error: trying again..."),this.addNetworkError(r),{status:"retry",reason:"network-error"};if(c.status===409)return this.savedButNotYetGlobalServerSidePatchIds=[],{status:"retry",reason:"conflict"};if(c.status!==200){console.error("Failed to add patches",{error:c.json.message}),this.addGlobalTransientError("Failed to save changes",r,c.json.message);for(const O of o)this.removeFromPatchIdsByModule(O),this.patchDataByPatchId={...this.patchDataByPatchId,[O]:void 0},a=!0;const u=new Set(o);this.pendingClientPatchIds=this.pendingClientPatchIds.filter(O=>!u.has(O))}else{const u=new Set(c.json.newPatchIds);this.deletePendingPatchId(u);for(const O of o){const h=O;this.savedButNotYetGlobalServerSidePatchIds.push(h),this.patchDataByPatchId[h]&&(this.patchDataByPatchId[h].isPending=!1,a=!0)}}return a&&this.invalidateAllPatches(),{status:"done",parentRef:l}}deletePendingPatchId(e){let n=0;for(let r=0;r<this.pendingClientPatchIds.length;r++){const i=this.pendingClientPatchIds[r];if(e.has(i)&&(this.pendingClientPatchIds.splice(r,1),r--,n++,e.size===n))break}}deleteSavedButNotYetGlobalServerSidePatchIds(e){let n=0;for(let r=0;r<this.savedButNotYetGlobalServerSidePatchIds.length;r++){const i=this.savedButNotYetGlobalServerSidePatchIds[r];if(e.has(i)&&(this.savedButNotYetGlobalServerSidePatchIds.splice(r,1),r--,n++,e.size===n))break}}async executeDeletePatches(e,n,r){let i=!1;const s=e.patchIds,o=new Set(s),a=await this.client("/patches","DELETE",{query:{id:e.patchIds.reverse()}});if(a.status!==null&&this.resetNetworkError(),a.status===null&&a.json.type==="network_error")return this.addNetworkError(r),{status:"retry",reason:"network-error"};if(a.status!==200)this.addGlobalTransientError("Failed to delete patches",r);else{for(const l of e.patchIds)if(this.patchDataByPatchId[l]){const c=this.patchDataByPatchId[l].moduleFilePath;n[c]||(n[c]=new Set),n[c].add("unknown"),this.removeFromPatchIdsByModule(l),this.patchDataByPatchId={...this.patchDataByPatchId,[l]:void 0}}else i=!0;this.pendingClientPatchIds=this.pendingClientPatchIds.filter(l=>!o.has(l)),this.globalServerSidePatchIds=this.globalServerSidePatchIds?.filter(l=>!o.has(l))??null,this.deleteSavedButNotYetGlobalServerSidePatchIds(o)}return{status:"done",syncAllRequired:i}}async setValModules(e){if(!e){this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"absent"},this.invalidateLocalModulesStatus(),this.recomputeSchemaOutOfDate();return}const n=++this.setValModulesSeq;this.localModulesStatus={type:"loading"},this.invalidateLocalModulesStatus();let r;try{r=await tre(e)}catch(i){if(n!==this.setValModulesSeq)return;console.debug("setValModules: extractValModules threw",i),this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"error",moduleErrors:[{message:i instanceof Error?i.message:String(i)}]},this.invalidateLocalModulesStatus(),this.recomputeSchemaOutOfDate();return}if(n===this.setValModulesSeq){if(r.moduleErrors.length>0){console.debug("setValModules: moduleErrors present, falling back to server",r.moduleErrors),this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"error",moduleErrors:r.moduleErrors},this.invalidateLocalModulesStatus(),this.recomputeSchemaOutOfDate();return}this.localSchemas=r.serializedSchemas,this.localSchemaSha=r.schemaSha,this.localSources=r.sources,this.localSourcesSha=r.sourcesSha,this.localModulesStatus={type:"loaded",schemaSha:r.schemaSha,sourcesSha:r.sourcesSha,moduleCount:Object.keys(r.serializedSchemas).length},this.adoptLocalSchemas(),this.adoptLocalSources(),this.requestAllModuleValidation(),this.initializedAt===null&&(this.initializedAt=Date.now(),this.invalidateInitializedAt()),this.invalidateLocalModulesStatus(),this.recomputeSchemaOutOfDate()}}adoptLocalSchemas(){!this.localSchemas||!this.localSchemaSha||(this.schemas=this.localSchemas,this.clientSideSchemaSha=this.localSchemaSha,this.resetSchemaError(),this.invalidateSchema())}adoptLocalSources(){if(!this.localSources||!this.localSourcesSha)return;const e=this.localSources;this.serverSources===null&&(this.serverSources={...e},this.sourcesSha=this.localSourcesSha),this.forceSyncAllModules=!0,this.patchedSourcesCache=null;for(const n of Object.keys(e))this.invalidateSource(n)}recomputeSchemaOutOfDate(){const e=this.mode==="http"&&this.localSchemaSha!==null&&this.serverSideSchemaSha!==null&&this.localSchemaSha!==this.serverSideSchemaSha;e!==this.schemaOutOfDate&&(this.schemaOutOfDate=e,this.invalidateSchemaOutOfDate(),e?(this.publishDisabled=!0,this.invalidatePublishDisabled()):this.isPublishing||(this.publishDisabled=!1,this.invalidatePublishDisabled()))}async syncSchema(){if(this.localSchemas&&this.localSchemaSha)return this.schemas=this.localSchemas,this.clientSideSchemaSha=this.localSchemaSha,this.resetSchemaError(),this.invalidateSchema(),{status:"done"};const e=await this.client("/schema","GET",{});if(e.status===200){this.schemas={};for(const[n,r]of Object.entries(e.json.schemas)){const i=n;r&&(this.schemas[i]=r)}return this.clientSideSchemaSha!==e.json.schemaSha&&(this.clientSideSchemaSha=e.json.schemaSha),console.debug("Invalidating schema"),this.resetSchemaError(),this.invalidateSchema(),{status:"done"}}else if(e.status===null)return{status:"retry",reason:"error"};return this.addSchemaError(Date.now()),{status:"retry",reason:"error"}}async syncPatches(e,n){const r=this.globalServerSidePatchIds||[];let i=!1,s=!1;if(this.initializedAt===null||e){this.patchSets=new Lh,i=!0;const l=await this.client("/patches","GET",{query:{exclude_patch_ops:!1,patch_id:void 0}});if(l.status!==200)return console.debug("Val: SyncEngine: Failed to get changes (full sync)",{res:l}),{status:"retry"};for(const c of l.json.patches)c.patch&&(s=!0,this.patchDataByPatchId[c.patchId]={moduleFilePath:c.path,patch:c.patch,isPending:!1,createdAt:c.createdAt,authorId:c.authorId,isCommitted:c.appliedAt?{commitSha:c.appliedAt.commitSha}:void 0},this.addToPatchIdsByModule(c.path,c.patchId));l.json.error&&this.addGlobalTransientError("Some changes has errors",n,l.json.error.message);for(const c of Object.values(l.json.errors||{}))c&&this.addGlobalTransientError("A change has an error",n,c.message)}else{const l=[];for(const c of this.globalServerSidePatchIds||[])this.patchDataByPatchId[c]||l.push(c);if(l.length>0){const u=[];for(let O=0;O<l.length;O+=100)u.push(l.slice(O,O+100));for(const O of u){const h=await this.client("/patches","GET",{query:{exclude_patch_ops:!1,patch_id:O}});if(h.status!==200)return console.debug("Val: SyncEngine: Failed to get changes (batch) - null status",{res:h}),{status:"retry"};for(const m of h.json.patches)m.patch&&(s=!0,this.patchDataByPatchId[m.patchId]={moduleFilePath:m.path,patch:m.patch,isPending:!1,createdAt:m.createdAt,authorId:m.authorId,isCommitted:m.appliedAt?{commitSha:m.appliedAt.commitSha}:void 0},this.addToPatchIdsByModule(m.path,m.patchId))}}}const o=new Set(r);for(const l of Array.from(this.patchSets.getInsertedPatches())||[])if(!o.has(l)){this.patchSets=new Lh,i=!0;break}const a=[];for(const l of r)if(!this.patchSets.isInserted(l)){const c=this.patchDataByPatchId[l],u=c?.moduleFilePath&&this.schemas?.[c?.moduleFilePath];if(c&&u)for(const O of c.patch)i=!0,this.patchSets.insert(c.moduleFilePath,u,O,l,c.createdAt,c.authorId);else a.push(l)}return s&&this.invalidateAllPatches(),i&&this.invalidatePatchSets(),a.length>0?(this.initializedAt!==null&&(console.debug("Missing data for patch ids",a,{currentPatchIds:r,reset:e}),this.mode!=="fs"&&this.addGlobalTransientError("Failed to get changes",n,`Missing data for patch ids: ${a.join(", ")}`)),{status:"retry"}):{status:"done"}}getChangedModules(e){const n=Object.entries(e);if(n.length===0)return[];if(n.length===1){const[r,i]=n[0];if(Array.from(i).every(s=>Sce.includes(s)))return[r]}return"all"}async sync(e){if(this.isSyncing)return{status:"retry",reason:"already-syncing"};if(this.isPublishing)return{status:"retry",reason:"publishing"};let n=[];this.forceSyncAllModules&&(this.forceSyncAllModules=!1,n="all"),this.initializedAt===null&&(n="all"),!this.localSchemas&&this.clientSideSchemaSha!==this.serverSideSchemaSha&&(n="all"),this.isSyncing=!0;let r=[],i=!1;const s=new Set([...this.syncedServerSidePatchIds,...this.savedButNotYetGlobalServerSidePatchIds]);if(this.globalServerSidePatchIds&&this.mode==="http"){for(const o of s)if(!this.globalServerSidePatchIds.includes(o)){this.syncedServerSidePatchIds=[],this.savedButNotYetGlobalServerSidePatchIds=[],this.pendingClientPatchIds=[],await this.syncPatches(!0,e),this.rebuildPatchIdsByModule(),i=!0;break}}try{const o={},a=(u,O)=>e-O<=u*1e3,l=(u,O)=>e-O>=u*1e3;if(this.pendingOps[this.pendingOps.length-1]?.updatedAt!==void 0&&a(this.MIN_WAIT_SECONDS,this.pendingOps[this.pendingOps.length-1].updatedAt)&&!l(this.MAX_WAIT_SECONDS,this.pendingOps[this.pendingOps.length-1].createdAt))return{status:"retry",reason:"too-fast"};r=this.pendingOps.slice(),this.pendingOps=[];let c=!1;for(;r[0];){const u=r[0];if(u.type==="add-patches")try{const O=await this.executeAddPatches(u,o,e);if(O.status!=="done")return O}catch{return{status:"retry",reason:"error"}}else if(u.type==="delete-patches")try{const O=await this.executeDeletePatches(u,o,e);if(O.status!=="done")return O;O.syncAllRequired&&n!=="all"&&(n="all")}catch{return{status:"retry",reason:"error"}}c=!0,r.shift()}if(this.invalidatePendingOps(),n!=="all"){const u=this.getChangedModules(o);if(u==="all")n="all";else for(const O of u)n.push(O)}if(this.clientSideSchemaSha===null||this.schemas===null||this.initializedAt===null){const u=await this.syncSchema();if(u.status!=="done")return u}if(n==="all"||n.length>0){const u=n!=="all"&&n.length===1?n[0]:void 0,O=await this.client("/sources/~","PUT",{path:u,query:{validate_sources:!1,validate_binary_files:!1,exclude_patches:!1,apply_patches:!1}});if(O.status!==null&&this.resetNetworkError(),O.status===null&&O.json.type==="network_error")return this.addNetworkError(e),{status:"retry",reason:"network-error"};if(O.status!==200)this.addGlobalTransientError("Could not sync content with server. Please wait or reload the application.",e,O.json.message);else{const h=new Set;for(const m in this.errors.validationErrors){const g=m;(u===void 0||g.startsWith(u))&&(h.add(g),this.errors.validationErrors[g]&&(this.errors.validationErrors={...this.errors.validationErrors,[g]:void 0}))}for(const[m,g]of Object.entries(O.json.modules)){const y=m;if(g){this.serverSources===null&&(this.serverSources={}),this.serverSources[y]=g.source,this.renders===null&&(this.renders={}),this.renders[y]=g.render||null,this.invalidateRenders(y),this.patchedSourcesCache!==null&&(this.patchedSourcesCache={...this.patchedSourcesCache,[y]:void 0}),console.debug("Invalidating source",y),this.invalidateSource(y),this.overlayEmitter?.(y,g.source),this.invalidatePatchErrors(y),g.patches?.errors&&(this.errors.patchErrors===void 0&&(this.errors.patchErrors={}),this.errors.patchErrors[y]=g.patches.errors),this.requestModuleValidation(y);for(const v of g.patches?.applied||[])this.syncedServerSidePatchIds.push(v);for(const v of g.patches?.skipped||[])this.syncedServerSidePatchIds.push(v)}else this.addGlobalTransientError(`Could not find '${y}' in server reply`,e,"This is most likely a bug");this.markAllSyncStatusIn(y,"done")}this.invalidateAllValidationErrors();for(const m of Array.from(h))this.invalidateValidationError(m);O.json.schemaSha!==this.clientSideSchemaSha&&await this.syncSchema()}}if(this.autoPublish&&this.mode==="fs"&&this.globalServerSidePatchIds&&this.globalServerSidePatchIds.length>0){let u=!1;for(const O in this.errors.validationErrors||{}){const h=O;if(this.errors?.validationErrors?.[h]&&this.errors?.validationErrors?.[h].length>0){u=!0;break}}u?console.debug("Skip auto-publish since there's validation errors",this.errors.validationErrors):(await this.publish(this.globalServerSidePatchIds.concat(...Array.from(this.syncedServerSidePatchIds)),void 0,e),c=!0)}return(i||c)&&(this.invalidatePendingClientSidePatchIds(),this.invalidateGlobalServerSidePatchIds(),this.invalidateSyncedServerSidePatchIds(),this.invalidateSavedServerSidePatchIds()),{status:"done"}}finally{this.isSyncing=!1,this.pendingOps=[...r,...this.pendingOps]}}async publish(e,n,r){try{if(this.isPublishing)return console.debug("Already publishing changes",r),{status:"retry",reason:"already-publishing"};if(this.isPublishing=!0,this.publishDisabled)return console.debug("Could not publish changes, since the publish is disabled",r),{status:"retry",reason:"publish-disabled"};if(this.publishDisabled=!0,this.invalidatePublishDisabled(),Object.values(this.errors.validationErrors||{}).flatMap(o=>o||[]).length>0)return console.debug("Skipping publish since there's validation errors",this.errors.validationErrors),this.addGlobalTransientError("Could not publish changes, since there are validation errors",r),{status:"retry",reason:"validation-error"};if(e.length===0)return this.addGlobalTransientError("Could not publish changes, since there are no changes to publish",Date.now()),{status:"done"};const s=await this.client("/save","POST",{body:{message:n,patchIds:e}});return s.status===null?(this.addGlobalTransientError("Network error: could not publish",Date.now()),{status:"retry"}):s.status!==200?(this.addGlobalTransientError("Failed to publish changes",Date.now(),s.json.message),{status:"retry"}):(this.mode==="fs"&&(this.globalServerSidePatchIds=[],console.debug("Deleting all patch ids")),this.pendingClientPatchIds=[],this.syncedServerSidePatchIds=[],this.savedButNotYetGlobalServerSidePatchIds=[],this.patchIdsByCreatorId=new Map,this.patchIdsByModuleFilePath=new Map,this.patchDataByPatchId={},this.patchSets=new Lh,await this.syncPatches(!0,r),this.invalidatePatchSets(),this.invalidateAllPatches(),this.invalidatePendingClientSidePatchIds(),this.invalidateSyncedServerSidePatchIds(),this.invalidateSavedServerSidePatchIds(),{status:"done"})}catch(i){return console.error("Error while publishing",i),this.addGlobalTransientError("Failed to publish changes",Date.now(),i.message),{status:"retry",reason:"error"}}finally{this.isPublishing=!1,this.publishDisabled=!1,this.invalidatePublishDisabled()}}resetNetworkError(){this.errors.hasNetworkErrorTimestamp=null,this.invalidateNetworkError()}addNetworkError(e){this.errors.hasNetworkErrorTimestamp=e,this.invalidateNetworkError()}resetSchemaError(){this.errors.hasSchemaErrorTimestamp=null,this.invalidateSchemaError()}addSchemaError(e){this.errors.hasSchemaErrorTimestamp=e,this.invalidateSchemaError()}addGlobalTransientError(e,n,r){this.errors.globalTransientErrorQueue||(this.errors.globalTransientErrorQueue=[]),console.error("Global transient error",e,r||""),this.errors.globalTransientErrorQueue.push({message:e,details:r,timestamp:n,id:crypto.randomUUID()});const i=100;this.errors.globalTransientErrorQueue.length>i&&(this.errors.globalTransientErrorQueue=this.errors.globalTransientErrorQueue.slice(-i)),this.invalidateGlobalTransientErrors()}removeGlobalTransientErrors(e){if(this.errors.globalTransientErrorQueue){const n=new Set(e);this.errors.globalTransientErrorQueue=this.errors.globalTransientErrorQueue.filter(r=>!n.has(r.id)),this.invalidateGlobalTransientErrors()}}setSchemas(e){this.schemas=e,this.cachedSchemaSnapshots=null,this.cachedAllSchemasSnapshot=null,this.cachedDeserializedSchemas=null,this.emit(this.listeners.schema?.[xn])}setSources(e){this.serverSources=e,this.patchedSourcesCache=null,this.cachedSourceSnapshots=null,this.cachedServerSourceSnapshots=null,this.cachedBaseSourceSnapshots=null,this.cachedAllSourcesSnapshot=null,this.cachedSourcesSnapshot=null;for(const n in e)this.emit(this.listeners.sources?.[n]),this.emit(this.listeners.source?.[n]);this.emit(this.listeners["all-sources"]?.[xn])}setRenders(e){this.renders=e,this.cachedRenderSnapshots=e,this.cachedAllRendersSnapshot=null;for(const n in e){const r=n;this.emit(this.listeners.render?.[r])}this.emit(this.listeners["all-renders"]?.[xn])}setInitializedAt(e){this.initializedAt=e,this.cachedInitializedAtSnapshot=null,this.emit(this.listeners["initialized-at"]?.[xn])}setBaseSha(e){this.baseSha=e,this.cachedParentRef=void 0}}const CP=new fce,xn="global",Sce=["string","boolean","number","date","dateTime","richtext","file","image"],bce=(t,e)=>{window.dispatchEvent(new CustomEvent("val-event",{detail:{type:"source-update",moduleFilePath:t,source:e}}))};function Pce(t,e,n){const r={};for(const i of t)r[i.commitSha]=i;for(const i of e)r[i.commitSha]||(r[i.commitSha]={commitMessage:i?.commitMessage||null,deploymentState:"created",creator:i.creator,createdAt:i.createdAt,updatedAt:i.createdAt,commitSha:i.commitSha});for(const i of n)i.commitSha&&(r[i.commitSha]={commitMessage:r[i.commitSha]?.commitMessage||null,deploymentState:i.deploymentState,creator:r[i.commitSha]?.creator||null,createdAt:r[i.commitSha]?.createdAt||i.createdAt,updatedAt:i.updatedAt,commitSha:i.commitSha});return Object.values(r).sort((i,s)=>new Date(s.updatedAt).getTime()-new Date(i.updatedAt).getTime())}function Ce(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t?.(i),n===!1||!i.defaultPrevented)return e?.(i)}}function Az(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function za(...t){return e=>{let n=!1;const r=t.map(i=>{const s=Az(i,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():Az(t[i],null)}}}}function ft(...t){return $.useCallback(za(...t),t)}function wce(t,e){const n=$.createContext(e),r=s=>{const{children:o,...a}=s,l=$.useMemo(()=>a,Object.values(a));return d.jsx(n.Provider,{value:l,children:o})};r.displayName=t+"Provider";function i(s){const o=$.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[r,i]}function Mi(t,e=[]){let n=[];function r(s,o){const a=$.createContext(o),l=n.length;n=[...n,o];const c=O=>{const{scope:h,children:m,...g}=O,y=h?.[t]?.[l]||a,v=$.useMemo(()=>g,Object.values(g));return d.jsx(y.Provider,{value:v,children:m})};c.displayName=s+"Provider";function u(O,h){const m=h?.[t]?.[l]||a,g=$.useContext(m);if(g)return g;if(o!==void 0)return o;throw new Error(`\`${O}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=n.map(o=>$.createContext(o));return function(a){const l=a?.[t]||s;return $.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[r,kce(i,...e)]}function kce(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const O=l(s)[`__scope${c}`];return{...a,...O}},{});return $.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Vs=bq();const RR=Xf(Vs);function lO(t){const e=Tce(t),n=$.forwardRef((r,i)=>{const{children:s,...o}=r,a=$.Children.toArray(s),l=a.find(Rce);if(l){const c=l.props.children,u=a.map(O=>O===l?$.Children.count(c)>1?$.Children.only(null):$.isValidElement(c)?c.props.children:null:O);return d.jsx(e,{...o,ref:i,children:$.isValidElement(c)?$.cloneElement(c,void 0,u):null})}return d.jsx(e,{...o,ref:i,children:s})});return n.displayName=`${t}.Slot`,n}function Tce(t){const e=$.forwardRef((n,r)=>{const{children:i,...s}=n;if($.isValidElement(i)){const o=Cce(i),a=_ce(s,i.props);return i.type!==$.Fragment&&(a.ref=r?za(r,o):o),$.cloneElement(i,a)}return $.Children.count(i)>1?$.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var iM=Symbol("radix.slottable");function Xce(t){const e=({children:n})=>d.jsx(d.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=iM,e}function Rce(t){return $.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===iM}function _ce(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function Cce(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var jce=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ut=jce.reduce((t,e)=>{const n=lO(`Primitive.${e}`),r=$.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function sM(t,e){t&&Vs.flushSync(()=>t.dispatchEvent(e))}function Qr(t){const e=$.useRef(t);return $.useEffect(()=>{e.current=t}),$.useMemo(()=>(...n)=>e.current?.(...n),[])}function Ece(t,e=globalThis?.document){const n=Qr(t);$.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var zce="DismissableLayer",mk="dismissableLayer.update",Yce="dismissableLayer.pointerDownOutside",Vce="dismissableLayer.focusOutside",Wz,oM=$.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),eu=$.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=t,c=$.useContext(oM),[u,O]=$.useState(null),h=u?.ownerDocument??globalThis?.document,[,m]=$.useState({}),g=ft(e,k=>O(k)),y=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=y.indexOf(v),b=u?y.indexOf(u):-1,P=c.layersWithOutsidePointerEventsDisabled.size>0,R=b>=x,j=Ace(k=>{const E=k.target,Y=[...c.branches].some(A=>A.contains(E));!R||Y||(i?.(k),o?.(k),k.defaultPrevented||a?.())},h),X=Wce(k=>{const E=k.target;[...c.branches].some(A=>A.contains(E))||(s?.(k),o?.(k),k.defaultPrevented||a?.())},h);return Ece(k=>{b===c.layers.size-1&&(r?.(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},h),$.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Wz=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Uz(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Wz)}},[u,h,n,c]),$.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Uz())},[u,c]),$.useEffect(()=>{const k=()=>m({});return document.addEventListener(mk,k),()=>document.removeEventListener(mk,k)},[]),d.jsx(ut.div,{...l,ref:g,style:{pointerEvents:P?R?"auto":"none":void 0,...t.style},onFocusCapture:Ce(t.onFocusCapture,X.onFocusCapture),onBlurCapture:Ce(t.onBlurCapture,X.onBlurCapture),onPointerDownCapture:Ce(t.onPointerDownCapture,j.onPointerDownCapture)})});eu.displayName=zce;var Zce="DismissableLayerBranch",Nce=$.forwardRef((t,e)=>{const n=$.useContext(oM),r=$.useRef(null),i=ft(e,r);return $.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(ut.div,{...t,ref:i})});Nce.displayName=Zce;function Ace(t,e=globalThis?.document){const n=Qr(t),r=$.useRef(!1),i=$.useRef(()=>{});return $.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){aM(Yce,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=l,e.addEventListener("click",i.current,{once:!0})):l()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function Wce(t,e=globalThis?.document){const n=Qr(t),r=$.useRef(!1);return $.useEffect(()=>{const i=s=>{s.target&&!r.current&&aM(Vce,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Uz(){const t=new CustomEvent(mk);document.dispatchEvent(t)}function aM(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?sM(i,s):i.dispatchEvent(s)}var Sr=globalThis?.document?$.useLayoutEffect:()=>{},Uce=dR[" useId ".trim().toString()]||(()=>{}),qce=0;function Kn(t){const[e,n]=$.useState(Uce());return Sr(()=>{n(r=>r??String(qce++))},[t]),e?`radix-${e}`:""}const Mce=["top","right","bottom","left"],Wc=Math.min,zs=Math.max,mv=Math.round,Ny=Math.floor,Xa=t=>({x:t,y:t}),Ice={left:"right",right:"left",bottom:"top",top:"bottom"},Dce={start:"end",end:"start"};function gk(t,e,n){return zs(t,Wc(e,n))}function kl(t,e){return typeof t=="function"?t(e):t}function Tl(t){return t.split("-")[0]}function Cf(t){return t.split("-")[1]}function _R(t){return t==="x"?"y":"x"}function CR(t){return t==="y"?"height":"width"}const Gce=new Set(["top","bottom"]);function Sa(t){return Gce.has(Tl(t))?"y":"x"}function jR(t){return _R(Sa(t))}function Lce(t,e,n){n===void 0&&(n=!1);const r=Cf(t),i=jR(t),s=CR(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=gv(o)),[o,gv(o)]}function Fce(t){const e=gv(t);return[$k(t),e,$k(e)]}function $k(t){return t.replace(/start|end/g,e=>Dce[e])}const qz=["left","right"],Mz=["right","left"],Bce=["top","bottom"],Hce=["bottom","top"];function Kce(t,e,n){switch(t){case"top":case"bottom":return n?e?Mz:qz:e?qz:Mz;case"left":case"right":return e?Bce:Hce;default:return[]}}function Jce(t,e,n,r){const i=Cf(t);let s=Kce(Tl(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map($k)))),s}function gv(t){return t.replace(/left|right|bottom|top/g,e=>Ice[e])}function eue(t){return{top:0,right:0,bottom:0,left:0,...t}}function lM(t){return typeof t!="number"?eue(t):{top:t,right:t,bottom:t,left:t}}function $v(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function Iz(t,e,n){let{reference:r,floating:i}=t;const s=Sa(e),o=jR(e),a=CR(o),l=Tl(e),c=s==="y",u=r.x+r.width/2-i.width/2,O=r.y+r.height/2-i.height/2,h=r[a]/2-i[a]/2;let m;switch(l){case"top":m={x:u,y:r.y-i.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:O};break;case"left":m={x:r.x-i.width,y:O};break;default:m={x:r.x,y:r.y}}switch(Cf(e)){case"start":m[o]-=h*(n&&c?-1:1);break;case"end":m[o]+=h*(n&&c?-1:1);break}return m}const tue=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:O}=Iz(c,r,l),h=r,m={},g=0;for(let y=0;y<a.length;y++){const{name:v,fn:x}=a[y],{x:b,y:P,data:R,reset:j}=await x({x:u,y:O,initialPlacement:r,placement:h,strategy:i,middlewareData:m,rects:c,platform:o,elements:{reference:t,floating:e}});u=b??u,O=P??O,m={...m,[v]:{...m[v],...R}},j&&g<=50&&(g++,typeof j=="object"&&(j.placement&&(h=j.placement),j.rects&&(c=j.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):j.rects),{x:u,y:O}=Iz(c,h,l)),y=-1)}return{x:u,y:O,placement:h,strategy:i,middlewareData:m}};async function vm(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:O="floating",altBoundary:h=!1,padding:m=0}=kl(e,t),g=lM(m),v=a[h?O==="floating"?"reference":"floating":O],x=$v(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),b=O==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,P=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),R=await(s.isElement==null?void 0:s.isElement(P))?await(s.getScale==null?void 0:s.getScale(P))||{x:1,y:1}:{x:1,y:1},j=$v(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:P,strategy:l}):b);return{top:(x.top-j.top+g.top)/R.y,bottom:(j.bottom-x.bottom+g.bottom)/R.y,left:(x.left-j.left+g.left)/R.x,right:(j.right-x.right+g.right)/R.x}}const nue=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=kl(t,e)||{};if(c==null)return{};const O=lM(u),h={x:n,y:r},m=jR(i),g=CR(m),y=await o.getDimensions(c),v=m==="y",x=v?"top":"left",b=v?"bottom":"right",P=v?"clientHeight":"clientWidth",R=s.reference[g]+s.reference[m]-h[m]-s.floating[g],j=h[m]-s.reference[m],X=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let k=X?X[P]:0;(!k||!await(o.isElement==null?void 0:o.isElement(X)))&&(k=a.floating[P]||s.floating[g]);const E=R/2-j/2,Y=k/2-y[g]/2-1,A=Wc(O[x],Y),W=Wc(O[b],Y),N=A,G=k-y[g]-W,U=k/2-y[g]/2+E,F=gk(N,U,G),H=!l.arrow&&Cf(i)!=null&&U!==F&&s.reference[g]/2-(U<N?A:W)-y[g]/2<0,B=H?U<N?U-N:U-G:0;return{[m]:h[m]+B,data:{[m]:F,centerOffset:U-F-B,...H&&{alignmentOffset:B}},reset:H}}}),rue=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:O=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...v}=kl(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Tl(i),b=Sa(a),P=Tl(a)===a,R=await(l.isRTL==null?void 0:l.isRTL(c.floating)),j=h||(P||!y?[gv(a)]:Fce(a)),X=g!=="none";!h&&X&&j.push(...Jce(a,y,g,R));const k=[a,...j],E=await vm(e,v),Y=[];let A=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&Y.push(E[x]),O){const U=Lce(i,o,R);Y.push(E[U[0]],E[U[1]])}if(A=[...A,{placement:i,overflows:Y}],!Y.every(U=>U<=0)){var W,N;const U=(((W=s.flip)==null?void 0:W.index)||0)+1,F=k[U];if(F&&(!(O==="alignment"?b!==Sa(F):!1)||A.every(V=>Sa(V.placement)===b?V.overflows[0]>0:!0)))return{data:{index:U,overflows:A},reset:{placement:F}};let H=(N=A.filter(B=>B.overflows[0]<=0).sort((B,V)=>B.overflows[1]-V.overflows[1])[0])==null?void 0:N.placement;if(!H)switch(m){case"bestFit":{var G;const B=(G=A.filter(V=>{if(X){const L=Sa(V.placement);return L===b||L==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(L=>L>0).reduce((L,_)=>L+_,0)]).sort((V,L)=>V[1]-L[1])[0])==null?void 0:G[0];B&&(H=B);break}case"initialPlacement":H=a;break}if(i!==H)return{reset:{placement:H}}}return{}}}};function Dz(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Gz(t){return Mce.some(e=>t[e]>=0)}const iue=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=kl(t,e);switch(r){case"referenceHidden":{const s=await vm(e,{...i,elementContext:"reference"}),o=Dz(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Gz(o)}}}case"escaped":{const s=await vm(e,{...i,altBoundary:!0}),o=Dz(s,n.floating);return{data:{escapedOffsets:o,escaped:Gz(o)}}}default:return{}}}}},cM=new Set(["left","top"]);async function sue(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Tl(n),a=Cf(n),l=Sa(n)==="y",c=cM.has(o)?-1:1,u=s&&l?-1:1,O=kl(e,t);let{mainAxis:h,crossAxis:m,alignmentAxis:g}=typeof O=="number"?{mainAxis:O,crossAxis:0,alignmentAxis:null}:{mainAxis:O.mainAxis||0,crossAxis:O.crossAxis||0,alignmentAxis:O.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),l?{x:m*u,y:h*c}:{x:h*c,y:m*u}}const oue=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,l=await sue(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},aue=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:v=>{let{x,y:b}=v;return{x,y:b}}},...l}=kl(t,e),c={x:n,y:r},u=await vm(e,l),O=Sa(Tl(i)),h=_R(O);let m=c[h],g=c[O];if(s){const v=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=m+u[v],P=m-u[x];m=gk(b,m,P)}if(o){const v=O==="y"?"top":"left",x=O==="y"?"bottom":"right",b=g+u[v],P=g-u[x];g=gk(b,g,P)}const y=a.fn({...e,[h]:m,[O]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:s,[O]:o}}}}}},lue=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=kl(t,e),u={x:n,y:r},O=Sa(i),h=_R(O);let m=u[h],g=u[O];const y=kl(a,e),v=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const P=h==="y"?"height":"width",R=s.reference[h]-s.floating[P]+v.mainAxis,j=s.reference[h]+s.reference[P]-v.mainAxis;m<R?m=R:m>j&&(m=j)}if(c){var x,b;const P=h==="y"?"width":"height",R=cM.has(Tl(i)),j=s.reference[O]-s.floating[P]+(R&&((x=o.offset)==null?void 0:x[O])||0)+(R?0:v.crossAxis),X=s.reference[O]+s.reference[P]+(R?0:((b=o.offset)==null?void 0:b[O])||0)-(R?v.crossAxis:0);g<j?g=j:g>X&&(g=X)}return{[h]:m,[O]:g}}}},cue=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:l=()=>{},...c}=kl(t,e),u=await vm(e,c),O=Tl(i),h=Cf(i),m=Sa(i)==="y",{width:g,height:y}=s.floating;let v,x;O==="top"||O==="bottom"?(v=O,x=h===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(x=O,v=h==="end"?"top":"bottom");const b=y-u.top-u.bottom,P=g-u.left-u.right,R=Wc(y-u[v],b),j=Wc(g-u[x],P),X=!e.middlewareData.shift;let k=R,E=j;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(E=P),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(k=b),X&&!h){const A=zs(u.left,0),W=zs(u.right,0),N=zs(u.top,0),G=zs(u.bottom,0);m?E=g-2*(A!==0||W!==0?A+W:zs(u.left,u.right)):k=y-2*(N!==0||G!==0?N+G:zs(u.top,u.bottom))}await l({...e,availableWidth:E,availableHeight:k});const Y=await o.getDimensions(a.floating);return g!==Y.width||y!==Y.height?{reset:{rects:!0}}:{}}}};function iS(){return typeof window<"u"}function jf(t){return uM(t)?(t.nodeName||"").toLowerCase():"#document"}function Ws(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Aa(t){var e;return(e=(uM(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function uM(t){return iS()?t instanceof Node||t instanceof Ws(t).Node:!1}function Uo(t){return iS()?t instanceof Element||t instanceof Ws(t).Element:!1}function Ya(t){return iS()?t instanceof HTMLElement||t instanceof Ws(t).HTMLElement:!1}function Lz(t){return!iS()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ws(t).ShadowRoot}const uue=new Set(["inline","contents"]);function gg(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=qo(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!uue.has(i)}const Oue=new Set(["table","td","th"]);function due(t){return Oue.has(jf(t))}const fue=[":popover-open",":modal"];function sS(t){return fue.some(e=>{try{return t.matches(e)}catch{return!1}})}const hue=["transform","translate","scale","rotate","perspective"],pue=["transform","translate","scale","rotate","perspective","filter"],mue=["paint","layout","strict","content"];function ER(t){const e=zR(),n=Uo(t)?qo(t):t;return hue.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||pue.some(r=>(n.willChange||"").includes(r))||mue.some(r=>(n.contain||"").includes(r))}function gue(t){let e=Uc(t);for(;Ya(e)&&!nf(e);){if(ER(e))return e;if(sS(e))return null;e=Uc(e)}return null}function zR(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const $ue=new Set(["html","body","#document"]);function nf(t){return $ue.has(jf(t))}function qo(t){return Ws(t).getComputedStyle(t)}function oS(t){return Uo(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Uc(t){if(jf(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Lz(t)&&t.host||Aa(t);return Lz(e)?e.host:e}function OM(t){const e=Uc(t);return nf(e)?t.ownerDocument?t.ownerDocument.body:t.body:Ya(e)&&gg(e)?e:OM(e)}function xm(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=OM(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=Ws(i);if(s){const a=yk(o);return e.concat(o,o.visualViewport||[],gg(i)?i:[],a&&n?xm(a):[])}return e.concat(i,xm(i,[],n))}function yk(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function dM(t){const e=qo(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Ya(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=mv(n)!==s||mv(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function YR(t){return Uo(t)?t:t.contextElement}function Ed(t){const e=YR(t);if(!Ya(e))return Xa(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=dM(e);let o=(s?mv(n.width):n.width)/r,a=(s?mv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const yue=Xa(0);function fM(t){const e=Ws(t);return!zR()||!e.visualViewport?yue:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Que(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ws(t)?!1:e}function cO(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=YR(t);let o=Xa(1);e&&(r?Uo(r)&&(o=Ed(r)):o=Ed(t));const a=Que(s,n,r)?fM(s):Xa(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,O=i.height/o.y;if(s){const h=Ws(s),m=r&&Uo(r)?Ws(r):r;let g=h,y=yk(g);for(;y&&r&&m!==g;){const v=Ed(y),x=y.getBoundingClientRect(),b=qo(y),P=x.left+(y.clientLeft+parseFloat(b.paddingLeft))*v.x,R=x.top+(y.clientTop+parseFloat(b.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,O*=v.y,l+=P,c+=R,g=Ws(y),y=yk(g)}}return $v({width:u,height:O,x:l,y:c})}function aS(t,e){const n=oS(t).scrollLeft;return e?e.left+n:cO(Aa(t)).left+n}function hM(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-aS(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function vue(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=Aa(r),a=e?sS(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Xa(1);const u=Xa(0),O=Ya(r);if((O||!O&&!s)&&((jf(r)!=="body"||gg(o))&&(l=oS(r)),Ya(r))){const m=cO(r);c=Ed(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const h=o&&!O&&!s?hM(o,l):Xa(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function xue(t){return Array.from(t.getClientRects())}function Sue(t){const e=Aa(t),n=oS(t),r=t.ownerDocument.body,i=zs(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=zs(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+aS(t);const a=-n.scrollTop;return qo(r).direction==="rtl"&&(o+=zs(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const Fz=25;function bue(t,e){const n=Ws(t),r=Aa(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const u=zR();(!u||u&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const c=aS(r);if(c<=0){const u=r.ownerDocument,O=u.body,h=getComputedStyle(O),m=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(r.clientWidth-O.clientWidth-m);g<=Fz&&(s-=g)}else c<=Fz&&(s+=c);return{width:s,height:o,x:a,y:l}}const Pue=new Set(["absolute","fixed"]);function wue(t,e){const n=cO(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Ya(t)?Ed(t):Xa(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function Bz(t,e,n){let r;if(e==="viewport")r=bue(t,n);else if(e==="document")r=Sue(Aa(t));else if(Uo(e))r=wue(e,n);else{const i=fM(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return $v(r)}function pM(t,e){const n=Uc(t);return n===e||!Uo(n)||nf(n)?!1:qo(n).position==="fixed"||pM(n,e)}function kue(t,e){const n=e.get(t);if(n)return n;let r=xm(t,[],!1).filter(a=>Uo(a)&&jf(a)!=="body"),i=null;const s=qo(t).position==="fixed";let o=s?Uc(t):t;for(;Uo(o)&&!nf(o);){const a=qo(o),l=ER(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&Pue.has(i.position)||gg(o)&&!l&&pM(t,o))?r=r.filter(u=>u!==o):i=a,o=Uc(o)}return e.set(t,r),r}function Tue(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?sS(e)?[]:kue(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((c,u)=>{const O=Bz(e,u,i);return c.top=zs(O.top,c.top),c.right=Wc(O.right,c.right),c.bottom=Wc(O.bottom,c.bottom),c.left=zs(O.left,c.left),c},Bz(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Xue(t){const{width:e,height:n}=dM(t);return{width:e,height:n}}function Rue(t,e,n){const r=Ya(e),i=Aa(e),s=n==="fixed",o=cO(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Xa(0);function c(){l.x=aS(i)}if(r||!r&&!s)if((jf(e)!=="body"||gg(i))&&(a=oS(e)),r){const m=cO(e,!0,s,e);l.x=m.x+e.clientLeft,l.y=m.y+e.clientTop}else i&&c();s&&!r&&i&&c();const u=i&&!r&&!s?hM(i,a):Xa(0),O=o.left+a.scrollLeft-l.x-u.x,h=o.top+a.scrollTop-l.y-u.y;return{x:O,y:h,width:o.width,height:o.height}}function jP(t){return qo(t).position==="static"}function Hz(t,e){if(!Ya(t)||qo(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Aa(t)===n&&(n=n.ownerDocument.body),n}function mM(t,e){const n=Ws(t);if(sS(t))return n;if(!Ya(t)){let i=Uc(t);for(;i&&!nf(i);){if(Uo(i)&&!jP(i))return i;i=Uc(i)}return n}let r=Hz(t,e);for(;r&&due(r)&&jP(r);)r=Hz(r,e);return r&&nf(r)&&jP(r)&&!ER(r)?n:r||gue(t)||n}const _ue=async function(t){const e=this.getOffsetParent||mM,n=this.getDimensions,r=await n(t.floating);return{reference:Rue(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Cue(t){return qo(t).direction==="rtl"}const jue={convertOffsetParentRelativeRectToViewportRelativeRect:vue,getDocumentElement:Aa,getClippingRect:Tue,getOffsetParent:mM,getElementRects:_ue,getClientRects:xue,getDimensions:Xue,getScale:Ed,isElement:Uo,isRTL:Cue};function gM(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Eue(t,e){let n=null,r;const i=Aa(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=t.getBoundingClientRect(),{left:u,top:O,width:h,height:m}=c;if(a||e(),!h||!m)return;const g=Ny(O),y=Ny(i.clientWidth-(u+h)),v=Ny(i.clientHeight-(O+m)),x=Ny(u),P={rootMargin:-g+"px "+-y+"px "+-v+"px "+-x+"px",threshold:zs(0,Wc(1,l))||1};let R=!0;function j(X){const k=X[0].intersectionRatio;if(k!==l){if(!R)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}k===1&&!gM(c,t.getBoundingClientRect())&&o(),R=!1}try{n=new IntersectionObserver(j,{...P,root:i.ownerDocument})}catch{n=new IntersectionObserver(j,P)}n.observe(t)}return o(!0),s}function zue(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=YR(t),u=i||s?[...c?xm(c):[],...xm(e)]:[];u.forEach(x=>{i&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const O=c&&a?Eue(c,n):null;let h=-1,m=null;o&&(m=new ResizeObserver(x=>{let[b]=x;b&&b.target===c&&m&&(m.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var P;(P=m)==null||P.observe(e)})),n()}),c&&!l&&m.observe(c),m.observe(e));let g,y=l?cO(t):null;l&&v();function v(){const x=cO(t);y&&!gM(y,x)&&n(),y=x,g=requestAnimationFrame(v)}return n(),()=>{var x;u.forEach(b=>{i&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),O?.(),(x=m)==null||x.disconnect(),m=null,l&&cancelAnimationFrame(g)}}const Yue=oue,Vue=aue,Zue=rue,Nue=cue,Aue=iue,Kz=nue,Wue=lue,Uue=(t,e,n)=>{const r=new Map,i={platform:jue,...n},s={...i.platform,_c:r};return tue(t,e,{...i,platform:s})};var que=typeof document<"u",Mue=function(){},ZQ=que?$.useLayoutEffect:Mue;function yv(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!yv(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!yv(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function $M(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Jz(t,e){const n=$M(t);return Math.round(e*n)/n}function EP(t){const e=$.useRef(t);return ZQ(()=>{e.current=t}),e}function Iue(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[u,O]=$.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,m]=$.useState(r);yv(h,r)||m(r);const[g,y]=$.useState(null),[v,x]=$.useState(null),b=$.useCallback(V=>{V!==X.current&&(X.current=V,y(V))},[]),P=$.useCallback(V=>{V!==k.current&&(k.current=V,x(V))},[]),R=s||g,j=o||v,X=$.useRef(null),k=$.useRef(null),E=$.useRef(u),Y=l!=null,A=EP(l),W=EP(i),N=EP(c),G=$.useCallback(()=>{if(!X.current||!k.current)return;const V={placement:e,strategy:n,middleware:h};W.current&&(V.platform=W.current),Uue(X.current,k.current,V).then(L=>{const _={...L,isPositioned:N.current!==!1};U.current&&!yv(E.current,_)&&(E.current=_,Vs.flushSync(()=>{O(_)}))})},[h,e,n,W,N]);ZQ(()=>{c===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,O(V=>({...V,isPositioned:!1})))},[c]);const U=$.useRef(!1);ZQ(()=>(U.current=!0,()=>{U.current=!1}),[]),ZQ(()=>{if(R&&(X.current=R),j&&(k.current=j),R&&j){if(A.current)return A.current(R,j,G);G()}},[R,j,G,A,Y]);const F=$.useMemo(()=>({reference:X,floating:k,setReference:b,setFloating:P}),[b,P]),H=$.useMemo(()=>({reference:R,floating:j}),[R,j]),B=$.useMemo(()=>{const V={position:n,left:0,top:0};if(!H.floating)return V;const L=Jz(H.floating,u.x),_=Jz(H.floating,u.y);return a?{...V,transform:"translate("+L+"px, "+_+"px)",...$M(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:L,top:_}},[n,a,H.floating,u.x,u.y]);return $.useMemo(()=>({...u,update:G,refs:F,elements:H,floatingStyles:B}),[u,G,F,H,B])}const Due=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Kz({element:r.current,padding:i}).fn(n):{}:r?Kz({element:r,padding:i}).fn(n):{}}}},Gue=(t,e)=>({...Yue(t),options:[t,e]}),Lue=(t,e)=>({...Vue(t),options:[t,e]}),Fue=(t,e)=>({...Wue(t),options:[t,e]}),Bue=(t,e)=>({...Zue(t),options:[t,e]}),Hue=(t,e)=>({...Nue(t),options:[t,e]}),Kue=(t,e)=>({...Aue(t),options:[t,e]}),Jue=(t,e)=>({...Due(t),options:[t,e]});var eOe="Arrow",yM=$.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return d.jsx(ut.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});yM.displayName=eOe;var tOe=yM;function VR(t){const[e,n]=$.useState(void 0);return Sr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=t.offsetWidth,a=t.offsetHeight;n({width:o,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var ZR="Popper",[QM,Wa]=Mi(ZR),[nOe,vM]=QM(ZR),xM=t=>{const{__scopePopper:e,children:n}=t,[r,i]=$.useState(null);return d.jsx(nOe,{scope:e,anchor:r,onAnchorChange:i,children:n})};xM.displayName=ZR;var SM="PopperAnchor",bM=$.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=vM(SM,n),o=$.useRef(null),a=ft(e,o),l=$.useRef(null);return $.useEffect(()=>{const c=l.current;l.current=r?.current||o.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:d.jsx(ut.div,{...i,ref:a})});bM.displayName=SM;var NR="PopperContent",[rOe,iOe]=QM(NR),PM=$.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:O="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:g,...y}=t,v=vM(NR,n),[x,b]=$.useState(null),P=ft(e,ne=>b(ne)),[R,j]=$.useState(null),X=VR(R),k=X?.width??0,E=X?.height??0,Y=r+(s!=="center"?"-"+s:""),A=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},W=Array.isArray(c)?c:[c],N=W.length>0,G={padding:A,boundary:W.filter(oOe),altBoundary:N},{refs:U,floatingStyles:F,placement:H,isPositioned:B,middlewareData:V}=Iue({strategy:"fixed",placement:Y,whileElementsMounted:(...ne)=>zue(...ne,{animationFrame:m==="always"}),elements:{reference:v.anchor},middleware:[Gue({mainAxis:i+E,alignmentAxis:o}),l&&Lue({mainAxis:!0,crossAxis:!1,limiter:O==="partial"?Fue():void 0,...G}),l&&Bue({...G}),Hue({...G,apply:({elements:ne,rects:Oe,availableWidth:Qe,availableHeight:se})=>{const{width:ve,height:ce}=Oe.reference,he=ne.floating.style;he.setProperty("--radix-popper-available-width",`${Qe}px`),he.setProperty("--radix-popper-available-height",`${se}px`),he.setProperty("--radix-popper-anchor-width",`${ve}px`),he.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),R&&Jue({element:R,padding:a}),aOe({arrowWidth:k,arrowHeight:E}),h&&Kue({strategy:"referenceHidden",...G})]}),[L,_]=TM(H),q=Qr(g);Sr(()=>{B&&q?.()},[B,q]);const M=V.arrow?.x,z=V.arrow?.y,te=V.arrow?.centerOffset!==0,[ee,ae]=$.useState();return Sr(()=>{x&&ae(window.getComputedStyle(x).zIndex)},[x]),d.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:B?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(" "),...V.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:d.jsx(rOe,{scope:n,placedSide:L,onArrowChange:j,arrowX:M,arrowY:z,shouldHideArrow:te,children:d.jsx(ut.div,{"data-side":L,"data-align":_,...y,ref:P,style:{...y.style,animation:B?void 0:"none"}})})})});PM.displayName=NR;var wM="PopperArrow",sOe={top:"bottom",right:"left",bottom:"top",left:"right"},kM=$.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=iOe(wM,r),o=sOe[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(tOe,{...i,ref:n,style:{...i.style,display:"block"}})})});kM.displayName=wM;function oOe(t){return t!==null}var aOe=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:i}=e,o=i.arrow?.centerOffset!==0,a=o?0:t.arrowWidth,l=o?0:t.arrowHeight,[c,u]=TM(n),O={start:"0%",center:"50%",end:"100%"}[u],h=(i.arrow?.x??0)+a/2,m=(i.arrow?.y??0)+l/2;let g="",y="";return c==="bottom"?(g=o?O:`${h}px`,y=`${-l}px`):c==="top"?(g=o?O:`${h}px`,y=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,y=o?O:`${m}px`):c==="left"&&(g=`${r.floating.width+l}px`,y=o?O:`${m}px`),{data:{x:g,y}}}});function TM(t){const[e,n="center"]=t.split("-");return[e,n]}var $g=xM,Ef=bM,yg=PM,Qg=kM,lOe="Portal",zf=$.forwardRef((t,e)=>{const{container:n,...r}=t,[i,s]=$.useState(!1);Sr(()=>s(!0),[]);const o=n||i&&globalThis?.document?.body;return o?RR.createPortal(d.jsx(ut.div,{...r,ref:e}),o):null});zf.displayName=lOe;function cOe(t,e){return $.useReducer((n,r)=>e[n][r]??n,t)}var Jn=t=>{const{present:e,children:n}=t,r=uOe(e),i=typeof n=="function"?n({present:r.isPresent}):$.Children.only(n),s=ft(r.ref,OOe(i));return typeof n=="function"||r.isPresent?$.cloneElement(i,{ref:s}):null};Jn.displayName="Presence";function uOe(t){const[e,n]=$.useState(),r=$.useRef(null),i=$.useRef(t),s=$.useRef("none"),o=t?"mounted":"unmounted",[a,l]=cOe(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return $.useEffect(()=>{const c=Ay(r.current);s.current=a==="mounted"?c:"none"},[a]),Sr(()=>{const c=r.current,u=i.current;if(u!==t){const h=s.current,m=Ay(c);t?l("MOUNT"):m==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&h!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,l]),Sr(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,O=m=>{const y=Ay(r.current).includes(CSS.escape(m.animationName));if(m.target===e&&y&&(l("ANIMATION_END"),!i.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},h=m=>{m.target===e&&(s.current=Ay(r.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",O),e.addEventListener("animationend",O),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",O),e.removeEventListener("animationend",O)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:$.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Ay(t){return t?.animationName||"none"}function OOe(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var dOe=dR[" useInsertionEffect ".trim().toString()]||Sr;function ms({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,s,o]=fOe({defaultProp:e,onChange:n}),a=t!==void 0,l=a?t:i;{const u=$.useRef(t!==void 0);$.useEffect(()=>{const O=u.current;O!==a&&console.warn(`${r} is changing from ${O?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=$.useCallback(u=>{if(a){const O=hOe(u)?u(t):u;O!==t&&o.current?.(O)}else s(u)},[a,t,s,o]);return[l,c]}function fOe({defaultProp:t,onChange:e}){const[n,r]=$.useState(t),i=$.useRef(n),s=$.useRef(e);return dOe(()=>{s.current=e},[e]),$.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function hOe(t){return typeof t=="function"}var XM=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),pOe="VisuallyHidden",RM=$.forwardRef((t,e)=>d.jsx(ut.span,{...t,ref:e,style:{...XM,...t.style}}));RM.displayName=pOe;var mOe=RM,[lS]=Mi("Tooltip",[Wa]),cS=Wa(),_M="TooltipProvider",gOe=700,Qk="tooltip.open",[$Oe,AR]=lS(_M),CM=t=>{const{__scopeTooltip:e,delayDuration:n=gOe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,o=$.useRef(!0),a=$.useRef(!1),l=$.useRef(0);return $.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),d.jsx($Oe,{scope:e,isOpenDelayedRef:o,delayDuration:n,onOpen:$.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:$.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:$.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};CM.displayName=_M;var Sm="Tooltip",[yOe,uS]=lS(Sm),jM=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,l=AR(Sm,t.__scopeTooltip),c=cS(e),[u,O]=$.useState(null),h=Kn(),m=$.useRef(0),g=o??l.disableHoverableContent,y=a??l.delayDuration,v=$.useRef(!1),[x,b]=ms({prop:r,defaultProp:i??!1,onChange:k=>{k?(l.onOpen(),document.dispatchEvent(new CustomEvent(Qk))):l.onClose(),s?.(k)},caller:Sm}),P=$.useMemo(()=>x?v.current?"delayed-open":"instant-open":"closed",[x]),R=$.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v.current=!1,b(!0)},[b]),j=$.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b(!1)},[b]),X=$.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{v.current=!0,b(!0),m.current=0},y)},[y,b]);return $.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),d.jsx($g,{...c,children:d.jsx(yOe,{scope:e,contentId:h,open:x,stateAttribute:P,trigger:u,onTriggerChange:O,onTriggerEnter:$.useCallback(()=>{l.isOpenDelayedRef.current?X():R()},[l.isOpenDelayedRef,X,R]),onTriggerLeave:$.useCallback(()=>{g?j():(window.clearTimeout(m.current),m.current=0)},[j,g]),onOpen:R,onClose:j,disableHoverableContent:g,children:n})})};jM.displayName=Sm;var vk="TooltipTrigger",WR=$.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=uS(vk,n),s=AR(vk,n),o=cS(n),a=$.useRef(null),l=ft(e,a,i.onTriggerChange),c=$.useRef(!1),u=$.useRef(!1),O=$.useCallback(()=>c.current=!1,[]);return $.useEffect(()=>()=>document.removeEventListener("pointerup",O),[O]),d.jsx(Ef,{asChild:!0,...o,children:d.jsx(ut.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Ce(t.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Ce(t.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Ce(t.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",O,{once:!0})}),onFocus:Ce(t.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ce(t.onBlur,i.onClose),onClick:Ce(t.onClick,i.onClose)})})});WR.displayName=vk;var QOe="TooltipPortal",[mFe,vOe]=lS(QOe,{forceMount:void 0}),rf="TooltipContent",EM=$.forwardRef((t,e)=>{const n=vOe(rf,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=uS(rf,t.__scopeTooltip);return d.jsx(Jn,{present:r||o.open,children:o.disableHoverableContent?d.jsx(zM,{side:i,...s,ref:e}):d.jsx(xOe,{side:i,...s,ref:e})})}),xOe=$.forwardRef((t,e)=>{const n=uS(rf,t.__scopeTooltip),r=AR(rf,t.__scopeTooltip),i=$.useRef(null),s=ft(e,i),[o,a]=$.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:O}=r,h=$.useCallback(()=>{a(null),O(!1)},[O]),m=$.useCallback((g,y)=>{const v=g.currentTarget,x={x:g.clientX,y:g.clientY},b=kOe(x,v.getBoundingClientRect()),P=TOe(x,b),R=XOe(y.getBoundingClientRect()),j=_Oe([...P,...R]);a(j),O(!0)},[O]);return $.useEffect(()=>()=>h(),[h]),$.useEffect(()=>{if(l&&u){const g=v=>m(v,u),y=v=>m(v,l);return l.addEventListener("pointerleave",g),u.addEventListener("pointerleave",y),()=>{l.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",y)}}},[l,u,m,h]),$.useEffect(()=>{if(o){const g=y=>{const v=y.target,x={x:y.clientX,y:y.clientY},b=l?.contains(v)||u?.contains(v),P=!ROe(x,o);b?h():P&&(h(),c())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,u,o,c,h]),d.jsx(zM,{...t,ref:s})}),[SOe,bOe]=lS(Sm,{isInside:!1}),POe=Xce("TooltipContent"),zM=$.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,l=uS(rf,n),c=cS(n),{onClose:u}=l;return $.useEffect(()=>(document.addEventListener(Qk,u),()=>document.removeEventListener(Qk,u)),[u]),$.useEffect(()=>{if(l.trigger){const O=h=>{h.target?.contains(l.trigger)&&u()};return window.addEventListener("scroll",O,{capture:!0}),()=>window.removeEventListener("scroll",O,{capture:!0})}},[l.trigger,u]),d.jsx(eu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:O=>O.preventDefault(),onDismiss:u,children:d.jsxs(yg,{"data-state":l.stateAttribute,...c,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[d.jsx(POe,{children:r}),d.jsx(SOe,{scope:n,isInside:!0,children:d.jsx(mOe,{id:l.contentId,role:"tooltip",children:i||r})})]})})});EM.displayName=rf;var YM="TooltipArrow",wOe=$.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=cS(n);return bOe(YM,n).isInside?null:d.jsx(Qg,{...i,...r,ref:e})});wOe.displayName=YM;function kOe(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function TOe(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function XOe(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function ROe(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s],l=e[o],c=a.x,u=a.y,O=l.x,h=l.y;u>r!=h>r&&n<(O-c)*(r-u)/(h-u)+c&&(i=!i)}return i}function _Oe(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),COe(e)}function COe(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var jOe=CM,EOe=jM,zOe=WR,VM=EM;function ZM(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=ZM(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function NM(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=ZM(t))&&(r&&(r+=" "),r+=e);return r}const UR="-",YOe=t=>{const e=ZOe(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const a=o.split(UR);return a[0]===""&&a.length!==1&&a.shift(),AM(a,e)||VOe(o)},getConflictingClassGroupIds:(o,a)=>{const l=n[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},AM=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?AM(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(UR);return e.validators.find(({validator:o})=>o(s))?.classGroupId},eY=/^\[(.+)\]$/,VOe=t=>{if(eY.test(t)){const e=eY.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},ZOe=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return AOe(Object.entries(t.classGroups),n).forEach(([s,o])=>{xk(o,r,s,e)}),r},xk=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:tY(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(NOe(i)){xk(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{xk(o,tY(e,s),n,r)})})},tY=(t,e)=>{let n=t;return e.split(UR).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},NOe=t=>t.isThemeGetter,AOe=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[e+o,a])):s);return[n,i]}):t,WOe=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},WM="!",UOe=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=a=>{const l=[];let c=0,u=0,O;for(let v=0;v<a.length;v++){let x=a[v];if(c===0){if(x===i&&(r||a.slice(v,v+s)===e)){l.push(a.slice(u,v)),u=v+s;continue}if(x==="/"){O=v;continue}}x==="["?c++:x==="]"&&c--}const h=l.length===0?a:a.substring(u),m=h.startsWith(WM),g=m?h.substring(1):h,y=O&&O>u?O-u:void 0;return{modifiers:l,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:y}};return n?a=>n({className:a,parseClassName:o}):o},qOe=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},MOe=t=>({cache:WOe(t.cacheSize),parseClassName:UOe(t),...YOe(t)}),IOe=/\s+/,DOe=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(IOe);let a="";for(let l=o.length-1;l>=0;l-=1){const c=o[l],{modifiers:u,hasImportantModifier:O,baseClassName:h,maybePostfixModifierPosition:m}=n(c);let g=!!m,y=r(g?h.substring(0,m):h);if(!y){if(!g){a=c+(a.length>0?" "+a:a);continue}if(y=r(h),!y){a=c+(a.length>0?" "+a:a);continue}g=!1}const v=qOe(u).join(":"),x=O?v+WM:v,b=x+y;if(s.includes(b))continue;s.push(b);const P=i(y,g);for(let R=0;R<P.length;++R){const j=P[R];s.push(x+j)}a=c+(a.length>0?" "+a:a)}return a};function GOe(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=UM(e))&&(r&&(r+=" "),r+=n);return r}const UM=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=UM(t[r]))&&(n&&(n+=" "),n+=e);return n};function LOe(t,...e){let n,r,i,s=o;function o(l){const c=e.reduce((u,O)=>O(u),t());return n=MOe(c),r=n.cache.get,i=n.cache.set,s=a,a(l)}function a(l){const c=r(l);if(c)return c;const u=DOe(l,n);return i(l,u),u}return function(){return s(GOe.apply(null,arguments))}}const Rn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},qM=/^\[(?:([a-z-]+):)?(.+)\]$/i,FOe=/^\d+\/\d+$/,BOe=new Set(["px","full","screen"]),HOe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,KOe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,JOe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,ede=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,tde=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,il=t=>zd(t)||BOe.has(t)||FOe.test(t),sc=t=>Yf(t,"length",cde),zd=t=>!!t&&!Number.isNaN(Number(t)),zP=t=>Yf(t,"number",zd),Fh=t=>!!t&&Number.isInteger(Number(t)),nde=t=>t.endsWith("%")&&zd(t.slice(0,-1)),bt=t=>qM.test(t),oc=t=>HOe.test(t),rde=new Set(["length","size","percentage"]),ide=t=>Yf(t,rde,MM),sde=t=>Yf(t,"position",MM),ode=new Set(["image","url"]),ade=t=>Yf(t,ode,Ode),lde=t=>Yf(t,"",ude),Bh=()=>!0,Yf=(t,e,n)=>{const r=qM.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},cde=t=>KOe.test(t)&&!JOe.test(t),MM=()=>!1,ude=t=>ede.test(t),Ode=t=>tde.test(t),dde=()=>{const t=Rn("colors"),e=Rn("spacing"),n=Rn("blur"),r=Rn("brightness"),i=Rn("borderColor"),s=Rn("borderRadius"),o=Rn("borderSpacing"),a=Rn("borderWidth"),l=Rn("contrast"),c=Rn("grayscale"),u=Rn("hueRotate"),O=Rn("invert"),h=Rn("gap"),m=Rn("gradientColorStops"),g=Rn("gradientColorStopPositions"),y=Rn("inset"),v=Rn("margin"),x=Rn("opacity"),b=Rn("padding"),P=Rn("saturate"),R=Rn("scale"),j=Rn("sepia"),X=Rn("skew"),k=Rn("space"),E=Rn("translate"),Y=()=>["auto","contain","none"],A=()=>["auto","hidden","clip","visible","scroll"],W=()=>["auto",bt,e],N=()=>[bt,e],G=()=>["",il,sc],U=()=>["auto",zd,bt],F=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],B=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>["start","end","center","between","around","evenly","stretch"],L=()=>["","0",bt],_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],q=()=>[zd,bt];return{cacheSize:500,separator:":",theme:{colors:[Bh],spacing:[il,sc],blur:["none","",oc,bt],brightness:q(),borderColor:[t],borderRadius:["none","","full",oc,bt],borderSpacing:N(),borderWidth:G(),contrast:q(),grayscale:L(),hueRotate:q(),invert:L(),gap:N(),gradientColorStops:[t],gradientColorStopPositions:[nde,sc],inset:W(),margin:W(),opacity:q(),padding:N(),saturate:q(),scale:q(),sepia:L(),skew:q(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",bt]}],container:["container"],columns:[{columns:[oc]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...F(),bt]}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:Y()}],"overscroll-x":[{"overscroll-x":Y()}],"overscroll-y":[{"overscroll-y":Y()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Fh,bt]}],basis:[{basis:W()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",bt]}],grow:[{grow:L()}],shrink:[{shrink:L()}],order:[{order:["first","last","none",Fh,bt]}],"grid-cols":[{"grid-cols":[Bh]}],"col-start-end":[{col:["auto",{span:["full",Fh,bt]},bt]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[Bh]}],"row-start-end":[{row:["auto",{span:[Fh,bt]},bt]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",bt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",bt]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...V()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...V(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...V(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[k]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[k]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",bt,e]}],"min-w":[{"min-w":[bt,e,"min","max","fit"]}],"max-w":[{"max-w":[bt,e,"none","full","min","max","fit","prose",{screen:[oc]},oc]}],h:[{h:[bt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[bt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[bt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[bt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",oc,sc]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",zP]}],"font-family":[{font:[Bh]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",bt]}],"line-clamp":[{"line-clamp":["none",zd,zP]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",il,bt]}],"list-image":[{"list-image":["none",bt]}],"list-style-type":[{list:["none","disc","decimal",bt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[x]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[x]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",il,sc]}],"underline-offset":[{"underline-offset":["auto",il,bt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",bt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",bt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[x]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...F(),sde]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ide]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},ade]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[x]}],"border-style":[{border:[...H(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[x]}],"divide-style":[{divide:H()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...H()]}],"outline-offset":[{"outline-offset":[il,bt]}],"outline-w":[{outline:[il,sc]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[x]}],"ring-offset-w":[{"ring-offset":[il,sc]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",oc,lde]}],"shadow-color":[{shadow:[Bh]}],opacity:[{opacity:[x]}],"mix-blend":[{"mix-blend":[...B(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":B()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",oc,bt]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[O]}],saturate:[{saturate:[P]}],sepia:[{sepia:[j]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[O]}],"backdrop-opacity":[{"backdrop-opacity":[x]}],"backdrop-saturate":[{"backdrop-saturate":[P]}],"backdrop-sepia":[{"backdrop-sepia":[j]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",bt]}],duration:[{duration:q()}],ease:[{ease:["linear","in","out","in-out",bt]}],delay:[{delay:q()}],animate:[{animate:["none","spin","ping","pulse","bounce",bt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[R]}],"scale-x":[{"scale-x":[R]}],"scale-y":[{"scale-y":[R]}],rotate:[{rotate:[Fh,bt]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[X]}],"skew-y":[{"skew-y":[X]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",bt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",bt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",bt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[il,sc,zP]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},fde=LOe(dde);function oe(...t){return fde(NM(t))}const qR=jOe,gi=EOe,zi=zOe,Jr=$.forwardRef(({className:t,sideOffset:e=4,...n},r)=>d.jsx(VM,{ref:r,sideOffset:e,className:oe("z-50 overflow-hidden rounded-md border bg-bg-primary px-3 py-2 text-sm text-fg-primary shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));Jr.displayName=VM.displayName;var hde=Symbol.for("react.lazy"),Qv=dR[" use ".trim().toString()];function pde(t){return typeof t=="object"&&t!==null&&"then"in t}function IM(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===hde&&"_payload"in t&&pde(t._payload)}function MR(t){const e=mde(t),n=$.forwardRef((r,i)=>{let{children:s,...o}=r;IM(s)&&typeof Qv=="function"&&(s=Qv(s._payload));const a=$.Children.toArray(s),l=a.find($de);if(l){const c=l.props.children,u=a.map(O=>O===l?$.Children.count(c)>1?$.Children.only(null):$.isValidElement(c)?c.props.children:null:O);return d.jsx(e,{...o,ref:i,children:$.isValidElement(c)?$.cloneElement(c,void 0,u):null})}return d.jsx(e,{...o,ref:i,children:s})});return n.displayName=`${t}.Slot`,n}var kO=MR("Slot");function mde(t){const e=$.forwardRef((n,r)=>{let{children:i,...s}=n;if(IM(i)&&typeof Qv=="function"&&(i=Qv(i._payload)),$.isValidElement(i)){const o=Qde(i),a=yde(s,i.props);return i.type!==$.Fragment&&(a.ref=r?za(r,o):o),$.cloneElement(i,a)}return $.Children.count(i)>1?$.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var gde=Symbol("radix.slottable");function $de(t){return $.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===gde}function yde(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function Qde(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}const nY=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,rY=NM,IR=(t,e)=>n=>{var r;if(e?.variants==null)return rY(t,n?.class,n?.className);const{variants:i,defaultVariants:s}=e,o=Object.keys(i).map(c=>{const u=n?.[c],O=s?.[c];if(u===null)return null;const h=nY(u)||nY(O);return i[c][h]}),a=n&&Object.entries(n).reduce((c,u)=>{let[O,h]=u;return h===void 0||(c[O]=h),c},{}),l=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:O,className:h,...m}=u;return Object.entries(m).every(g=>{let[y,v]=g;return Array.isArray(v)?v.includes({...s,...a}[y]):{...s,...a}[y]===v})?[...c,O,h]:c},[]);return rY(t,o,l,n?.class,n?.className)},vde="disabled:text-fg-disabled disabled:pointer-events-none disabled:opacity-50 aria-disabled:text-fg-disabled aria-disabled:pointer-events-none aria-disabled:opacity-50",Wy="disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary aria-disabled:bg-bg-disabled aria-disabled:text-fg-disabled aria-disabled:border aria-disabled:border-border-primary",Sk=IR(oe("inline-flex items-center justify-center whitespace-nowrap rounded-md text-fg-primary text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",vde),{variants:{variant:{default:oe("cursor-pointer","border border-border-brand-primary","bg-bg-brand-primary text-fg-brand-primary","hover:bg-bg-brand-primary-hover hover:text-fg-brand-primary-hover",Wy),destructive:oe("cursor-pointer","border border-bg-error-primary","bg-bg-error-primary text-fg-error-primary hover:bg-bg-error-primary-hover disabled:text-fg-error-primary aria-disabled:text-fg-error-primary"),warning:oe("cursor-pointer","border border-bg-warning-secondary","bg-bg-warning-secondary text-fg-warning-secondary hover:bg-bg-warning-secondary-hover disabled:text-fg-warning-secondary aria-disabled:text-fg-warning-secondary"),outline:oe("cursor-pointer","border border-transparent","bg-bg-background hover:bg-bg-secondary",Wy),secondary:oe("cursor-pointer","border border-border-secondary","bg-bg-secondary text-fg-secondary hover:bg-bg-secondary-hover",Wy),ghost:oe("cursor-pointer","border border-transparent","bg-bg-background hover:bg-bg-secondary",Wy,"hover:bg-bg-secondary-hover hover:text-fg-secondary"),link:oe("cursor-pointer","border border-transparent","text-fg-primary underline-offset-4 hover:underline")},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",xs:"h-8 rounded-md px-2",lg:"h-11 rounded-md px-8",icon:"h-10 w-10","icon-sm":"h-8 w-8"}},defaultVariants:{variant:"default",size:"default"}}),Me=$.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,disabled:i,...s},o)=>{const a=r?kO:"button";return d.jsx(a,{className:oe(Sk({variant:e,size:n,className:t})),ref:o,disabled:i,"aria-disabled":i||void 0,...s})});Me.displayName="Button";function DM(t,e=[]){let n=[];function r(s,o){const a=$.createContext(o);a.displayName=s+"Context";const l=n.length;n=[...n,o];const c=O=>{const{scope:h,children:m,...g}=O,y=h?.[t]?.[l]||a,v=$.useMemo(()=>g,Object.values(g));return d.jsx(y.Provider,{value:v,children:m})};c.displayName=s+"Provider";function u(O,h){const m=h?.[t]?.[l]||a,g=$.useContext(m);if(g)return g;if(o!==void 0)return o;throw new Error(`\`${O}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=n.map(o=>$.createContext(o));return function(a){const l=a?.[t]||s;return $.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[r,xde(i,...e)]}function xde(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const O=l(s)[`__scope${c}`];return{...a,...O}},{});return $.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Sde=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ar=Sde.reduce((t,e)=>{const n=MR(`Primitive.${e}`),r=$.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),YP="focusScope.autoFocusOnMount",VP="focusScope.autoFocusOnUnmount",iY={bubbles:!1,cancelable:!0},bde="FocusScope",GM=$.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[a,l]=$.useState(null),c=Qr(i),u=Qr(s),O=$.useRef(null),h=ft(e,y=>l(y)),m=$.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;$.useEffect(()=>{if(r){let y=function(P){if(m.paused||!a)return;const R=P.target;a.contains(R)?O.current=R:fc(O.current,{select:!0})},v=function(P){if(m.paused||!a)return;const R=P.relatedTarget;R!==null&&(a.contains(R)||fc(O.current,{select:!0}))},x=function(P){if(document.activeElement===document.body)for(const j of P)j.removedNodes.length>0&&fc(a)};document.addEventListener("focusin",y),document.addEventListener("focusout",v);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",v),b.disconnect()}}},[r,a,m.paused]),$.useEffect(()=>{if(a){oY.add(m);const y=document.activeElement;if(!a.contains(y)){const x=new CustomEvent(YP,iY);a.addEventListener(YP,c),a.dispatchEvent(x),x.defaultPrevented||(Pde(Rde(LM(a)),{select:!0}),document.activeElement===y&&fc(a))}return()=>{a.removeEventListener(YP,c),setTimeout(()=>{const x=new CustomEvent(VP,iY);a.addEventListener(VP,u),a.dispatchEvent(x),x.defaultPrevented||fc(y??document.body,{select:!0}),a.removeEventListener(VP,u),oY.remove(m)},0)}}},[a,c,u,m]);const g=$.useCallback(y=>{if(!n&&!r||m.paused)return;const v=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,x=document.activeElement;if(v&&x){const b=y.currentTarget,[P,R]=wde(b);P&&R?!y.shiftKey&&x===R?(y.preventDefault(),n&&fc(P,{select:!0})):y.shiftKey&&x===P&&(y.preventDefault(),n&&fc(R,{select:!0})):x===b&&y.preventDefault()}},[n,r,m.paused]);return d.jsx(Ar.div,{tabIndex:-1,...o,ref:h,onKeyDown:g})});GM.displayName=bde;function Pde(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(fc(r,{select:e}),document.activeElement!==n)return}function wde(t){const e=LM(t),n=sY(e,t),r=sY(e.reverse(),t);return[n,r]}function LM(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function sY(t,e){for(const n of t)if(!kde(n,{upTo:e}))return n}function kde(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Tde(t){return t instanceof HTMLInputElement&&"select"in t}function fc(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&Tde(t)&&e&&t.select()}}var oY=Xde();function Xde(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=aY(t,e),t.unshift(e)},remove(e){t=aY(t,e),t[0]?.resume()}}}function aY(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function Rde(t){return t.filter(e=>e.tagName!=="A")}var _de="Portal",FM=$.forwardRef((t,e)=>{const{container:n,...r}=t,[i,s]=$.useState(!1);Sr(()=>s(!0),[]);const o=n||i&&globalThis?.document?.body;return o?RR.createPortal(d.jsx(Ar.div,{...r,ref:e}),o):null});FM.displayName=_de;var ZP=0;function vg(){$.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??lY()),document.body.insertAdjacentElement("beforeend",t[1]??lY()),ZP++,()=>{ZP===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),ZP--}},[])}function lY(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var $a=function(){return $a=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},$a.apply(this,arguments)};function BM(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function Cde(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var NQ="right-scroll-bar-position",AQ="width-before-scroll-bar",jde="with-scroll-bars-hidden",Ede="--removed-body-scroll-bar-size";function NP(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function zde(t,e){var n=$.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var Yde=typeof window<"u"?$.useLayoutEffect:$.useEffect,cY=new WeakMap;function Vde(t,e){var n=zde(null,function(r){return t.forEach(function(i){return NP(i,r)})});return Yde(function(){var r=cY.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(a){s.has(a)||NP(a,null)}),s.forEach(function(a){i.has(a)||NP(a,o)})}cY.set(n,t)},[t]),n}function Zde(t){return t}function Nde(t,e){e===void 0&&(e=Zde);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function Ade(t){t===void 0&&(t={});var e=Nde(null);return e.options=$a({async:!0,ssr:!1},t),e}var HM=function(t){var e=t.sideCar,n=BM(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return $.createElement(r,$a({},n))};HM.isSideCarExport=!0;function Wde(t,e){return t.useMedium(e),HM}var KM=Ade(),AP=function(){},OS=$.forwardRef(function(t,e){var n=$.useRef(null),r=$.useState({onScrollCapture:AP,onWheelCapture:AP,onTouchMoveCapture:AP}),i=r[0],s=r[1],o=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,u=t.enabled,O=t.shards,h=t.sideCar,m=t.noRelative,g=t.noIsolation,y=t.inert,v=t.allowPinchZoom,x=t.as,b=x===void 0?"div":x,P=t.gapMode,R=BM(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,X=Vde([n,e]),k=$a($a({},R),i);return $.createElement($.Fragment,null,u&&$.createElement(j,{sideCar:KM,removeScrollBar:c,shards:O,noRelative:m,noIsolation:g,inert:y,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:P}),o?$.cloneElement($.Children.only(a),$a($a({},k),{ref:X})):$.createElement(b,$a({},k,{className:l,ref:X}),a))});OS.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};OS.classNames={fullWidth:AQ,zeroRight:NQ};var Ude=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qde(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=Ude();return e&&t.setAttribute("nonce",e),t}function Mde(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function Ide(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var Dde=function(){var t=0,e=null;return{add:function(n){t==0&&(e=qde())&&(Mde(e,n),Ide(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Gde=function(){var t=Dde();return function(e,n){$.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},JM=function(){var t=Gde(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},Lde={left:0,top:0,right:0,gap:0},WP=function(t){return parseInt(t||"",10)||0},Fde=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[WP(n),WP(r),WP(i)]},Bde=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Lde;var e=Fde(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},Hde=JM(),Yd="data-scroll-locked",Kde=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
|
|
55
|
+
All routes will be filtered out due to malformed exclude pattern.`)}return t.filter(function(s){return!(e&&(!r||!r.test(s))||n&&(!i||i.test(s)))})}function Hle(t,e,n){if(e)try{var r=new RegExp(e.source,e.flags);if(!r.test(t))return{valid:!1,message:"Route '".concat(t,"' does not match include pattern: /").concat(e.source,"/").concat(e.flags)}}catch(s){return{valid:!1,message:"Invalid include pattern: ".concat(s instanceof Error?s.message:String(s))}}if(n)try{var i=new RegExp(n.source,n.flags);if(i.test(t))return{valid:!1,message:"Route '".concat(t,"' matches exclude pattern: /").concat(n.source,"/").concat(n.flags)}}catch(s){return{valid:!1,message:"Invalid exclude pattern: ".concat(s instanceof Error?s.message:String(s))}}return{valid:!0}}var Su="This is most likely a Val version mismatch or Val bug.";function Kle(t,e){var n=new Map;for(var r in t){var i=r,s=t[i],o=e[i];if(s&&s.type==="record"&&s.router&&o&&fi(o)==="object"&&!Array.isArray(o))for(var a in o)n.has(a)||n.set(a,i)}var l=Array.from(n.entries()).map(function(c){var u=Qm(c,2),O=u[0],h=u[1];return{route:O,moduleFilePath:h}});return l.sort(function(c,u){return c.route.localeCompare(u.route)})}var Jle=function(e,n){var r=[e.length,n.length],i=r[0],s=r[1];if(!i||!s)return Math.max(i,s);for(var o=Array.from({length:i+1},function(O,h){return h}),a=1;a<=s;a++){var l=o[0];o[0]=a;for(var c=1;c<=i;c++){var u=o[c];o[c]=e[c-1]===n[a-1]?l:Math.min(l+1,o[c-1]+1,o[c]+1),l=u}}return o[i]};function H4(t,e){return e.map(function(n){return{target:n,distance:Jle(t,n)}}).sort(function(n,r){return n.distance-r.distance})}function ece(t,e){var n=pe.splitModuleFilePathAndModulePath(t),r=Qm(n,2),i=r[0],s=r[1],o=e.sources[i],a=e.schemas[i];if(!a||o===void 0)return{source:void 0,schema:void 0};if(!s)return{source:o,schema:a};var l=o,c=a,u=nS(pe.splitModulePath(s)),O;try{for(u.s();!(O=u.n()).done;){var h=O.value;l&&fi(l)==="object"&&!Array.isArray(l)&&h in l?l=l[h]:l=void 0,c&&c.type==="object"&&c.items[h]?c=c.items[h]:c&&c.type==="record"?c=c.item:c=void 0}}catch(m){u.e(m)}finally{u.f()}return{source:l,schema:c}}function tce(t,e,n){var r=ece(e,n),i=r.source,s=r.schema;if(s&&s.type!=="record")return{error:!0,message:"Expected key at ".concat(e," to be of type 'record'")};if(i&&fi(i)==="object"&&!Array.isArray(i)&&t in i)return{error:!1};if(!i||fi(i)!=="object"||Array.isArray(i))return{error:!0,message:"Expected ".concat(e," to be a truthy object")};var o=H4(t,Object.keys(i));return o.length===0?{error:!0,message:"Key '".concat(t,"' does not exist in ").concat(e,".")}:{error:!0,message:"Key '".concat(t,"' does not exist in ").concat(e,". Closest match: '").concat(o[0].target,"'. Other similar: ").concat(o.slice(1,4).map(function(a){return"'".concat(a.target,"'")}).join(", ")).concat(o.length>4?", ...":"")}}function nce(t,e,n,r){var i={};for(var s in r.schemas){var o=s,a=r.schemas[o];if(a?.type==="record"&&a.router){var l=r.sources[o];l&&fi(l)==="object"&&!Array.isArray(l)&&(i[o]=Object.keys(l))}}for(var c=Object.entries(i),u=null,O=0,h=c;O<h.length;O++){var m=Qm(h[O],2),g=m[0],y=m[1];if(y.includes(t)){u=g;break}}if(!u){var v=c.flatMap(function(P){var R=Qm(P,2),j=R[1];return j});if(v.length===0)return{error:!0,message:"Route '".concat(t,"' could not be validated: No router modules found in the project. Use s.record(...).router(...) to define router modules.")};v=Ble(v,e,n);var x=H4(t,v);return{error:!0,message:"Route '".concat(t,"' does not exist in any router module. ").concat(x.length>0?"Closest match: '".concat(x[0].target,"'. Other similar: ").concat(x.slice(1,4).map(function(P){return"'".concat(P.target,"'")}).join(", ")).concat(x.length>4?", ...":""):"No similar routes found.")}}var b=Hle(t,e,n);return b.valid?{error:!1}:{error:!0,message:b.message}}function rce(t,e){var n,r=(n=t.fixes)!==null&&n!==void 0?n:[];if(r.includes("keyof:check-keys")){if(!t.value)return{status:"remaining",error:ur(ur({},t),{},{message:"Could not find a value for keyOf. ".concat(Su),typeError:!0,fixes:void 0})};if(fi(t.value)!=="object")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected keyOf validation error to have a 'value' property of type 'object'. Found: ".concat(fi(t.value),". ").concat(Su),typeError:!0,fixes:void 0})};var i=t.value,s=i.key,o=i.sourcePath;if(typeof s!="string")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ".concat(fi(s),". ").concat(Su),typeError:!0,fixes:void 0})};if(typeof o!="string")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ".concat(fi(o),". ").concat(Su),typeError:!0,fixes:void 0})};var a=tce(s,o,e);return a.error?{status:"remaining",error:ur(ur({},t),{},{message:a.message,fixes:void 0})}:{status:"resolved"}}if(r.includes("router:check-route")){if(!t.value)return{status:"remaining",error:ur(ur({},t),{},{message:"Could not find a value for route. ".concat(Su),typeError:!0,fixes:void 0})};if(fi(t.value)!=="object")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected route validation error to have a 'value' property of type 'object'. Found: ".concat(fi(t.value),". ").concat(Su),typeError:!0,fixes:void 0})};var l=t.value,c=l.route;if(typeof c!="string")return{status:"remaining",error:ur(ur({},t),{},{message:"Expected route validation error 'value' to have property 'route' of type 'string'. Found: ".concat(fi(c),". ").concat(Su),typeError:!0,fixes:void 0})};var u=Yz(l.include),O=Yz(l.exclude),h=nce(c,u,O,e);return h.error?{status:"remaining",error:ur(ur({},t),{},{message:h.message,fixes:void 0})}:{status:"resolved"}}return null}function Yz(t){if(t&&fi(t)==="object"&&"source"in t&&"flags"in t&&typeof t.source=="string"&&typeof t.flags=="string")return t}function K4(t,e){var n={};for(var r in t){var i=r,s=[],o=nS(t[i]),a;try{for(o.s();!(a=o.n()).done;){var l=a.value,c=rce(l,e);c===null?s.push(l):c.status==="remaining"&&s.push(c.error)}}catch(u){o.e(u)}finally{o.f()}s.length>0&&(n[i]=s)}return n}function Nu(t){return Array.isArray(t)}const J4=I().uuid().refine(t=>!0),ice=pg(["openai-gpt-5.1"]);D({id:I(),systemPrompt:I(),model:ice,tools:Ue(D({name:I(),description:I(),parameters:D({type:J("object"),properties:as(I(),oO()),required:Ue(I()).optional()})})).optional(),description:I().optional()});const sce=Ae([D({type:J("patches"),patches:Ue(J4)}),D({type:J("deployment"),deployment:F4}),D({type:J("commit"),commit:kR}),D({type:J("subscribed")})]);D({type:Ae([J("did-change"),J("no-change"),J("request-again"),J("use-websocket")]),profileId:I().nullable(),config:D({project:I().optional(),ai:D({chat:D({experimental:D({enable:Ve().optional()}).optional()}).optional()}).optional(),files:D({directory:I()}).optional()}),commitSha:I().optional(),sourcesSha:I(),schemaSha:I(),baseSha:I(),patches:Ue(J4),commits:Ue(kR).optional(),deployments:Ue(F4).optional(),mode:Ae([J("fs"),J("http")])});function oce(t){const[e,n]=$.useState({status:"not-asked"}),r=$.useRef(null),i=$.useRef(crypto.randomUUID()),{authenticationState:s,setAuthenticationLoadingIfNotAuthenticated:o,setIsAuthenticated:a}=ace(),[l,c]=$.useState(),u=$.useRef(0);return $.useEffect(()=>{if(e.status==="updated-request-again"||e.status==="error"||e.status==="ws-message-received")if(e.status==="error"&&console.error("Stat error",e.status,"error:",e.error),e.wait===0)console.debug("Executing stat immediately",e.status,e.status==="error"?e.error:"no error","Now:",Date.now()),TP(t,r,i,u,e,n,o,a,c);else{console.debug("Executing stat in ",e.wait," status: ",e.status,"Now:",Date.now());const O=setTimeout(()=>{TP(t,r,i,u,e,n,o,a,c)},e.wait);return()=>clearTimeout(O)}},[t,e]),$.useEffect(()=>{e.status==="not-asked"&&(n({status:"initializing"}),console.debug("Initializing stat"),TP(t,r,i,u,e,n,o,a,c))},[t,e.status]),[e,n,s,o,a,l]}const Gh=1200*1e3;async function TP(t,e,n,r,i,s,o,a,l){const c=++r.current;let u=null;return"data"in i&&i.data&&(u={schemaSha:i.data.schemaSha,sourcesSha:i.data.sourcesSha,baseSha:i.data.baseSha,patches:i.data.patches}),o(),t("/stat","POST",{body:u}).then(O=>{if(O.status===401){a("login-required");return}else a("authorized");if(O.status===503){l(!0),s(h=>({status:"error",error:"Service unavailable",retries:("retries"in h?h.retries:0)+1,waitStart:Date.now(),wait:5e3}));return}if(l(!1),!(r.current!==0&&r.current!==c))if(O.status===200){if(O.json.type==="did-change"||O.json.type==="no-change"||O.json.type==="request-again")s({status:"updated-request-again",data:O.json,waitStart:Date.now(),wait:e.current?Gh:0});else if(O.json.type==="use-websocket"){s(y=>({...y,status:"updated-request-again",data:O.json,waitStart:Date.now(),wait:Gh})),e.current&&(console.debug("Closing existing WebSocket"),e.current.close());const h=O.json.url;console.debug("Connecting to WebSocket",h),e.current=new WebSocket(h);const m=O.json.nonce;e.current.onopen=()=>{e.current?.send(JSON.stringify({nonce:m,type:"subscribe",connectionId:n.current}))},e.current.onmessage=y=>{try{const v=sce.safeParse(JSON.parse(y.data));if(!v.success){console.error("Could not parse WebSocket message",v.error);return}const x=v.data;x.type==="patches"?s(b=>"data"in b&&b.data?{status:"ws-message-received",data:{...b.data,patches:x.patches},waitStart:"waitStart"in b?b.waitStart:Date.now(),wait:"waitStart"in b?Math.max(0,Date.now()-b.waitStart):Gh}:b):x.type==="subscribed"?console.debug("Subscribed!"):x.type==="commit"?(console.debug("Commit",x.commit),s(b=>"data"in b&&b.data?{status:"ws-message-received",data:{...b.data,commits:(b.data.commits||[]).concat(x.commit)},waitStart:"waitStart"in b?b.waitStart:Date.now(),wait:"waitStart"in b?Math.max(0,Date.now()-b.waitStart):Gh}:b)):x.type==="deployment"?(console.debug("Deployment",x.deployment),s(b=>"data"in b&&b.data?{status:"ws-message-received",data:{...b.data,deployments:(b.data.deployments||[]).concat({commitSha:x.deployment.commitSha,deploymentId:x.deployment.deploymentId,deploymentState:x.deployment.deploymentState,createdAt:x.deployment.createdAt,updatedAt:x.deployment.updatedAt})},waitStart:"waitStart"in b?b.waitStart:Date.now(),wait:"waitStart"in b?Math.max(0,Date.now()-b.waitStart):Gh}:b)):console.warn("Unknown WebSocket message",x)}catch(v){console.error("Could not parse WebSocket message",v)}};const g=e.current;e.current.onclose=()=>{g===e.current&&(console.debug("WebSocket closed"),s(y=>Vy(y,"WebSocket closed")))},e.current.onerror=()=>{console.warn("WebSocket error"),s(y=>Vy(y,"Got an error while syncing with Val (reason: WebSocket error)"))}}}else s(h=>Vy(h,O.json.message))}).catch(O=>{r.current!==0&&r.current!==c||s(h=>Vy(h,O.message))})}function Vy(t,e){const n="retries"in t?t.retries+1:0,r=t.status==="error"&&t.retries>1?Math.min(500,t.retries*50+Math.floor(Math.random()*100))*10:0;return{status:"error",error:e,data:"data"in t?t.data:void 0,retries:n,waitStart:"waitStart"in t?t.waitStart:Date.now(),wait:r}}function ace(){const[t,e]=$.useState("not-asked"),n=$.useCallback(()=>{t==="not-asked"&&e("loading")},[t]);return{authenticationState:t,setIsAuthenticated:e,setAuthenticationLoadingIfNotAuthenticated:n}}function gp(t){if(t.type==="file")return!!t.remote;if(t.type==="image")return!!t.remote;if(t.type==="richtext")return!!(typeof t.options?.inline?.img!="boolean"&&t.options?.inline?.img?.remote);if(t.type==="array")return gp(t.item);if(t.type==="record")return t.mediaType&&t.remote?!0:gp(t.item);if(t.type==="union"){for(const e of t.items)if(gp(e))return!0;return!1}else if(t.type==="object"){for(const e in t.items)if(gp(t.items[e]))return!0;return!1}else{if(t.type==="boolean"||t.type==="number"||t.type==="string"||t.type==="date"||t.type==="dateTime"||t.type==="keyOf"||t.type==="route"||t.type==="literal")return!1;{const e=t;return console.error(`Val: requiresRemoteFiles: unexpected schema type ${typeof e=="object"&&"type"in e&&e.type}`,t),null}}}function zr(t){for(var e=t,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];for(var s=0,o=r;s<o.length;s++){var a=o[s];e=a(e)}return e}function eM(t){return hR(t)}function aO(t,e){if(t===e)return!0;if(Xe(t)==="object"&&Xe(e)==="object"&&t!==null&&e!==null){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;++n)if(!aO(t[n],e[n]))return!1;return!0}else if(!Array.isArray(t)&&!Array.isArray(e)){var r=Object.entries(t);if(r.length!==Object.keys(e).length)return!1;for(var i=0,s=r;i<s.length;i++){var o=xr(s[i],2),a=o[0],l=o[1],c=e[a];if(c===void 0||!aO(l,c))return!1}return!0}}return!1}function ji(t){return Array.isArray(t)?t.map(ji):Xe(t)==="object"&&t!==null?Object.fromEntries(Object.entries(t).map(function(e){var n=xr(e,2),r=n[0],i=n[1];return[r,ji(i)]})):t}function TR(t){return/^(0|[1-9][0-9]*)$/g.test(t)?ti(Number(t)):Qi(new Ms('Invalid array index "'.concat(t,'"')))}function lce(t,e){return t==="-"?ti(e.length):zr(TR(t),Fx(function(n){return n<=e.length},function(){return new Ms("Array index out of bounds")}))}function tM(t,e){return zr(TR(t),Fx(function(n){return n<e.length},function(){return new Ms("Array index out of bounds")}))}function cce(t,e,n){if(Array.isArray(t))return zr(tM(e,t),to(function(i){var s=t[i];return t[i]=n,s}));if(Xe(t)==="object"&&t!==null)if(Object.prototype.hasOwnProperty.call(t,e)){var r=t[e];return t[e]=n,ti(r)}else return Qi(new Ms("Cannot replace object element which does not exist"));return Qi(new Ms("Cannot replace in non-object/array"))}function uce(t,e,n){return eM(e)?zr(XR(t,e),iO(function(r){var i=xr(r,2),s=i[0],o=i[1];return cce(s,o,n)}),to(function(r){return[t,r]})):ti([n,t])}function nM(t,e){return Array.isArray(t)?zr(TR(e),iO(function(n){return n>=t.length?Qi(new Ms("Array index out of bounds")):ti(t[n])})):Xe(t)==="object"&&t!==null?Object.prototype.hasOwnProperty.call(t,e)?ti(t[e]):ti(void 0):Qi(new Ms("Cannot access non-object/array"))}function XR(t,e){for(var n=t,r=e[0],i=0;i<e.length-1;++i,r=e[i]){var s=nM(n,r);if(Lx(s))return s;if(s.value===void 0)return Qi(new Ms("Path refers to non-existing object/array"));n=s.value}return ti([n,r])}function XP(t,e){return zr(e,pR(function(n,r){return zr(nM(n,r),Fx(function(i){return i!==void 0},function(){return new Ms("Path refers to non-existing object/array")}))},t))}function Oce(t,e){if(Array.isArray(t))return zr(tM(e,t),to(function(r){var i=t.splice(r,1),s=xr(i,1),o=s[0];return o}));if(Xe(t)==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(t,e)){var n=t[e];return delete t[e],ti(n)}return Qi(new Ms("Cannot remove from non-object/array"))}function Vz(t,e){return zr(XR(t,e),iO(function(n){var r=xr(n,2),i=r[0],s=r[1];return Oce(i,s)}))}function dce(t,e,n){if(Array.isArray(t))return zr(lce(e,t),to(function(i){t.splice(i,0,n)}));if(Xe(t)==="object"&&t!==null){var r;return Object.prototype.hasOwnProperty.call(t,e)&&(r=t[e]),t[e]=n,ti(r)}return Qi(new Ms("Cannot add to non-object/array"))}function RP(t,e,n){return eM(e)?zr(XR(t,e),iO(function(r){var i=xr(r,2),s=i[0],o=i[1];return dce(s,o,n)}),to(function(r){return[t,r]})):ti([n,t])}function Zy(t){var e=xr(t,1),n=e[0];return n}var fce=(function(){function t(){wr(this,t)}return kr(t,[{key:"get",value:function(n,r){return XP(n,r)}},{key:"add",value:function(n,r,i){return zr(RP(n,r,i),to(Zy))}},{key:"remove",value:function(n,r){return zr(Vz(n,r),to(function(){return n}))}},{key:"replace",value:function(n,r,i){return zr(uce(n,r,i),to(Zy))}},{key:"move",value:function(n,r,i){return zr(Vz(n,r),iO(function(s){return RP(n,i,s)}),to(Zy))}},{key:"copy",value:function(n,r,i){return zr(XP(n,r),iO(function(s){return RP(n,i,ji(s))}),to(Zy))}},{key:"test",value:function(n,r,i){return zr(XP(n,r),to(function(s){return aO(i,s)}))}}])})();function hce(t,e,n){switch(n.op){case"add":return e.add(t,n.path,n.value);case"remove":return e.remove(t,n.path);case"replace":return e.replace(t,n.path,n.value);case"move":return e.move(t,n.from,n.path);case"copy":return e.copy(t,n.from,n.path);case"test":return e.test(t,n.path,n.value)?ti(t):Qi(new Ms("Test failed"));case"file":return Qi(new Ms("Cannot apply a file patch here"))}}function _P(t,e,n){return zr(n,pR(function(r,i){return hce(r,e,i)},t))}function pce(t,e){return!t||!e?!1:t.length===1&&t[0].op==="replace"&&e.length===1&&e[0].op==="replace"?t[0].path.join("/")===e[0].path.join("/"):!1}function gd(t,e){if(!e||e.length===0)return new Set([t.type]);const n=new Set;let r=t,i=-1;for(const s of e){if(i++,!r)break;if(r.type==="array")r=r.item;else if(r.type==="record")r=r.item;else if(r.type==="object")r=r.items[s];else{if(r.type==="richtext")break;if(r.type==="union")if(typeof r.key=="string"){const o=r.items;for(const a of o){const l=gd(a,e.slice(i));for(const c of Array.from(l.values()))n.add(c)}return n}else{if(i!==e.length-1)throw new Error("Found string union (primitive), but path has more parts: "+e.join("/")+" at "+s);break}else if(r.type==="boolean"||r.type==="number"||r.type==="string"||r.type==="date"||r.type==="dateTime"||r.type==="file"||r.type==="image"||r.type==="keyOf"||r.type==="route"||r.type==="literal"){if((r.type==="image"||r.type==="file")&&e[i]==="metadata")break;if(i!==e.length-1)throw new Error("Found "+r.type+" (primitive), but path has more parts: "+e.join("/")+" at "+s);break}else{const a=r.type;return console.error(`Unexecpted resolved schema type: ${a} in ${e.join("/")} at ${s}`),new Set([a])}}}return r&&(n.add(r.type),r.type==="union"&&(typeof r.key=="string"?n.add("object"):n.add("string"))),n}class Lh{constructor(){this.patchSetMetadata={},this.orderedInsertKeys=[],this.insertedPatches=new Set}reset(){this.patchSetMetadata={},this.orderedInsertKeys=[],this.insertedPatches=new Set}getInsertedPatches(){return this.insertedPatches}insertPath(e,n,r,i,s,o,a,l){let c=n.length>0?`${e}?${n.join("/")}`:e;const u=[];for(let O=this.orderedInsertKeys.length-1;O>=0;O--){const h=this.orderedInsertKeys[O];c!==h?c.startsWith(h)?(c=h,this.orderedInsertKeys.splice(O,1),this.orderedInsertKeys.unshift(c)):h.startsWith(c)&&u.push(O):(this.orderedInsertKeys.splice(O,1),this.orderedInsertKeys.unshift(c))}for(const O of u){const h=this.orderedInsertKeys[O];this.orderedInsertKeys.splice(O,1);const m=this.patchSetMetadata[h];if(this.patchSetMetadata[c]||(this.patchSetMetadata[c]={moduleFilePath:e,patchPath:n,patches:[],authors:[],opTypes:[],schemaTypes:Array.from(a),lastUpdated:i,lastUpdatedBy:s}),m)for(const g of m.patches.slice())this.patchSetMetadata[c].patches.unshift(g),g.author!==null&&this.patchSetMetadata[c].authors.unshift(g.author),this.patchSetMetadata[c].opTypes.unshift(g.opType);else throw new Error(`Could not find patch set metadata or patch metadata for (inserted) patch set path: ${h}`);h!==c&&delete this.patchSetMetadata[h]}this.patchSetMetadata[c]||(this.patchSetMetadata[c]={moduleFilePath:e,patchPath:n,patches:[],authors:[],opTypes:[],schemaTypes:a,lastUpdated:i,lastUpdatedBy:s}),s!==null&&!this.patchSetMetadata[c].authors.includes(s)&&this.patchSetMetadata[c].authors.unshift(s),this.patchSetMetadata[c].lastUpdatedBy=s,this.patchSetMetadata[c].lastUpdated=i,this.patchSetMetadata[c].opTypes.includes(o)||this.patchSetMetadata[c].opTypes.unshift(o),this.patchSetMetadata[c].patches.unshift({patchPath:l,patchId:r,author:s,createdAt:i,opType:o,schemaTypes:a}),this.orderedInsertKeys.includes(c)||this.orderedInsertKeys.unshift(c)}insert(e,n,r,i,s,o){if(!this.insertedPatches.has(i)){if(!n){this.insertPath(e,[],i,s,o,r.op,[],r.path);return}if(this.insertedPatches.add(i),!(r.op==="file"||r.op==="test"))try{if(r.op==="replace"){const a=gd(n,r.path);this.insertPath(e,r.path,i,s,o,r.op,Array.from(a),r.path)}else if(r.op==="add"||r.op==="remove"||r.op==="move"||r.op==="copy"){const a=r.path.slice(0,-1),l=gd(n,a);if(l.size===1&&l.has("array")){if(this.insertPath(e,a,i,s,o,r.op,Array.from(l),r.path),r.op==="move"){const c=r.from.slice(0,-1),u=gd(n,c);this.insertPath(e,c,i,s,o,r.op,Array.from(u),r.path)}}else if(l.size===1&&l.has("record")){const c=r.path,u=gd(n,c);if(this.insertPath(e,c,i,s,o,r.op,Array.from(u),r.path),r.op==="move"){const O=r.from,h=gd(n,O);this.insertPath(e,O,i,s,o,r.op,Array.from(h),r.path)}}else{if(l.size===1&&!(l.has("image")||l.has("file")))throw new Error(`Cannot perform op: '${r.op}' on non-array or non-record schema. Type: ${l.values().next().value}`);this.insertPath(e,a,i,s,o,r.op,[n.type],r.path)}}else{const a=r;throw new Error("Unreachable op: "+a)}}catch(a){a instanceof Error?console.error("Could not resolve path while creating patch set",a.message):console.error("Could not resolve path while creating patch set",a),this.insertPath(e,[],i,s,o,r.op,[n.type],r.path)}}}isInserted(e){return this.insertedPatches.has(e)}serialize(){return this.orderedInsertKeys.map(e=>{if(e in this.patchSetMetadata)return this.patchSetMetadata[e];throw new Error(`Could not find patch set metadata or patch metadata for (inserted) patch set path: ${e}`)})}}const mce="modulepreload",gce=function(t){return"/api/val/static/"+t},Zz={},$ce=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let l=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(O=>({status:"fulfilled",value:O}),O=>({status:"rejected",reason:O}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=o?.nonce||o?.getAttribute("nonce");i=l(n.map(c=>{if(c=gce(c),c in Zz)return;Zz[c]=!0;const u=c.endsWith(".css"),O=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${O}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":mce,u||(h.as="script"),h.crossOrigin="",h.href=c,a&&h.setAttribute("nonce",a),document.head.appendChild(h),u)return new Promise((m,g)=>{h.addEventListener("load",m),h.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})},Nz=typeof window<"u"&&typeof Worker<"u";class yce{constructor(e){this.onResult=e,this.worker=null,this.pending=Nz?[]:null,this.requestIdCounter=0,this.disposed=!1,this.latestRequestId=new Map,this.fallbackSchemaCache=new Map,Nz&&this.setupWorker()}async setupWorker(){try{const{createValidationWorker:e}=await $ce(async()=>{const{createValidationWorker:i}=await import("./createValidationWorker-Cu4Zom1o.js");return{createValidationWorker:i}},[]),n=e();if(this.disposed){n.terminate();return}n.onmessage=i=>{const s=i.data;this.latestRequestId.get(s.moduleFilePath)===s.id&&(s.type==="result"?this.onResult(s.moduleFilePath,s.errors):(console.error("Validation worker error:",s.moduleFilePath,s.error),this.onResult(s.moduleFilePath,!1)))},n.onerror=i=>{console.error("Validation worker crashed:",i.message)},this.worker=n;const r=this.pending;if(this.pending=null,r)for(const i of r)this.latestRequestId.get(i.moduleFilePath)===i.id&&n.postMessage(i)}catch(e){console.error("Failed to create validation worker:",e instanceof Error?e.message:String(e)),this.pending=null}}validate(e,n,r,i){const s=`val-${this.requestIdCounter++}`;this.latestRequestId.set(e,s);const o={type:"validate",id:s,moduleFilePath:e,schemaSha:i,serializedSchema:r,source:n};if(this.worker){this.worker.postMessage(o);return}if(this.pending){this.pending=this.pending.filter(a=>a.moduleFilePath!==e),this.pending.push(o);return}try{let a=this.fallbackSchemaCache.get(e);(!a||a.schemaSha!==i)&&(a={schemaSha:i,schema:Eo(r)},this.fallbackSchemaCache.set(e,a));const l=a.schema.executeValidate(e,n);this.onResult(e,l)}catch(a){console.error("Validation fallback failed:",e,a instanceof Error?a.message:String(a)),this.onResult(e,!1)}}dispose(){this.disposed=!0,this.worker&&(this.worker.terminate(),this.worker=null),this.pending=null,this.latestRequestId.clear(),this.fallbackSchemaCache.clear()}}function rM(t){const e={},n={};for(const r in t){const i=r;for(const s of t[i])Qce(s)?(n[i]??(n[i]=[])).push(s):(e[i]??(e[i]=[])).push(s)}return{surfaced:e,skipped:n}}function Qce(t){const e=t.fixes??[];return e.length===0?!1:e.every(vce)}function vce(t){switch(t){case"image:add-metadata":case"image:check-metadata":case"image:upload-remote":case"image:download-remote":case"image:check-remote":case"images:check-remote":case"file:add-metadata":case"file:check-metadata":case"file:upload-remote":case"file:download-remote":case"file:check-remote":case"files:check-remote":case"images:check-unique-folder":case"files:check-unique-folder":case"images:check-all-files":case"files:check-all-files":return!0;case"keyof:check-keys":case"router:check-route":return!1;default:return!1}}class xce{constructor(e,n=void 0){this.client=e,this.overlayEmitter=n,this.autoPublish=!1,this.setValModulesSeq=0,this.multipleSourcesSep="|",this.isSyncing=!1,this.MIN_WAIT_SECONDS=1,this.MAX_WAIT_SECONDS=5,this.initializedAt=null,this.forceSyncAllModules=!0,this.errors={},this.listeners={},this.syncStatus={},this.schemas=null,this.serverSideSchemaSha=null,this.clientSideSchemaSha=null,this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"absent"},this.schemaOutOfDate=!1,this.baseSha=null,this.sourcesSha=null,this.mode=null,this.serverSources=null,this.patchedSourcesCache=null,this.renders=null,this.globalServerSidePatchIds=[],this.syncedServerSidePatchIds=[],this.savedButNotYetGlobalServerSidePatchIds=[],this.patchIdsByCreatorId=new Map,this.patchIdsByModuleFilePath=new Map,this.pendingOps=[],this.pendingClientPatchIds=[],this.patchDataByPatchId={},this.isSyncing=!1,this.patchSets=new Lh,this.authorId=null,this.publishDisabled=!0,this.isPublishing=!1,this.commitSha=null,this.cachedSourceSnapshots=null,this.cachedServerSourceSnapshots=null,this.cachedBaseSourceSnapshots=null,this.cachedSchemaSnapshots=null,this.cachedRenderSnapshots=null,this.cachedPatchData=null,this.cachedSerializedPatchSetsSnapshot=null,this.cachedValidationErrors=null,this.cachedAllSchemasSnapshot=null,this.cachedDeserializedSchemas=null,this.cachedGlobalServerSidePatchIdsSnapshot=null,this.cachedPendingClientSidePatchIdsSnapshot=null,this.cachedSyncedServerSidePatchIdsSnapshot=null,this.cachedSavedServerSidePatchIdsSnapshot=null,this.cachedAllSourcesSnapshot=null,this.cachedAllRendersSnapshot=null,this.cachedSourcesSnapshot=null,this.cachedSyncStatus=null,this.cachedPendingOpsCountSnapshot=null,this.cachedInitializedAtSnapshot=null,this.cachedAutoPublishSnapshot=null,this.cachedPublishDisabledSnapshot=null,this.cachedSchemaOutOfDateSnapshot=null,this.cachedLocalModulesStatusSnapshot=null,this.cachedGlobalTransientErrorSnapshot=null,this.cachedParentRef=void 0,this.cachedPatchErrorsSnapshot=null,this.validationWorker=null}setAutoPublish(e,n){this.autoPublish=n;try{localStorage.setItem("val-auto-publish",n.toString())}catch{}return this.invalidateAutoPublish(),this.sync(e)}loadAutoPublish(){try{this.autoPublish=localStorage.getItem("val-auto-publish")==="true",this.invalidateAutoPublish()}catch{}}async init(e,n,r,i,s,o,a,l){this.mode=e,this.baseSha=n,this.commitSha=a,this.authorId=o;const c=Date.now();e==="fs"?this.loadAutoPublish():this.autoPublish=!1;const u=await this.syncWithUpdatedStat(e,n,r,i,s,o,a,l);return u.status==="done"&&(await this.syncPatches(!0,l),this.publishDisabled=!1,this.invalidatePublishDisabled(),this.initializedAt=l+(Date.now()-c),this.invalidateInitializedAt()),u}reset(){console.debug("Resetting ValSyncEngine"),this.initializedAt=null,this.forceSyncAllModules=!0,this.errors={},this.listeners={},this.syncStatus={},this.schemas=null,this.serverSideSchemaSha=null,this.clientSideSchemaSha=null,this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"absent"},this.schemaOutOfDate=!1,this.sourcesSha=null,this.serverSources=null,this.patchedSourcesCache=null,this.renders=null,this.globalServerSidePatchIds=[],this.syncedServerSidePatchIds=[],this.savedButNotYetGlobalServerSidePatchIds=[],this.patchIdsByCreatorId=new Map,this.patchIdsByModuleFilePath=new Map,this.pendingOps=[],this.pendingClientPatchIds=[],this.patchDataByPatchId={},this.isSyncing=!1,this.patchSets=new Lh,this.authorId=null,this.publishDisabled=!0,this.isPublishing=!1,this.commitSha=null,this.cachedSourceSnapshots=null,this.cachedServerSourceSnapshots=null,this.cachedBaseSourceSnapshots=null,this.cachedSchemaSnapshots=null,this.cachedRenderSnapshots=null,this.cachedPatchData=null,this.cachedSerializedPatchSetsSnapshot=null,this.cachedValidationErrors=null,this.cachedAllSchemasSnapshot=null,this.cachedDeserializedSchemas=null,this.cachedGlobalServerSidePatchIdsSnapshot=null,this.cachedPendingClientSidePatchIdsSnapshot=null,this.cachedSyncedServerSidePatchIdsSnapshot=null,this.cachedSavedServerSidePatchIdsSnapshot=null,this.cachedAllSourcesSnapshot=null,this.cachedAllRendersSnapshot=null,this.cachedSyncStatus=null,this.cachedPendingOpsCountSnapshot=null,this.cachedInitializedAtSnapshot=null,this.cachedAutoPublishSnapshot=null,this.cachedPublishDisabledSnapshot=null,this.cachedSchemaOutOfDateSnapshot=null,this.cachedLocalModulesStatusSnapshot=null,this.cachedGlobalTransientErrorSnapshot=null,this.cachedParentRef=void 0,this.cachedPatchErrorsSnapshot=null,this.validationWorker?.dispose(),this.validationWorker=null,this.invalidateInitializedAt()}subscribe(e,n){const r=n||xn;return i=>{const s=this.listeners;if(s[e]||(s[e]={}),Array.isArray(r)){const o=[];for(const a of r){s[e][a]||(s[e][a]=[]);const l=s[e][a].push(i)-1;o.push(l)}return()=>{for(const a of o)s[e]?.[r[a]]?.splice(a,1)}}else{s[e][r]||(s[e][r]=[]);const o=s[e][r].push(i)-1;return()=>{s[e]?.[r].splice(o,1)}}}}emit(e){if(e)for(const n of e)n()}setCommitSha(e){this.commitSha=e}invalidateInitializedAt(){this.cachedInitializedAtSnapshot=null,this.emit(this.listeners["initialized-at"]?.[xn])}invalidateSource(e){if(this.cachedSourceSnapshots!==null){const n=[];for(const r in this.cachedSourceSnapshots)(r===e||r.startsWith(e+"\0"))&&n.push(r);if(n.length>0){const r={...this.cachedSourceSnapshots};for(const i of n)delete r[i];this.cachedSourceSnapshots=r}}this.cachedServerSourceSnapshots!==null&&(this.cachedServerSourceSnapshots={...this.cachedServerSourceSnapshots,[e]:void 0}),this.cachedBaseSourceSnapshots!==null&&(this.cachedBaseSourceSnapshots={...this.cachedBaseSourceSnapshots,[e]:void 0}),this.invalidatePatchedSourcesCache(e),this.cachedAllSourcesSnapshot=null,this.cachedSourcesSnapshot=null,this.cachedValidationErrors=null,this.emit(this.listeners.sources?.[e]),this.emit(this.listeners.source?.[e]),this.emit(this.listeners["all-sources"]?.[xn]),this.emit(this.listeners["all-validation-errors"]?.[xn])}invalidatePatchErrors(e){this.cachedPatchErrorsSnapshot=null,this.emit(this.listeners["patch-errors"]?.[e])}invalidateRenders(e){this.cachedSourceSnapshots===null&&(this.cachedSourceSnapshots={}),this.cachedRenderSnapshots={...this.cachedRenderSnapshots,[e]:null},this.cachedAllRendersSnapshot=null,this.emit(this.listeners.render?.[e]),this.emit(this.listeners["all-renders"]?.[xn])}invalidateSyncStatus(e){this.cachedSyncStatus={...this.cachedSyncStatus,[e]:void 0},this.emit(this.listeners["sync-status"]?.[e])}invalidateValidationError(e){this.emit(this.listeners["validation-error"]?.[e])}invalidateAllValidationErrors(){this.cachedValidationErrors=null,this.emit(this.listeners["all-validation-errors"]?.[xn])}invalidateGlobalTransientErrors(){this.cachedGlobalTransientErrorSnapshot=null,this.emit(this.listeners["global-transient-errors"]?.[xn])}invalidateNetworkError(){this.cachedNetworkErrorSnapshot=void 0,this.emit(this.listeners["network-error"]?.[xn])}invalidateSchemaError(){this.cachedSchemaErrorSnapshot=void 0,this.emit(this.listeners["schema-error"]?.[xn])}invalidatePatchSets(){this.cachedSerializedPatchSetsSnapshot=null,this.emit(this.listeners["patch-sets"]?.[xn])}invalidatePendingOps(){this.cachedPendingOpsCountSnapshot=null,this.emit(this.listeners["pending-ops-count"]?.[xn])}invalidateAllPatches(){this.cachedPatchData=null,this.emit(this.listeners["all-patches"]?.[xn])}invalidateSchema(){this.cachedAllSchemasSnapshot=null,this.cachedDeserializedSchemas=null,this.cachedSchemaSnapshots=null,this.cachedAllSourcesSnapshot=null,this.emit(this.listeners.schema?.[xn]),this.invalidateAllValidationErrors();for(const e in this.listeners?.["validation-error"]||{}){const n=e;this.invalidateValidationError(n)}}invalidateParentRef(){this.cachedParentRef=void 0,this.emit(this.listeners["parent-ref"]?.[xn])}invalidateGlobalServerSidePatchIds(){this.cachedGlobalServerSidePatchIdsSnapshot=null,this.invalidateParentRef(),this.emit(this.listeners["global-server-side-patch-ids"]?.[xn])}invalidatePendingClientSidePatchIds(){this.cachedPendingClientSidePatchIdsSnapshot=null,this.emit(this.listeners["pending-client-side-patch-ids"]?.[xn])}invalidateSyncedServerSidePatchIds(){this.cachedSyncedServerSidePatchIdsSnapshot=null,this.emit(this.listeners["synced-server-side-patch-ids"]?.[xn])}invalidateSavedServerSidePatchIds(){this.cachedSavedServerSidePatchIdsSnapshot=null,this.invalidateParentRef(),this.emit(this.listeners["saved-server-side-patch-ids"]?.[xn])}invalidatePublishDisabled(){this.cachedPublishDisabledSnapshot=null,this.emit(this.listeners["publish-disabled"]?.[xn])}invalidateSchemaOutOfDate(){this.cachedSchemaOutOfDateSnapshot=null,this.emit(this.listeners["schema-out-of-date"]?.[xn])}invalidateLocalModulesStatus(){this.cachedLocalModulesStatusSnapshot=null,this.emit(this.listeners["local-modules-status"]?.[xn])}invalidateAutoPublish(){this.cachedAutoPublishSnapshot=null,this.emit(this.listeners["auto-publish"]?.[xn])}getSchemaSnapshot(e){if(this.cachedSchemaSnapshots===null&&(this.cachedSchemaSnapshots={}),this.cachedSchemaSnapshots[e]===void 0)if(!this.schemas)this.cachedSchemaSnapshots[e]={status:"no-schemas"};else{const n=this.schemas[e];n?this.cachedSchemaSnapshots[e]={status:"success",data:ji(n)}:this.cachedSchemaSnapshots[e]={status:"module-schema-not-found"}}return this.cachedSchemaSnapshots[e]}getRenderSnapshot(e){return this.cachedRenderSnapshots===null&&(this.cachedRenderSnapshots={}),this.cachedRenderSnapshots[e]===null&&(this.cachedRenderSnapshots[e]=this.renders?.[e]||null),this.cachedRenderSnapshots[e]}orderedPatchIdsForModule(e){const n=[],r=this.patchIdsByModuleFilePath.get(e);if(!r||r.size===0)return n;const i=s=>{r.has(s)&&this.patchDataByPatchId[s]&&n.push(s)};if(this.globalServerSidePatchIds)for(const s of this.globalServerSidePatchIds)i(s);for(const s of this.savedButNotYetGlobalServerSidePatchIds)i(s);for(const s of this.pendingClientPatchIds)i(s);return n}getPatchedSource(e){const n=this.serverSources?.[e];if(n===void 0)return;const r=this.orderedPatchIdsForModule(e);if(r.length===0)return n;this.patchedSourcesCache===null&&(this.patchedSourcesCache={});const i=this.patchedSourcesCache[e];let s,o;if(i&&this.isPrefix(i.patchIds,r)){if(i.source===void 0)return;if(s=i.source,o=i.patchIds.length,o===r.length)return s}else s=n,o=0;let a=o,l=s,c=!0;for(let u=o;u<r.length;u++){const O=r[u],h=this.patchDataByPatchId[O];if(!h){c=!1;continue}const m=h.patch.filter(y=>y.op!=="file");if(m.length===0){c&&(a=u+1,l=s);continue}const g=_P(ji(s),CP,m);SP.isOk(g)?(s=g.value,c&&(a=u+1,l=s)):(c=!1,console.debug("ValSyncEngine: skipping unappliable client-side patch",{patchId:O,moduleFilePath:e,message:g.error.message}))}return this.patchedSourcesCache[e]={patchIds:r.slice(0,a),source:l},s}isPrefix(e,n){if(e.length>n.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}invalidatePatchedSourcesCache(e){this.patchedSourcesCache!==null&&(e===void 0?this.patchedSourcesCache=null:this.patchedSourcesCache={...this.patchedSourcesCache,[e]:void 0})}getSourceSnapshot(e,n){this.cachedSourceSnapshots===null&&(this.cachedSourceSnapshots={});const r=n?`${e}\0${n}`:e;if(this.cachedSourceSnapshots[r]===void 0){const i=this.getPatchedSource(e);this.schemas===null?this.cachedSourceSnapshots[r]={status:"no-schemas"}:this.schemas[e]?i===void 0?this.cachedSourceSnapshots[r]={status:"source-not-found"}:this.cachedSourceSnapshots[r]={status:"success",data:ji(i),optimistic:this.isEditedByComponent(e,n)}:this.cachedSourceSnapshots[r]={status:"schema-not-found"}}return this.cachedSourceSnapshots[r]}getServerSourceSnapshot(e){if(this.cachedServerSourceSnapshots===null&&(this.cachedServerSourceSnapshots={}),this.cachedServerSourceSnapshots[e]===void 0)if(this.schemas===null)this.cachedServerSourceSnapshots[e]={status:"no-schemas"};else if(!this.schemas[e])this.cachedServerSourceSnapshots[e]={status:"schema-not-found"};else{const n=this.serverSources?.[e];n===void 0?this.cachedServerSourceSnapshots[e]={status:"source-not-found"}:this.cachedServerSourceSnapshots[e]={status:"success",data:ji(n)}}return this.cachedServerSourceSnapshots[e]}getBaseSourceSnapshot(e){if(this.cachedBaseSourceSnapshots===null&&(this.cachedBaseSourceSnapshots={}),this.cachedBaseSourceSnapshots[e]===void 0)if(this.schemas===null)this.cachedBaseSourceSnapshots[e]={status:"no-schemas"};else if(!this.schemas[e])this.cachedBaseSourceSnapshots[e]={status:"schema-not-found"};else{const n=this.serverSources?.[e];n===void 0?this.cachedBaseSourceSnapshots[e]={status:"source-not-found"}:this.cachedBaseSourceSnapshots[e]={status:"success",data:ji(n)}}return this.cachedBaseSourceSnapshots[e]}getAllSourcesSnapshot(){if(this.cachedAllSourcesSnapshot===null){this.cachedAllSourcesSnapshot={};for(const e in this.schemas||{}){const n=e,r=this.getPatchedSource(n);r!==void 0&&(this.cachedAllSourcesSnapshot[n]=ji(r))}}return this.cachedAllSourcesSnapshot}getAllRendersSnapshot(){if(this.cachedAllRendersSnapshot===null&&(this.cachedAllRendersSnapshot={},this.renders))for(const e in this.renders){const n=e;this.cachedAllRendersSnapshot[n]=this.renders[n]}return this.cachedAllRendersSnapshot}getSourcesSnapshot(e){const n=e.sort().map(r=>r+this.multipleSourcesSep).join(this.multipleSourcesSep);if(this.cachedSourcesSnapshot===null&&(this.cachedSourcesSnapshot={}),this.cachedSourcesSnapshot[n]===void 0)for(const r of e){const i=this.getPatchedSource(r);i!==void 0&&(this.cachedSourcesSnapshot[n]=[...this.cachedSourcesSnapshot[n]||[],ji(i)])}return this.cachedSourcesSnapshot[n]}getAllSchemasSnapshot(){this.cachedAllSchemasSnapshot===null&&(this.cachedAllSchemasSnapshot={});for(const e in this.schemas||{}){const n=e,r=this.schemas?.[n];r&&(this.cachedAllSchemasSnapshot[n]=ji(r))}return this.cachedAllSchemasSnapshot}getValidationErrorSnapshot(e){return this.getAllValidationErrorsSnapshot()?.[e]}getAllValidationErrorsSnapshot(){if(!this.cachedValidationErrors){const e={},n=this.errors.validationErrors||{};for(const s in n){const o=s,a=[];for(const l of n[o]||[])l&&a.push(l);a.length>0&&(e[o]=a)}const r=K4(e,{schemas:this.getAllSchemasSnapshot(),sources:this.getAllSourcesSnapshot()}),{surfaced:i}=rM(r);this.cachedValidationErrors=i}return this.cachedValidationErrors}getSyncStatusSnapshot(e){return this.cachedSyncStatus===null&&(this.cachedSyncStatus={}),this.cachedSyncStatus[e]===void 0&&(this.cachedSyncStatus[e]=this.syncStatus[e]||null),this.cachedSyncStatus[e]}getPendingOpsSnapshot(){return this.cachedPendingOpsCountSnapshot===null&&(this.cachedPendingOpsCountSnapshot=this.pendingOps.length),this.cachedPendingOpsCountSnapshot}getSerializedPatchSetsSnapshot(){return this.cachedSerializedPatchSetsSnapshot||(this.cachedSerializedPatchSetsSnapshot=this.patchSets.serialize()),this.cachedSerializedPatchSetsSnapshot}getInitializedAtSnapshot(){return this.cachedInitializedAtSnapshot===null&&(this.cachedInitializedAtSnapshot={data:this.initializedAt}),this.cachedInitializedAtSnapshot}getPatchErrorsSnapshot(e){const n=e.sort().join("|");if(this.cachedPatchErrorsSnapshot===null){this.cachedPatchErrorsSnapshot={};const r={};let i=!1;for(const s of e)this.errors.patchErrors?.[s]&&(r[s]={...r[s]||{},...ji(this.errors.patchErrors[s])},i=!0);i&&(this.cachedPatchErrorsSnapshot[n]=r)}return this.cachedPatchErrorsSnapshot[n]}getAllPatchesSnapshot(){if(!this.cachedPatchData){this.cachedPatchData={};for(const e in this.patchDataByPatchId){const n=e,r=this.patchDataByPatchId[n];r&&(this.cachedPatchData[n]=ji(r))}}return this.cachedPatchData}getGlobalServerSidePatchIdsSnapshot(){return this.cachedGlobalServerSidePatchIdsSnapshot===null&&(this.cachedGlobalServerSidePatchIdsSnapshot=this.globalServerSidePatchIds?.slice()||[]),this.cachedGlobalServerSidePatchIdsSnapshot}getPendingClientSidePatchIdsSnapshot(){return this.cachedPendingClientSidePatchIdsSnapshot===null&&(this.cachedPendingClientSidePatchIdsSnapshot=this.pendingClientPatchIds?.slice()||[]),this.cachedPendingClientSidePatchIdsSnapshot}getSyncedServerSidePatchIdsSnapshot(){return this.cachedSyncedServerSidePatchIdsSnapshot===null&&(this.cachedSyncedServerSidePatchIdsSnapshot=this.syncedServerSidePatchIds?.slice()||[]),this.cachedSyncedServerSidePatchIdsSnapshot}getSavedServerSidePatchIdsSnapshot(){return this.cachedSavedServerSidePatchIdsSnapshot===null&&(this.cachedSavedServerSidePatchIdsSnapshot=this.savedButNotYetGlobalServerSidePatchIds?.slice()||[]),this.cachedSavedServerSidePatchIdsSnapshot}getPublishDisabledSnapshot(){return this.cachedPublishDisabledSnapshot===null&&(this.cachedPublishDisabledSnapshot=this.publishDisabled),this.cachedPublishDisabledSnapshot}getSchemaOutOfDateSnapshot(){return this.cachedSchemaOutOfDateSnapshot===null&&(this.cachedSchemaOutOfDateSnapshot=this.schemaOutOfDate),this.cachedSchemaOutOfDateSnapshot}getLocalModulesStatusSnapshot(){return this.cachedLocalModulesStatusSnapshot===null&&(this.cachedLocalModulesStatusSnapshot=this.localModulesStatus),this.cachedLocalModulesStatusSnapshot}getAutoPublishSnapshot(){return this.cachedAutoPublishSnapshot===null&&(this.cachedAutoPublishSnapshot=this.autoPublish),this.cachedAutoPublishSnapshot}getGlobalTransientErrorsSnapshot(){return this.cachedGlobalTransientErrorSnapshot===null&&(this.cachedGlobalTransientErrorSnapshot=this.errors.globalTransientErrorQueue?.slice()||[]),this.cachedGlobalTransientErrorSnapshot}getNetworkErrorSnapshot(){return this.cachedNetworkErrorSnapshot===void 0&&(this.cachedNetworkErrorSnapshot=this.errors.hasNetworkErrorTimestamp||null),this.cachedNetworkErrorSnapshot}getSchemaErrorSnapshot(){return this.cachedSchemaErrorSnapshot===void 0&&(this.cachedSchemaErrorSnapshot=this.errors.hasSchemaErrorTimestamp||null),this.cachedSchemaErrorSnapshot}getParentRefSnapshot(){return this.cachedParentRef===void 0&&(this.cachedParentRef=this.getParentRef()),this.cachedParentRef}addPatchOnClientOnly(e,n,r){const[i]=pe.splitModuleFilePathAndModulePath(e);if(this.serverSources===null||this.serverSources?.[i]===void 0)return this.addGlobalTransientError(`Content at '${i}' is not yet initialized`,r),{status:"patch-error",message:`Content at '${i}' is not yet initialized`,moduleFilePath:i};const s=this.getPatchedSource(i);if(s===void 0)return{status:"patch-error",message:`Content at '${i}' is not yet initialized`,moduleFilePath:i};const o=n.filter(l=>l.op!=="file");if(o.length===0)return{status:"patch-applies",moduleFilePath:i,patch:n};const a=_P(ji(s),CP,o);return SP.isErr(a)?(console.error("Could not apply patch:",a.error),this.addGlobalTransientError(`Could not apply patch: ${a.error.message}`,r),{status:"patch-error",message:a.error.message,moduleFilePath:i}):{status:"patch-applies",moduleFilePath:i,patch:n}}ensureValidationWorker(){return this.validationWorker||(this.validationWorker=new yce((e,n)=>{this.applyValidationResult(e,n)})),this.validationWorker}requestModuleValidation(e){const n=this.clientSideSchemaSha;if(!n)return;const r=this.schemas?.[e];if(!r)return;const i=this.getPatchedSource(e);i!==void 0&&this.ensureValidationWorker().validate(e,i,r,n)}requestAllModuleValidation(){const e=this.schemas;if(e)for(const n of Object.keys(e))this.requestModuleValidation(n)}applyValidationResult(e,n){this.errors.validationErrors||(this.errors.validationErrors={});const r=new Set;for(const i in this.errors.validationErrors){const s=i;(s===e||s.startsWith(e+".")||s.startsWith(e+"?"))&&this.errors.validationErrors[s]!==void 0&&(this.errors.validationErrors[s]=void 0,r.add(s))}if(n!==!1)for(const i in n){const s=i;this.errors.validationErrors[s]=n[s],r.add(s)}if(r.size>0){this.invalidateAllValidationErrors();for(const i of r)this.invalidateValidationError(i)}}validatePatchResult(e,n){const r=this.getPatchedSource(e);if(r===void 0)return{status:"no-source",message:`Content at '${e}' is not yet initialized`};const i=this.schemas?.[e];if(!i)return{status:"no-schema",message:`Schema not found for '${e}'`};const s=n.filter(l=>l.op!=="file"),o=_P(ji(r),CP,s);return SP.isErr(o)?{status:"patch-error",message:o.error.message}:(this.cachedDeserializedSchemas||(this.cachedDeserializedSchemas={}),this.cachedDeserializedSchemas[e]||(this.cachedDeserializedSchemas[e]=Eo(i)),this.cachedDeserializedSchemas[e].executeValidate(e,o.value))}async addPatchAwaitable(e,n,r,i,s,o,a,l){const c=this.addPatchOnClientOnly(e,r,o);if(c.status!=="patch-applies")return c;const{moduleFilePath:u,patch:O}=c;this.patchDataByPatchId[i]={moduleFilePath:u,patch:O,isPending:!0,createdAt:new Date(o).toISOString(),authorId:this.authorId},this.pendingClientPatchIds.push(i),this.addToPatchIdsByModule(u,i),a&&this.addToCreatorId(a,i),this.invalidateAllPatches(),this.invalidatePendingClientSidePatchIds(),this.invalidateSource(u),this.requestModuleValidation(u);const h={type:"add-patches",data:{[u]:[{patch:O,patchId:i,type:n}]},createdAt:o};let m=0;this.syncStatus[e]="patches-pending",this.invalidateSyncStatus(e);let g=await this.executeAddPatches(h,{},o,l);for(;g.status==="retry"&&m<3&&(m++,await new Promise(y=>setTimeout(y,500*(m+1))),g=await this.executeAddPatches(h,{},o,l),g.status==="retry"););return this.syncStatus[e]="done",this.invalidateSyncStatus(e),g.status==="done"?{status:"patch-synced",patchId:i,parentRef:g.parentRef,moduleFilePath:u}:(this.invalidateSource(u),this.requestModuleValidation(u),{status:"patch-sync-error",message:"Could not sync patch. Tried 3 times.",moduleFilePath:u})}addPatch(e,n,r,i,s){const o=this.addPatchOnClientOnly(e,r,i);if(o.status!=="patch-applies")return o;const a=o.moduleFilePath;this.syncStatus[e]="patches-pending",this.invalidateSyncStatus(e);const l=this.pendingOps[this.pendingOps.length-1];if(l?.type==="add-patches"){const c=(l.data?.[a]?.length||0)-1,u=l.data?.[a]?.[c]?.patch,O=l.data?.[a]?.[c]?.patchId;if(pce(u,r)&&l.data?.[a]?.[c]?.type===n&&O&&this.patchDataByPatchId[O])return l.data[a][c].patch=r,l.updatedAt=i,this.invalidatePendingOps(),this.patchDataByPatchId[O].patch=r,this.invalidateAllPatches(),this.patchSetInsert(a,O,r,i),this.invalidateSyncStatus(e),this.invalidateSource(a),this.requestModuleValidation(a),{status:"patch-merged",patchId:O,moduleFilePath:a};{l.data[a]||(l.data[a]=[]);const h=this.createPatchId();return l.data[a].push({patch:r,type:n,patchId:h}),this.invalidatePendingOps(),this.pendingClientPatchIds.push(h),this.invalidatePendingClientSidePatchIds(),this.patchDataByPatchId[h]={moduleFilePath:a,patch:r,isPending:!0,createdAt:new Date(i).toISOString(),authorId:this.authorId},this.invalidateAllPatches(),this.addToPatchIdsByModule(a,h),this.patchSetInsert(a,h,r,i),s&&this.addToCreatorId(s,h),this.invalidateSyncStatus(e),this.invalidateSource(a),this.requestModuleValidation(a),{status:"patch-added",patchId:h,moduleFilePath:a}}}else{const c=this.createPatchId();return this.pendingOps.push({type:"add-patches",data:{[a]:[{patch:r,type:n,patchId:c}]},createdAt:i}),this.invalidatePendingOps(),this.pendingClientPatchIds.push(c),this.invalidatePendingClientSidePatchIds(),this.patchDataByPatchId[c]={moduleFilePath:a,patch:r,isPending:!0,createdAt:new Date(i).toISOString(),authorId:this.authorId},this.invalidateAllPatches(),this.addToPatchIdsByModule(a,c),this.patchSetInsert(a,c,r,i),s&&this.addToCreatorId(s,c),this.invalidateSyncStatus(e),this.invalidateSource(a),this.requestModuleValidation(a),{status:"patch-added",patchId:c,moduleFilePath:a}}}createPatchId(){return crypto.randomUUID()}addToCreatorId(e,n){let r=this.patchIdsByCreatorId.get(e);r||(r=[],this.patchIdsByCreatorId.set(e,r)),r.push(n)}addToPatchIdsByModule(e,n){let r=this.patchIdsByModuleFilePath.get(e);r||(r=new Set,this.patchIdsByModuleFilePath.set(e,r)),r.add(n)}removeFromPatchIdsByModule(e){const n=this.patchDataByPatchId[e];if(n){const r=this.patchIdsByModuleFilePath.get(n.moduleFilePath);r&&r.delete(e)}}rebuildPatchIdsByModule(){this.patchIdsByModuleFilePath=new Map;for(const e in this.patchDataByPatchId){const n=e,r=this.patchDataByPatchId[n];r&&this.addToPatchIdsByModule(r.moduleFilePath,n)}}isEditedByComponent(e,n){if(!n)return!1;this.patchIdsByModuleFilePath.get(e);const r=this.patchIdsByCreatorId.get(n);if(!r)return!1;const i=this.globalServerSidePatchIds&&r[r.length-1]===this.globalServerSidePatchIds[this.globalServerSidePatchIds.length-1],s=this.savedButNotYetGlobalServerSidePatchIds&&r[r.length-1]===this.savedButNotYetGlobalServerSidePatchIds[this.savedButNotYetGlobalServerSidePatchIds.length-1],o=this.pendingClientPatchIds&&r[r.length-1]===this.pendingClientPatchIds[this.pendingClientPatchIds.length-1];return!!(i||o||s)}patchSetInsert(e,n,r,i){const s=new Date(i).toISOString();for(const o of r)this.patchSets.insert(e,this.schemas?.[e]??void 0,o,n,s,this.authorId);this.invalidatePatchSets()}deletePatches(e,n){const r=this.pendingOps[this.pendingOps.length-1];if(r?.type==="delete-patches"){r.patchIds.push(...e),r.updatedAt=n;return}this.pendingOps.push({type:"delete-patches",patchIds:e,createdAt:n}),this.invalidatePendingOps()}markAllSyncStatusIn(e,n){for(const r in this.syncStatus)r.startsWith(e)&&(this.syncStatus[r]=n)}getParentRef(){if(this.baseSha===null||this.globalServerSidePatchIds===null)return null;const e=this.savedButNotYetGlobalServerSidePatchIds[this.savedButNotYetGlobalServerSidePatchIds.length-1]||this.globalServerSidePatchIds[this.globalServerSidePatchIds.length-1];return e?{type:"patch",patchId:e}:{type:"head",headBaseSha:this.baseSha}}async syncWithUpdatedStat(e,n,r,i,s,o,a,l){const c=this.localModulesStatus.type==="loaded",u=this.sourcesSha!==i;if(this.sourcesSha=i,this.baseSha=n,this.mode=e,this.serverSideSchemaSha!==r||this.commitSha!==a)if(c)this.serverSideSchemaSha=r,this.commitSha=a,this.recomputeSchemaOutOfDate();else return this.reset(),this.serverSideSchemaSha=r,this.commitSha=a,this.init(e,n,r,i,s,o,a,l);const O=this.globalServerSidePatchIds===null||!aO(this.globalServerSidePatchIds,s);if(O){this.globalServerSidePatchIds=s;const h=new Set(s);this.deletePendingPatchId(h),this.deleteSavedButNotYetGlobalServerSidePatchIds(h),await this.syncPatches(!1,l),this.invalidateGlobalServerSidePatchIds(),this.invalidateSyncedServerSidePatchIds(),this.invalidateSavedServerSidePatchIds(),this.invalidatePendingClientSidePatchIds()}return!this.forceSyncAllModules&&(u||O)&&(this.forceSyncAllModules=!0),this.sync(l)}async executeAddPatches(e,n,r,i){if(this.schemaOutOfDate)return this.addGlobalTransientError("Cannot save: a new version has been deployed. Reload to continue editing.",r),{status:"retry",reason:"schema-out-of-date"};const s=[],o=[];let a=!1;for(const[u,O]of Object.entries(e.data)){const h=u;for(const m of O)s.push({path:h,patchId:m.patchId,patch:m.patch}),o.push(m.patchId),n[h]||(n[h]=new Set),n[h].add(m.type)}const l=i??this.getParentRef();if(l===null)return this.addGlobalTransientError("Tried to update content with changes, but could not since Val is not yet initialized",r),{status:"retry",reason:"not-initialized"};const c=await this.client("/patches","PUT",{body:{patches:s,parentRef:l,sessionId:e.sessionId}});if(c.status!==null&&this.resetNetworkError(),c.status===null&&c.json.type==="network_error")return console.warn("Network error: trying again..."),this.addNetworkError(r),{status:"retry",reason:"network-error"};if(c.status===409)return this.savedButNotYetGlobalServerSidePatchIds=[],{status:"retry",reason:"conflict"};if(c.status!==200){console.error("Failed to add patches",{error:c.json.message}),this.addGlobalTransientError("Failed to save changes",r,c.json.message);for(const O of o)this.removeFromPatchIdsByModule(O),this.patchDataByPatchId={...this.patchDataByPatchId,[O]:void 0},a=!0;const u=new Set(o);this.pendingClientPatchIds=this.pendingClientPatchIds.filter(O=>!u.has(O))}else{const u=new Set(c.json.newPatchIds);this.deletePendingPatchId(u);for(const O of o){const h=O;this.savedButNotYetGlobalServerSidePatchIds.push(h),this.patchDataByPatchId[h]&&(this.patchDataByPatchId[h].isPending=!1,a=!0)}}return a&&this.invalidateAllPatches(),{status:"done",parentRef:l}}deletePendingPatchId(e){let n=0;for(let r=0;r<this.pendingClientPatchIds.length;r++){const i=this.pendingClientPatchIds[r];if(e.has(i)&&(this.pendingClientPatchIds.splice(r,1),r--,n++,e.size===n))break}}deleteSavedButNotYetGlobalServerSidePatchIds(e){let n=0;for(let r=0;r<this.savedButNotYetGlobalServerSidePatchIds.length;r++){const i=this.savedButNotYetGlobalServerSidePatchIds[r];if(e.has(i)&&(this.savedButNotYetGlobalServerSidePatchIds.splice(r,1),r--,n++,e.size===n))break}}async executeDeletePatches(e,n,r){let i=!1;const s=e.patchIds,o=new Set(s),a=await this.client("/patches","DELETE",{query:{id:e.patchIds.reverse()}});if(a.status!==null&&this.resetNetworkError(),a.status===null&&a.json.type==="network_error")return this.addNetworkError(r),{status:"retry",reason:"network-error"};if(a.status!==200)this.addGlobalTransientError("Failed to delete patches",r);else{for(const l of e.patchIds)if(this.patchDataByPatchId[l]){const c=this.patchDataByPatchId[l].moduleFilePath;n[c]||(n[c]=new Set),n[c].add("unknown"),this.removeFromPatchIdsByModule(l),this.patchDataByPatchId={...this.patchDataByPatchId,[l]:void 0}}else i=!0;this.pendingClientPatchIds=this.pendingClientPatchIds.filter(l=>!o.has(l)),this.globalServerSidePatchIds=this.globalServerSidePatchIds?.filter(l=>!o.has(l))??null,this.deleteSavedButNotYetGlobalServerSidePatchIds(o)}return{status:"done",syncAllRequired:i}}async setValModules(e){if(!e){this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"absent"},this.invalidateLocalModulesStatus(),this.recomputeSchemaOutOfDate();return}const n=++this.setValModulesSeq;this.localModulesStatus={type:"loading"},this.invalidateLocalModulesStatus();let r;try{r=await tre(e)}catch(i){if(n!==this.setValModulesSeq)return;console.debug("setValModules: extractValModules threw",i),this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"error",moduleErrors:[{message:i instanceof Error?i.message:String(i)}]},this.invalidateLocalModulesStatus(),this.recomputeSchemaOutOfDate();return}if(n===this.setValModulesSeq){if(r.moduleErrors.length>0){console.debug("setValModules: moduleErrors present, falling back to server",r.moduleErrors),this.localSchemas=null,this.localSchemaSha=null,this.localSources=null,this.localSourcesSha=null,this.localModulesStatus={type:"error",moduleErrors:r.moduleErrors},this.invalidateLocalModulesStatus(),this.recomputeSchemaOutOfDate();return}this.localSchemas=r.serializedSchemas,this.localSchemaSha=r.schemaSha,this.localSources=r.sources,this.localSourcesSha=r.sourcesSha,this.localModulesStatus={type:"loaded",schemaSha:r.schemaSha,sourcesSha:r.sourcesSha,moduleCount:Object.keys(r.serializedSchemas).length},this.adoptLocalSchemas(),this.adoptLocalSources(),this.requestAllModuleValidation(),this.initializedAt===null&&(this.initializedAt=Date.now(),this.invalidateInitializedAt()),this.invalidateLocalModulesStatus(),this.recomputeSchemaOutOfDate()}}adoptLocalSchemas(){!this.localSchemas||!this.localSchemaSha||(this.schemas=this.localSchemas,this.clientSideSchemaSha=this.localSchemaSha,this.resetSchemaError(),this.invalidateSchema())}adoptLocalSources(){if(!this.localSources||!this.localSourcesSha)return;const e=this.localSources;this.serverSources===null&&(this.serverSources={...e},this.sourcesSha=this.localSourcesSha),this.forceSyncAllModules=!0,this.patchedSourcesCache=null;for(const n of Object.keys(e))this.invalidateSource(n)}recomputeSchemaOutOfDate(){const e=this.mode==="http"&&this.localSchemaSha!==null&&this.serverSideSchemaSha!==null&&this.localSchemaSha!==this.serverSideSchemaSha;e!==this.schemaOutOfDate&&(this.schemaOutOfDate=e,this.invalidateSchemaOutOfDate(),e?(this.publishDisabled=!0,this.invalidatePublishDisabled()):this.isPublishing||(this.publishDisabled=!1,this.invalidatePublishDisabled()))}async syncSchema(){if(this.localSchemas&&this.localSchemaSha)return this.schemas=this.localSchemas,this.clientSideSchemaSha=this.localSchemaSha,this.resetSchemaError(),this.invalidateSchema(),{status:"done"};const e=await this.client("/schema","GET",{});if(e.status===200){this.schemas={};for(const[n,r]of Object.entries(e.json.schemas)){const i=n;r&&(this.schemas[i]=r)}return this.clientSideSchemaSha!==e.json.schemaSha&&(this.clientSideSchemaSha=e.json.schemaSha),console.debug("Invalidating schema"),this.resetSchemaError(),this.invalidateSchema(),{status:"done"}}else if(e.status===null)return{status:"retry",reason:"error"};return this.addSchemaError(Date.now()),{status:"retry",reason:"error"}}async syncPatches(e,n){const r=this.globalServerSidePatchIds||[];let i=!1,s=!1;if(this.initializedAt===null||e){this.patchSets=new Lh,i=!0;const l=await this.client("/patches","GET",{query:{exclude_patch_ops:!1,patch_id:void 0}});if(l.status!==200)return console.debug("Val: SyncEngine: Failed to get changes (full sync)",{res:l}),{status:"retry"};for(const c of l.json.patches)c.patch&&(s=!0,this.patchDataByPatchId[c.patchId]={moduleFilePath:c.path,patch:c.patch,isPending:!1,createdAt:c.createdAt,authorId:c.authorId,isCommitted:c.appliedAt?{commitSha:c.appliedAt.commitSha}:void 0},this.addToPatchIdsByModule(c.path,c.patchId));l.json.error&&this.addGlobalTransientError("Some changes has errors",n,l.json.error.message);for(const c of Object.values(l.json.errors||{}))c&&this.addGlobalTransientError("A change has an error",n,c.message)}else{const l=[];for(const c of this.globalServerSidePatchIds||[])this.patchDataByPatchId[c]||l.push(c);if(l.length>0){const u=[];for(let O=0;O<l.length;O+=100)u.push(l.slice(O,O+100));for(const O of u){const h=await this.client("/patches","GET",{query:{exclude_patch_ops:!1,patch_id:O}});if(h.status!==200)return console.debug("Val: SyncEngine: Failed to get changes (batch) - null status",{res:h}),{status:"retry"};for(const m of h.json.patches)m.patch&&(s=!0,this.patchDataByPatchId[m.patchId]={moduleFilePath:m.path,patch:m.patch,isPending:!1,createdAt:m.createdAt,authorId:m.authorId,isCommitted:m.appliedAt?{commitSha:m.appliedAt.commitSha}:void 0},this.addToPatchIdsByModule(m.path,m.patchId))}}}const o=new Set(r);for(const l of Array.from(this.patchSets.getInsertedPatches())||[])if(!o.has(l)){this.patchSets=new Lh,i=!0;break}const a=[];for(const l of r)if(!this.patchSets.isInserted(l)){const c=this.patchDataByPatchId[l],u=c?.moduleFilePath&&this.schemas?.[c?.moduleFilePath];if(c&&u)for(const O of c.patch)i=!0,this.patchSets.insert(c.moduleFilePath,u,O,l,c.createdAt,c.authorId);else a.push(l)}return s&&this.invalidateAllPatches(),i&&this.invalidatePatchSets(),a.length>0?(this.initializedAt!==null&&(console.debug("Missing data for patch ids",a,{currentPatchIds:r,reset:e}),this.mode!=="fs"&&this.addGlobalTransientError("Failed to get changes",n,`Missing data for patch ids: ${a.join(", ")}`)),{status:"retry"}):{status:"done"}}getChangedModules(e){const n=Object.entries(e);if(n.length===0)return[];if(n.length===1){const[r,i]=n[0];if(Array.from(i).every(s=>Sce.includes(s)))return[r]}return"all"}async sync(e){if(this.isSyncing)return{status:"retry",reason:"already-syncing"};if(this.isPublishing)return{status:"retry",reason:"publishing"};let n=[];this.forceSyncAllModules&&(this.forceSyncAllModules=!1,n="all"),this.initializedAt===null&&(n="all"),!this.localSchemas&&this.clientSideSchemaSha!==this.serverSideSchemaSha&&(n="all"),this.isSyncing=!0;let r=[],i=!1;const s=new Set([...this.syncedServerSidePatchIds,...this.savedButNotYetGlobalServerSidePatchIds]);if(this.globalServerSidePatchIds&&this.mode==="http"){for(const o of s)if(!this.globalServerSidePatchIds.includes(o)){this.syncedServerSidePatchIds=[],this.savedButNotYetGlobalServerSidePatchIds=[],this.pendingClientPatchIds=[],await this.syncPatches(!0,e),this.rebuildPatchIdsByModule(),i=!0;break}}try{const o={},a=(u,O)=>e-O<=u*1e3,l=(u,O)=>e-O>=u*1e3;if(this.pendingOps[this.pendingOps.length-1]?.updatedAt!==void 0&&a(this.MIN_WAIT_SECONDS,this.pendingOps[this.pendingOps.length-1].updatedAt)&&!l(this.MAX_WAIT_SECONDS,this.pendingOps[this.pendingOps.length-1].createdAt))return{status:"retry",reason:"too-fast"};r=this.pendingOps.slice(),this.pendingOps=[];let c=!1;for(;r[0];){const u=r[0];if(u.type==="add-patches")try{const O=await this.executeAddPatches(u,o,e);if(O.status!=="done")return O}catch{return{status:"retry",reason:"error"}}else if(u.type==="delete-patches")try{const O=await this.executeDeletePatches(u,o,e);if(O.status!=="done")return O;O.syncAllRequired&&n!=="all"&&(n="all")}catch{return{status:"retry",reason:"error"}}c=!0,r.shift()}if(this.invalidatePendingOps(),n!=="all"){const u=this.getChangedModules(o);if(u==="all")n="all";else for(const O of u)n.push(O)}if(this.clientSideSchemaSha===null||this.schemas===null||this.initializedAt===null){const u=await this.syncSchema();if(u.status!=="done")return u}if(n==="all"||n.length>0){const u=n!=="all"&&n.length===1?n[0]:void 0,O=await this.client("/sources/~","PUT",{path:u,query:{validate_sources:!1,validate_binary_files:!1,exclude_patches:!1,apply_patches:!1}});if(O.status!==null&&this.resetNetworkError(),O.status===null&&O.json.type==="network_error")return this.addNetworkError(e),{status:"retry",reason:"network-error"};if(O.status!==200)this.addGlobalTransientError("Could not sync content with server. Please wait or reload the application.",e,O.json.message);else{const h=new Set;for(const m in this.errors.validationErrors){const g=m;(u===void 0||g.startsWith(u))&&(h.add(g),this.errors.validationErrors[g]&&(this.errors.validationErrors={...this.errors.validationErrors,[g]:void 0}))}for(const[m,g]of Object.entries(O.json.modules)){const y=m;if(g){this.serverSources===null&&(this.serverSources={}),this.serverSources[y]=g.source,this.renders===null&&(this.renders={}),this.renders[y]=g.render||null,this.invalidateRenders(y),this.patchedSourcesCache!==null&&(this.patchedSourcesCache={...this.patchedSourcesCache,[y]:void 0}),console.debug("Invalidating source",y),this.invalidateSource(y),this.overlayEmitter?.(y,g.source),this.invalidatePatchErrors(y),g.patches?.errors&&(this.errors.patchErrors===void 0&&(this.errors.patchErrors={}),this.errors.patchErrors[y]=g.patches.errors),this.requestModuleValidation(y);for(const v of g.patches?.applied||[])this.syncedServerSidePatchIds.push(v);for(const v of g.patches?.skipped||[])this.syncedServerSidePatchIds.push(v)}else this.addGlobalTransientError(`Could not find '${y}' in server reply`,e,"This is most likely a bug");this.markAllSyncStatusIn(y,"done")}this.invalidateAllValidationErrors();for(const m of Array.from(h))this.invalidateValidationError(m);O.json.schemaSha!==this.clientSideSchemaSha&&await this.syncSchema()}}if(this.autoPublish&&this.mode==="fs"&&this.globalServerSidePatchIds&&this.globalServerSidePatchIds.length>0){const u=this.getAllValidationErrorsSnapshot();Object.values(u||{}).some(h=>h&&h.length>0)?console.debug("Skip auto-publish since there's validation errors",u):(await this.publish(this.globalServerSidePatchIds.concat(...Array.from(this.syncedServerSidePatchIds)),void 0,e),c=!0)}return(i||c)&&(this.invalidatePendingClientSidePatchIds(),this.invalidateGlobalServerSidePatchIds(),this.invalidateSyncedServerSidePatchIds(),this.invalidateSavedServerSidePatchIds()),{status:"done"}}finally{this.isSyncing=!1,this.pendingOps=[...r,...this.pendingOps]}}async publish(e,n,r){try{if(this.isPublishing)return console.debug("Already publishing changes",r),{status:"retry",reason:"already-publishing"};if(this.isPublishing=!0,this.publishDisabled)return console.debug("Could not publish changes, since the publish is disabled",r),{status:"retry",reason:"publish-disabled"};this.publishDisabled=!0,this.invalidatePublishDisabled();const i=this.getAllValidationErrorsSnapshot();if(Object.values(i||{}).flatMap(a=>a||[]).length>0)return console.debug("Skipping publish since there's validation errors",i),this.addGlobalTransientError("Could not publish changes, since there are validation errors",r),{status:"retry",reason:"validation-error"};if(e.length===0)return this.addGlobalTransientError("Could not publish changes, since there are no changes to publish",Date.now()),{status:"done"};const o=await this.client("/save","POST",{body:{message:n,patchIds:e}});return o.status===null?(this.addGlobalTransientError("Network error: could not publish",Date.now()),{status:"retry"}):o.status!==200?(this.addGlobalTransientError("Failed to publish changes",Date.now(),o.json.message),{status:"retry"}):(this.mode==="fs"&&(this.globalServerSidePatchIds=[],console.debug("Deleting all patch ids")),this.pendingClientPatchIds=[],this.syncedServerSidePatchIds=[],this.savedButNotYetGlobalServerSidePatchIds=[],this.patchIdsByCreatorId=new Map,this.patchIdsByModuleFilePath=new Map,this.patchDataByPatchId={},this.patchSets=new Lh,await this.syncPatches(!0,r),this.invalidatePatchSets(),this.invalidateAllPatches(),this.invalidatePendingClientSidePatchIds(),this.invalidateSyncedServerSidePatchIds(),this.invalidateSavedServerSidePatchIds(),{status:"done"})}catch(i){return console.error("Error while publishing",i),this.addGlobalTransientError("Failed to publish changes",Date.now(),i.message),{status:"retry",reason:"error"}}finally{this.isPublishing=!1,this.publishDisabled=!1,this.invalidatePublishDisabled()}}resetNetworkError(){this.errors.hasNetworkErrorTimestamp=null,this.invalidateNetworkError()}addNetworkError(e){this.errors.hasNetworkErrorTimestamp=e,this.invalidateNetworkError()}resetSchemaError(){this.errors.hasSchemaErrorTimestamp=null,this.invalidateSchemaError()}addSchemaError(e){this.errors.hasSchemaErrorTimestamp=e,this.invalidateSchemaError()}addGlobalTransientError(e,n,r){this.errors.globalTransientErrorQueue||(this.errors.globalTransientErrorQueue=[]),console.error("Global transient error",e,r||""),this.errors.globalTransientErrorQueue.push({message:e,details:r,timestamp:n,id:crypto.randomUUID()});const i=100;this.errors.globalTransientErrorQueue.length>i&&(this.errors.globalTransientErrorQueue=this.errors.globalTransientErrorQueue.slice(-i)),this.invalidateGlobalTransientErrors()}removeGlobalTransientErrors(e){if(this.errors.globalTransientErrorQueue){const n=new Set(e);this.errors.globalTransientErrorQueue=this.errors.globalTransientErrorQueue.filter(r=>!n.has(r.id)),this.invalidateGlobalTransientErrors()}}setSchemas(e){this.schemas=e,this.cachedSchemaSnapshots=null,this.cachedAllSchemasSnapshot=null,this.cachedDeserializedSchemas=null,this.emit(this.listeners.schema?.[xn])}setSources(e){this.serverSources=e,this.patchedSourcesCache=null,this.cachedSourceSnapshots=null,this.cachedServerSourceSnapshots=null,this.cachedBaseSourceSnapshots=null,this.cachedAllSourcesSnapshot=null,this.cachedSourcesSnapshot=null;for(const n in e)this.emit(this.listeners.sources?.[n]),this.emit(this.listeners.source?.[n]);this.emit(this.listeners["all-sources"]?.[xn])}setRenders(e){this.renders=e,this.cachedRenderSnapshots=e,this.cachedAllRendersSnapshot=null;for(const n in e){const r=n;this.emit(this.listeners.render?.[r])}this.emit(this.listeners["all-renders"]?.[xn])}setInitializedAt(e){this.initializedAt=e,this.cachedInitializedAtSnapshot=null,this.emit(this.listeners["initialized-at"]?.[xn])}setBaseSha(e){this.baseSha=e,this.cachedParentRef=void 0}}const CP=new fce,xn="global",Sce=["string","boolean","number","date","dateTime","richtext","file","image"],bce=(t,e)=>{window.dispatchEvent(new CustomEvent("val-event",{detail:{type:"source-update",moduleFilePath:t,source:e}}))};function Pce(t,e,n){const r={};for(const i of t)r[i.commitSha]=i;for(const i of e)r[i.commitSha]||(r[i.commitSha]={commitMessage:i?.commitMessage||null,deploymentState:"created",creator:i.creator,createdAt:i.createdAt,updatedAt:i.createdAt,commitSha:i.commitSha});for(const i of n)i.commitSha&&(r[i.commitSha]={commitMessage:r[i.commitSha]?.commitMessage||null,deploymentState:i.deploymentState,creator:r[i.commitSha]?.creator||null,createdAt:r[i.commitSha]?.createdAt||i.createdAt,updatedAt:i.updatedAt,commitSha:i.commitSha});return Object.values(r).sort((i,s)=>new Date(s.updatedAt).getTime()-new Date(i.updatedAt).getTime())}function Ce(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t?.(i),n===!1||!i.defaultPrevented)return e?.(i)}}function Az(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function za(...t){return e=>{let n=!1;const r=t.map(i=>{const s=Az(i,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():Az(t[i],null)}}}}function ft(...t){return $.useCallback(za(...t),t)}function wce(t,e){const n=$.createContext(e),r=s=>{const{children:o,...a}=s,l=$.useMemo(()=>a,Object.values(a));return d.jsx(n.Provider,{value:l,children:o})};r.displayName=t+"Provider";function i(s){const o=$.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[r,i]}function Mi(t,e=[]){let n=[];function r(s,o){const a=$.createContext(o),l=n.length;n=[...n,o];const c=O=>{const{scope:h,children:m,...g}=O,y=h?.[t]?.[l]||a,v=$.useMemo(()=>g,Object.values(g));return d.jsx(y.Provider,{value:v,children:m})};c.displayName=s+"Provider";function u(O,h){const m=h?.[t]?.[l]||a,g=$.useContext(m);if(g)return g;if(o!==void 0)return o;throw new Error(`\`${O}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=n.map(o=>$.createContext(o));return function(a){const l=a?.[t]||s;return $.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[r,kce(i,...e)]}function kce(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const O=l(s)[`__scope${c}`];return{...a,...O}},{});return $.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Vs=bq();const RR=Xf(Vs);function lO(t){const e=Tce(t),n=$.forwardRef((r,i)=>{const{children:s,...o}=r,a=$.Children.toArray(s),l=a.find(Rce);if(l){const c=l.props.children,u=a.map(O=>O===l?$.Children.count(c)>1?$.Children.only(null):$.isValidElement(c)?c.props.children:null:O);return d.jsx(e,{...o,ref:i,children:$.isValidElement(c)?$.cloneElement(c,void 0,u):null})}return d.jsx(e,{...o,ref:i,children:s})});return n.displayName=`${t}.Slot`,n}function Tce(t){const e=$.forwardRef((n,r)=>{const{children:i,...s}=n;if($.isValidElement(i)){const o=Cce(i),a=_ce(s,i.props);return i.type!==$.Fragment&&(a.ref=r?za(r,o):o),$.cloneElement(i,a)}return $.Children.count(i)>1?$.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var iM=Symbol("radix.slottable");function Xce(t){const e=({children:n})=>d.jsx(d.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=iM,e}function Rce(t){return $.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===iM}function _ce(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function Cce(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var jce=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ut=jce.reduce((t,e)=>{const n=lO(`Primitive.${e}`),r=$.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function sM(t,e){t&&Vs.flushSync(()=>t.dispatchEvent(e))}function Qr(t){const e=$.useRef(t);return $.useEffect(()=>{e.current=t}),$.useMemo(()=>(...n)=>e.current?.(...n),[])}function Ece(t,e=globalThis?.document){const n=Qr(t);$.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var zce="DismissableLayer",mk="dismissableLayer.update",Yce="dismissableLayer.pointerDownOutside",Vce="dismissableLayer.focusOutside",Wz,oM=$.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),eu=$.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=t,c=$.useContext(oM),[u,O]=$.useState(null),h=u?.ownerDocument??globalThis?.document,[,m]=$.useState({}),g=ft(e,k=>O(k)),y=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=y.indexOf(v),b=u?y.indexOf(u):-1,P=c.layersWithOutsidePointerEventsDisabled.size>0,R=b>=x,j=Ace(k=>{const E=k.target,Y=[...c.branches].some(A=>A.contains(E));!R||Y||(i?.(k),o?.(k),k.defaultPrevented||a?.())},h),X=Wce(k=>{const E=k.target;[...c.branches].some(A=>A.contains(E))||(s?.(k),o?.(k),k.defaultPrevented||a?.())},h);return Ece(k=>{b===c.layers.size-1&&(r?.(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},h),$.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Wz=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Uz(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Wz)}},[u,h,n,c]),$.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Uz())},[u,c]),$.useEffect(()=>{const k=()=>m({});return document.addEventListener(mk,k),()=>document.removeEventListener(mk,k)},[]),d.jsx(ut.div,{...l,ref:g,style:{pointerEvents:P?R?"auto":"none":void 0,...t.style},onFocusCapture:Ce(t.onFocusCapture,X.onFocusCapture),onBlurCapture:Ce(t.onBlurCapture,X.onBlurCapture),onPointerDownCapture:Ce(t.onPointerDownCapture,j.onPointerDownCapture)})});eu.displayName=zce;var Zce="DismissableLayerBranch",Nce=$.forwardRef((t,e)=>{const n=$.useContext(oM),r=$.useRef(null),i=ft(e,r);return $.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(ut.div,{...t,ref:i})});Nce.displayName=Zce;function Ace(t,e=globalThis?.document){const n=Qr(t),r=$.useRef(!1),i=$.useRef(()=>{});return $.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){aM(Yce,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=l,e.addEventListener("click",i.current,{once:!0})):l()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function Wce(t,e=globalThis?.document){const n=Qr(t),r=$.useRef(!1);return $.useEffect(()=>{const i=s=>{s.target&&!r.current&&aM(Vce,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Uz(){const t=new CustomEvent(mk);document.dispatchEvent(t)}function aM(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?sM(i,s):i.dispatchEvent(s)}var Sr=globalThis?.document?$.useLayoutEffect:()=>{},Uce=dR[" useId ".trim().toString()]||(()=>{}),qce=0;function Kn(t){const[e,n]=$.useState(Uce());return Sr(()=>{n(r=>r??String(qce++))},[t]),e?`radix-${e}`:""}const Mce=["top","right","bottom","left"],Wc=Math.min,zs=Math.max,mv=Math.round,Ny=Math.floor,Xa=t=>({x:t,y:t}),Ice={left:"right",right:"left",bottom:"top",top:"bottom"},Dce={start:"end",end:"start"};function gk(t,e,n){return zs(t,Wc(e,n))}function kl(t,e){return typeof t=="function"?t(e):t}function Tl(t){return t.split("-")[0]}function Cf(t){return t.split("-")[1]}function _R(t){return t==="x"?"y":"x"}function CR(t){return t==="y"?"height":"width"}const Gce=new Set(["top","bottom"]);function Sa(t){return Gce.has(Tl(t))?"y":"x"}function jR(t){return _R(Sa(t))}function Lce(t,e,n){n===void 0&&(n=!1);const r=Cf(t),i=jR(t),s=CR(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=gv(o)),[o,gv(o)]}function Fce(t){const e=gv(t);return[$k(t),e,$k(e)]}function $k(t){return t.replace(/start|end/g,e=>Dce[e])}const qz=["left","right"],Mz=["right","left"],Bce=["top","bottom"],Hce=["bottom","top"];function Kce(t,e,n){switch(t){case"top":case"bottom":return n?e?Mz:qz:e?qz:Mz;case"left":case"right":return e?Bce:Hce;default:return[]}}function Jce(t,e,n,r){const i=Cf(t);let s=Kce(Tl(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map($k)))),s}function gv(t){return t.replace(/left|right|bottom|top/g,e=>Ice[e])}function eue(t){return{top:0,right:0,bottom:0,left:0,...t}}function lM(t){return typeof t!="number"?eue(t):{top:t,right:t,bottom:t,left:t}}function $v(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function Iz(t,e,n){let{reference:r,floating:i}=t;const s=Sa(e),o=jR(e),a=CR(o),l=Tl(e),c=s==="y",u=r.x+r.width/2-i.width/2,O=r.y+r.height/2-i.height/2,h=r[a]/2-i[a]/2;let m;switch(l){case"top":m={x:u,y:r.y-i.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:O};break;case"left":m={x:r.x-i.width,y:O};break;default:m={x:r.x,y:r.y}}switch(Cf(e)){case"start":m[o]-=h*(n&&c?-1:1);break;case"end":m[o]+=h*(n&&c?-1:1);break}return m}const tue=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:O}=Iz(c,r,l),h=r,m={},g=0;for(let y=0;y<a.length;y++){const{name:v,fn:x}=a[y],{x:b,y:P,data:R,reset:j}=await x({x:u,y:O,initialPlacement:r,placement:h,strategy:i,middlewareData:m,rects:c,platform:o,elements:{reference:t,floating:e}});u=b??u,O=P??O,m={...m,[v]:{...m[v],...R}},j&&g<=50&&(g++,typeof j=="object"&&(j.placement&&(h=j.placement),j.rects&&(c=j.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):j.rects),{x:u,y:O}=Iz(c,h,l)),y=-1)}return{x:u,y:O,placement:h,strategy:i,middlewareData:m}};async function vm(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:O="floating",altBoundary:h=!1,padding:m=0}=kl(e,t),g=lM(m),v=a[h?O==="floating"?"reference":"floating":O],x=$v(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),b=O==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,P=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),R=await(s.isElement==null?void 0:s.isElement(P))?await(s.getScale==null?void 0:s.getScale(P))||{x:1,y:1}:{x:1,y:1},j=$v(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:P,strategy:l}):b);return{top:(x.top-j.top+g.top)/R.y,bottom:(j.bottom-x.bottom+g.bottom)/R.y,left:(x.left-j.left+g.left)/R.x,right:(j.right-x.right+g.right)/R.x}}const nue=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=kl(t,e)||{};if(c==null)return{};const O=lM(u),h={x:n,y:r},m=jR(i),g=CR(m),y=await o.getDimensions(c),v=m==="y",x=v?"top":"left",b=v?"bottom":"right",P=v?"clientHeight":"clientWidth",R=s.reference[g]+s.reference[m]-h[m]-s.floating[g],j=h[m]-s.reference[m],X=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let k=X?X[P]:0;(!k||!await(o.isElement==null?void 0:o.isElement(X)))&&(k=a.floating[P]||s.floating[g]);const E=R/2-j/2,Y=k/2-y[g]/2-1,A=Wc(O[x],Y),W=Wc(O[b],Y),N=A,G=k-y[g]-W,U=k/2-y[g]/2+E,F=gk(N,U,G),H=!l.arrow&&Cf(i)!=null&&U!==F&&s.reference[g]/2-(U<N?A:W)-y[g]/2<0,B=H?U<N?U-N:U-G:0;return{[m]:h[m]+B,data:{[m]:F,centerOffset:U-F-B,...H&&{alignmentOffset:B}},reset:H}}}),rue=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:O=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...v}=kl(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Tl(i),b=Sa(a),P=Tl(a)===a,R=await(l.isRTL==null?void 0:l.isRTL(c.floating)),j=h||(P||!y?[gv(a)]:Fce(a)),X=g!=="none";!h&&X&&j.push(...Jce(a,y,g,R));const k=[a,...j],E=await vm(e,v),Y=[];let A=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&Y.push(E[x]),O){const U=Lce(i,o,R);Y.push(E[U[0]],E[U[1]])}if(A=[...A,{placement:i,overflows:Y}],!Y.every(U=>U<=0)){var W,N;const U=(((W=s.flip)==null?void 0:W.index)||0)+1,F=k[U];if(F&&(!(O==="alignment"?b!==Sa(F):!1)||A.every(V=>Sa(V.placement)===b?V.overflows[0]>0:!0)))return{data:{index:U,overflows:A},reset:{placement:F}};let H=(N=A.filter(B=>B.overflows[0]<=0).sort((B,V)=>B.overflows[1]-V.overflows[1])[0])==null?void 0:N.placement;if(!H)switch(m){case"bestFit":{var G;const B=(G=A.filter(V=>{if(X){const L=Sa(V.placement);return L===b||L==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(L=>L>0).reduce((L,_)=>L+_,0)]).sort((V,L)=>V[1]-L[1])[0])==null?void 0:G[0];B&&(H=B);break}case"initialPlacement":H=a;break}if(i!==H)return{reset:{placement:H}}}return{}}}};function Dz(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Gz(t){return Mce.some(e=>t[e]>=0)}const iue=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=kl(t,e);switch(r){case"referenceHidden":{const s=await vm(e,{...i,elementContext:"reference"}),o=Dz(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Gz(o)}}}case"escaped":{const s=await vm(e,{...i,altBoundary:!0}),o=Dz(s,n.floating);return{data:{escapedOffsets:o,escaped:Gz(o)}}}default:return{}}}}},cM=new Set(["left","top"]);async function sue(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Tl(n),a=Cf(n),l=Sa(n)==="y",c=cM.has(o)?-1:1,u=s&&l?-1:1,O=kl(e,t);let{mainAxis:h,crossAxis:m,alignmentAxis:g}=typeof O=="number"?{mainAxis:O,crossAxis:0,alignmentAxis:null}:{mainAxis:O.mainAxis||0,crossAxis:O.crossAxis||0,alignmentAxis:O.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),l?{x:m*u,y:h*c}:{x:h*c,y:m*u}}const oue=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,l=await sue(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},aue=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:v=>{let{x,y:b}=v;return{x,y:b}}},...l}=kl(t,e),c={x:n,y:r},u=await vm(e,l),O=Sa(Tl(i)),h=_R(O);let m=c[h],g=c[O];if(s){const v=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=m+u[v],P=m-u[x];m=gk(b,m,P)}if(o){const v=O==="y"?"top":"left",x=O==="y"?"bottom":"right",b=g+u[v],P=g-u[x];g=gk(b,g,P)}const y=a.fn({...e,[h]:m,[O]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:s,[O]:o}}}}}},lue=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=kl(t,e),u={x:n,y:r},O=Sa(i),h=_R(O);let m=u[h],g=u[O];const y=kl(a,e),v=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const P=h==="y"?"height":"width",R=s.reference[h]-s.floating[P]+v.mainAxis,j=s.reference[h]+s.reference[P]-v.mainAxis;m<R?m=R:m>j&&(m=j)}if(c){var x,b;const P=h==="y"?"width":"height",R=cM.has(Tl(i)),j=s.reference[O]-s.floating[P]+(R&&((x=o.offset)==null?void 0:x[O])||0)+(R?0:v.crossAxis),X=s.reference[O]+s.reference[P]+(R?0:((b=o.offset)==null?void 0:b[O])||0)-(R?v.crossAxis:0);g<j?g=j:g>X&&(g=X)}return{[h]:m,[O]:g}}}},cue=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:l=()=>{},...c}=kl(t,e),u=await vm(e,c),O=Tl(i),h=Cf(i),m=Sa(i)==="y",{width:g,height:y}=s.floating;let v,x;O==="top"||O==="bottom"?(v=O,x=h===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(x=O,v=h==="end"?"top":"bottom");const b=y-u.top-u.bottom,P=g-u.left-u.right,R=Wc(y-u[v],b),j=Wc(g-u[x],P),X=!e.middlewareData.shift;let k=R,E=j;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(E=P),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(k=b),X&&!h){const A=zs(u.left,0),W=zs(u.right,0),N=zs(u.top,0),G=zs(u.bottom,0);m?E=g-2*(A!==0||W!==0?A+W:zs(u.left,u.right)):k=y-2*(N!==0||G!==0?N+G:zs(u.top,u.bottom))}await l({...e,availableWidth:E,availableHeight:k});const Y=await o.getDimensions(a.floating);return g!==Y.width||y!==Y.height?{reset:{rects:!0}}:{}}}};function iS(){return typeof window<"u"}function jf(t){return uM(t)?(t.nodeName||"").toLowerCase():"#document"}function Ws(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Aa(t){var e;return(e=(uM(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function uM(t){return iS()?t instanceof Node||t instanceof Ws(t).Node:!1}function Uo(t){return iS()?t instanceof Element||t instanceof Ws(t).Element:!1}function Ya(t){return iS()?t instanceof HTMLElement||t instanceof Ws(t).HTMLElement:!1}function Lz(t){return!iS()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ws(t).ShadowRoot}const uue=new Set(["inline","contents"]);function gg(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=qo(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!uue.has(i)}const Oue=new Set(["table","td","th"]);function due(t){return Oue.has(jf(t))}const fue=[":popover-open",":modal"];function sS(t){return fue.some(e=>{try{return t.matches(e)}catch{return!1}})}const hue=["transform","translate","scale","rotate","perspective"],pue=["transform","translate","scale","rotate","perspective","filter"],mue=["paint","layout","strict","content"];function ER(t){const e=zR(),n=Uo(t)?qo(t):t;return hue.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||pue.some(r=>(n.willChange||"").includes(r))||mue.some(r=>(n.contain||"").includes(r))}function gue(t){let e=Uc(t);for(;Ya(e)&&!nf(e);){if(ER(e))return e;if(sS(e))return null;e=Uc(e)}return null}function zR(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const $ue=new Set(["html","body","#document"]);function nf(t){return $ue.has(jf(t))}function qo(t){return Ws(t).getComputedStyle(t)}function oS(t){return Uo(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Uc(t){if(jf(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Lz(t)&&t.host||Aa(t);return Lz(e)?e.host:e}function OM(t){const e=Uc(t);return nf(e)?t.ownerDocument?t.ownerDocument.body:t.body:Ya(e)&&gg(e)?e:OM(e)}function xm(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=OM(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=Ws(i);if(s){const a=yk(o);return e.concat(o,o.visualViewport||[],gg(i)?i:[],a&&n?xm(a):[])}return e.concat(i,xm(i,[],n))}function yk(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function dM(t){const e=qo(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Ya(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=mv(n)!==s||mv(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function YR(t){return Uo(t)?t:t.contextElement}function Ed(t){const e=YR(t);if(!Ya(e))return Xa(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=dM(e);let o=(s?mv(n.width):n.width)/r,a=(s?mv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const yue=Xa(0);function fM(t){const e=Ws(t);return!zR()||!e.visualViewport?yue:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Que(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ws(t)?!1:e}function cO(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=YR(t);let o=Xa(1);e&&(r?Uo(r)&&(o=Ed(r)):o=Ed(t));const a=Que(s,n,r)?fM(s):Xa(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,O=i.height/o.y;if(s){const h=Ws(s),m=r&&Uo(r)?Ws(r):r;let g=h,y=yk(g);for(;y&&r&&m!==g;){const v=Ed(y),x=y.getBoundingClientRect(),b=qo(y),P=x.left+(y.clientLeft+parseFloat(b.paddingLeft))*v.x,R=x.top+(y.clientTop+parseFloat(b.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,O*=v.y,l+=P,c+=R,g=Ws(y),y=yk(g)}}return $v({width:u,height:O,x:l,y:c})}function aS(t,e){const n=oS(t).scrollLeft;return e?e.left+n:cO(Aa(t)).left+n}function hM(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-aS(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function vue(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=Aa(r),a=e?sS(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Xa(1);const u=Xa(0),O=Ya(r);if((O||!O&&!s)&&((jf(r)!=="body"||gg(o))&&(l=oS(r)),Ya(r))){const m=cO(r);c=Ed(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const h=o&&!O&&!s?hM(o,l):Xa(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function xue(t){return Array.from(t.getClientRects())}function Sue(t){const e=Aa(t),n=oS(t),r=t.ownerDocument.body,i=zs(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=zs(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+aS(t);const a=-n.scrollTop;return qo(r).direction==="rtl"&&(o+=zs(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const Fz=25;function bue(t,e){const n=Ws(t),r=Aa(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const u=zR();(!u||u&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const c=aS(r);if(c<=0){const u=r.ownerDocument,O=u.body,h=getComputedStyle(O),m=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(r.clientWidth-O.clientWidth-m);g<=Fz&&(s-=g)}else c<=Fz&&(s+=c);return{width:s,height:o,x:a,y:l}}const Pue=new Set(["absolute","fixed"]);function wue(t,e){const n=cO(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Ya(t)?Ed(t):Xa(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function Bz(t,e,n){let r;if(e==="viewport")r=bue(t,n);else if(e==="document")r=Sue(Aa(t));else if(Uo(e))r=wue(e,n);else{const i=fM(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return $v(r)}function pM(t,e){const n=Uc(t);return n===e||!Uo(n)||nf(n)?!1:qo(n).position==="fixed"||pM(n,e)}function kue(t,e){const n=e.get(t);if(n)return n;let r=xm(t,[],!1).filter(a=>Uo(a)&&jf(a)!=="body"),i=null;const s=qo(t).position==="fixed";let o=s?Uc(t):t;for(;Uo(o)&&!nf(o);){const a=qo(o),l=ER(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&Pue.has(i.position)||gg(o)&&!l&&pM(t,o))?r=r.filter(u=>u!==o):i=a,o=Uc(o)}return e.set(t,r),r}function Tue(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?sS(e)?[]:kue(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((c,u)=>{const O=Bz(e,u,i);return c.top=zs(O.top,c.top),c.right=Wc(O.right,c.right),c.bottom=Wc(O.bottom,c.bottom),c.left=zs(O.left,c.left),c},Bz(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Xue(t){const{width:e,height:n}=dM(t);return{width:e,height:n}}function Rue(t,e,n){const r=Ya(e),i=Aa(e),s=n==="fixed",o=cO(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Xa(0);function c(){l.x=aS(i)}if(r||!r&&!s)if((jf(e)!=="body"||gg(i))&&(a=oS(e)),r){const m=cO(e,!0,s,e);l.x=m.x+e.clientLeft,l.y=m.y+e.clientTop}else i&&c();s&&!r&&i&&c();const u=i&&!r&&!s?hM(i,a):Xa(0),O=o.left+a.scrollLeft-l.x-u.x,h=o.top+a.scrollTop-l.y-u.y;return{x:O,y:h,width:o.width,height:o.height}}function jP(t){return qo(t).position==="static"}function Hz(t,e){if(!Ya(t)||qo(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Aa(t)===n&&(n=n.ownerDocument.body),n}function mM(t,e){const n=Ws(t);if(sS(t))return n;if(!Ya(t)){let i=Uc(t);for(;i&&!nf(i);){if(Uo(i)&&!jP(i))return i;i=Uc(i)}return n}let r=Hz(t,e);for(;r&&due(r)&&jP(r);)r=Hz(r,e);return r&&nf(r)&&jP(r)&&!ER(r)?n:r||gue(t)||n}const _ue=async function(t){const e=this.getOffsetParent||mM,n=this.getDimensions,r=await n(t.floating);return{reference:Rue(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Cue(t){return qo(t).direction==="rtl"}const jue={convertOffsetParentRelativeRectToViewportRelativeRect:vue,getDocumentElement:Aa,getClippingRect:Tue,getOffsetParent:mM,getElementRects:_ue,getClientRects:xue,getDimensions:Xue,getScale:Ed,isElement:Uo,isRTL:Cue};function gM(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Eue(t,e){let n=null,r;const i=Aa(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=t.getBoundingClientRect(),{left:u,top:O,width:h,height:m}=c;if(a||e(),!h||!m)return;const g=Ny(O),y=Ny(i.clientWidth-(u+h)),v=Ny(i.clientHeight-(O+m)),x=Ny(u),P={rootMargin:-g+"px "+-y+"px "+-v+"px "+-x+"px",threshold:zs(0,Wc(1,l))||1};let R=!0;function j(X){const k=X[0].intersectionRatio;if(k!==l){if(!R)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}k===1&&!gM(c,t.getBoundingClientRect())&&o(),R=!1}try{n=new IntersectionObserver(j,{...P,root:i.ownerDocument})}catch{n=new IntersectionObserver(j,P)}n.observe(t)}return o(!0),s}function zue(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=YR(t),u=i||s?[...c?xm(c):[],...xm(e)]:[];u.forEach(x=>{i&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const O=c&&a?Eue(c,n):null;let h=-1,m=null;o&&(m=new ResizeObserver(x=>{let[b]=x;b&&b.target===c&&m&&(m.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var P;(P=m)==null||P.observe(e)})),n()}),c&&!l&&m.observe(c),m.observe(e));let g,y=l?cO(t):null;l&&v();function v(){const x=cO(t);y&&!gM(y,x)&&n(),y=x,g=requestAnimationFrame(v)}return n(),()=>{var x;u.forEach(b=>{i&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),O?.(),(x=m)==null||x.disconnect(),m=null,l&&cancelAnimationFrame(g)}}const Yue=oue,Vue=aue,Zue=rue,Nue=cue,Aue=iue,Kz=nue,Wue=lue,Uue=(t,e,n)=>{const r=new Map,i={platform:jue,...n},s={...i.platform,_c:r};return tue(t,e,{...i,platform:s})};var que=typeof document<"u",Mue=function(){},ZQ=que?$.useLayoutEffect:Mue;function yv(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!yv(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!yv(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function $M(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Jz(t,e){const n=$M(t);return Math.round(e*n)/n}function EP(t){const e=$.useRef(t);return ZQ(()=>{e.current=t}),e}function Iue(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[u,O]=$.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,m]=$.useState(r);yv(h,r)||m(r);const[g,y]=$.useState(null),[v,x]=$.useState(null),b=$.useCallback(V=>{V!==X.current&&(X.current=V,y(V))},[]),P=$.useCallback(V=>{V!==k.current&&(k.current=V,x(V))},[]),R=s||g,j=o||v,X=$.useRef(null),k=$.useRef(null),E=$.useRef(u),Y=l!=null,A=EP(l),W=EP(i),N=EP(c),G=$.useCallback(()=>{if(!X.current||!k.current)return;const V={placement:e,strategy:n,middleware:h};W.current&&(V.platform=W.current),Uue(X.current,k.current,V).then(L=>{const _={...L,isPositioned:N.current!==!1};U.current&&!yv(E.current,_)&&(E.current=_,Vs.flushSync(()=>{O(_)}))})},[h,e,n,W,N]);ZQ(()=>{c===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,O(V=>({...V,isPositioned:!1})))},[c]);const U=$.useRef(!1);ZQ(()=>(U.current=!0,()=>{U.current=!1}),[]),ZQ(()=>{if(R&&(X.current=R),j&&(k.current=j),R&&j){if(A.current)return A.current(R,j,G);G()}},[R,j,G,A,Y]);const F=$.useMemo(()=>({reference:X,floating:k,setReference:b,setFloating:P}),[b,P]),H=$.useMemo(()=>({reference:R,floating:j}),[R,j]),B=$.useMemo(()=>{const V={position:n,left:0,top:0};if(!H.floating)return V;const L=Jz(H.floating,u.x),_=Jz(H.floating,u.y);return a?{...V,transform:"translate("+L+"px, "+_+"px)",...$M(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:L,top:_}},[n,a,H.floating,u.x,u.y]);return $.useMemo(()=>({...u,update:G,refs:F,elements:H,floatingStyles:B}),[u,G,F,H,B])}const Due=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Kz({element:r.current,padding:i}).fn(n):{}:r?Kz({element:r,padding:i}).fn(n):{}}}},Gue=(t,e)=>({...Yue(t),options:[t,e]}),Lue=(t,e)=>({...Vue(t),options:[t,e]}),Fue=(t,e)=>({...Wue(t),options:[t,e]}),Bue=(t,e)=>({...Zue(t),options:[t,e]}),Hue=(t,e)=>({...Nue(t),options:[t,e]}),Kue=(t,e)=>({...Aue(t),options:[t,e]}),Jue=(t,e)=>({...Due(t),options:[t,e]});var eOe="Arrow",yM=$.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return d.jsx(ut.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});yM.displayName=eOe;var tOe=yM;function VR(t){const[e,n]=$.useState(void 0);return Sr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=t.offsetWidth,a=t.offsetHeight;n({width:o,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var ZR="Popper",[QM,Wa]=Mi(ZR),[nOe,vM]=QM(ZR),xM=t=>{const{__scopePopper:e,children:n}=t,[r,i]=$.useState(null);return d.jsx(nOe,{scope:e,anchor:r,onAnchorChange:i,children:n})};xM.displayName=ZR;var SM="PopperAnchor",bM=$.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=vM(SM,n),o=$.useRef(null),a=ft(e,o),l=$.useRef(null);return $.useEffect(()=>{const c=l.current;l.current=r?.current||o.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:d.jsx(ut.div,{...i,ref:a})});bM.displayName=SM;var NR="PopperContent",[rOe,iOe]=QM(NR),PM=$.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:O="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:g,...y}=t,v=vM(NR,n),[x,b]=$.useState(null),P=ft(e,ne=>b(ne)),[R,j]=$.useState(null),X=VR(R),k=X?.width??0,E=X?.height??0,Y=r+(s!=="center"?"-"+s:""),A=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},W=Array.isArray(c)?c:[c],N=W.length>0,G={padding:A,boundary:W.filter(oOe),altBoundary:N},{refs:U,floatingStyles:F,placement:H,isPositioned:B,middlewareData:V}=Iue({strategy:"fixed",placement:Y,whileElementsMounted:(...ne)=>zue(...ne,{animationFrame:m==="always"}),elements:{reference:v.anchor},middleware:[Gue({mainAxis:i+E,alignmentAxis:o}),l&&Lue({mainAxis:!0,crossAxis:!1,limiter:O==="partial"?Fue():void 0,...G}),l&&Bue({...G}),Hue({...G,apply:({elements:ne,rects:Oe,availableWidth:Qe,availableHeight:se})=>{const{width:ve,height:ce}=Oe.reference,he=ne.floating.style;he.setProperty("--radix-popper-available-width",`${Qe}px`),he.setProperty("--radix-popper-available-height",`${se}px`),he.setProperty("--radix-popper-anchor-width",`${ve}px`),he.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),R&&Jue({element:R,padding:a}),aOe({arrowWidth:k,arrowHeight:E}),h&&Kue({strategy:"referenceHidden",...G})]}),[L,_]=TM(H),q=Qr(g);Sr(()=>{B&&q?.()},[B,q]);const M=V.arrow?.x,z=V.arrow?.y,te=V.arrow?.centerOffset!==0,[ee,ae]=$.useState();return Sr(()=>{x&&ae(window.getComputedStyle(x).zIndex)},[x]),d.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:B?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(" "),...V.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:d.jsx(rOe,{scope:n,placedSide:L,onArrowChange:j,arrowX:M,arrowY:z,shouldHideArrow:te,children:d.jsx(ut.div,{"data-side":L,"data-align":_,...y,ref:P,style:{...y.style,animation:B?void 0:"none"}})})})});PM.displayName=NR;var wM="PopperArrow",sOe={top:"bottom",right:"left",bottom:"top",left:"right"},kM=$.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=iOe(wM,r),o=sOe[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(tOe,{...i,ref:n,style:{...i.style,display:"block"}})})});kM.displayName=wM;function oOe(t){return t!==null}var aOe=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:i}=e,o=i.arrow?.centerOffset!==0,a=o?0:t.arrowWidth,l=o?0:t.arrowHeight,[c,u]=TM(n),O={start:"0%",center:"50%",end:"100%"}[u],h=(i.arrow?.x??0)+a/2,m=(i.arrow?.y??0)+l/2;let g="",y="";return c==="bottom"?(g=o?O:`${h}px`,y=`${-l}px`):c==="top"?(g=o?O:`${h}px`,y=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,y=o?O:`${m}px`):c==="left"&&(g=`${r.floating.width+l}px`,y=o?O:`${m}px`),{data:{x:g,y}}}});function TM(t){const[e,n="center"]=t.split("-");return[e,n]}var $g=xM,Ef=bM,yg=PM,Qg=kM,lOe="Portal",zf=$.forwardRef((t,e)=>{const{container:n,...r}=t,[i,s]=$.useState(!1);Sr(()=>s(!0),[]);const o=n||i&&globalThis?.document?.body;return o?RR.createPortal(d.jsx(ut.div,{...r,ref:e}),o):null});zf.displayName=lOe;function cOe(t,e){return $.useReducer((n,r)=>e[n][r]??n,t)}var Jn=t=>{const{present:e,children:n}=t,r=uOe(e),i=typeof n=="function"?n({present:r.isPresent}):$.Children.only(n),s=ft(r.ref,OOe(i));return typeof n=="function"||r.isPresent?$.cloneElement(i,{ref:s}):null};Jn.displayName="Presence";function uOe(t){const[e,n]=$.useState(),r=$.useRef(null),i=$.useRef(t),s=$.useRef("none"),o=t?"mounted":"unmounted",[a,l]=cOe(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return $.useEffect(()=>{const c=Ay(r.current);s.current=a==="mounted"?c:"none"},[a]),Sr(()=>{const c=r.current,u=i.current;if(u!==t){const h=s.current,m=Ay(c);t?l("MOUNT"):m==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&h!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,l]),Sr(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,O=m=>{const y=Ay(r.current).includes(CSS.escape(m.animationName));if(m.target===e&&y&&(l("ANIMATION_END"),!i.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},h=m=>{m.target===e&&(s.current=Ay(r.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",O),e.addEventListener("animationend",O),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",O),e.removeEventListener("animationend",O)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:$.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Ay(t){return t?.animationName||"none"}function OOe(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var dOe=dR[" useInsertionEffect ".trim().toString()]||Sr;function ms({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,s,o]=fOe({defaultProp:e,onChange:n}),a=t!==void 0,l=a?t:i;{const u=$.useRef(t!==void 0);$.useEffect(()=>{const O=u.current;O!==a&&console.warn(`${r} is changing from ${O?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=$.useCallback(u=>{if(a){const O=hOe(u)?u(t):u;O!==t&&o.current?.(O)}else s(u)},[a,t,s,o]);return[l,c]}function fOe({defaultProp:t,onChange:e}){const[n,r]=$.useState(t),i=$.useRef(n),s=$.useRef(e);return dOe(()=>{s.current=e},[e]),$.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function hOe(t){return typeof t=="function"}var XM=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),pOe="VisuallyHidden",RM=$.forwardRef((t,e)=>d.jsx(ut.span,{...t,ref:e,style:{...XM,...t.style}}));RM.displayName=pOe;var mOe=RM,[lS]=Mi("Tooltip",[Wa]),cS=Wa(),_M="TooltipProvider",gOe=700,Qk="tooltip.open",[$Oe,AR]=lS(_M),CM=t=>{const{__scopeTooltip:e,delayDuration:n=gOe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,o=$.useRef(!0),a=$.useRef(!1),l=$.useRef(0);return $.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),d.jsx($Oe,{scope:e,isOpenDelayedRef:o,delayDuration:n,onOpen:$.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:$.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:$.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};CM.displayName=_M;var Sm="Tooltip",[yOe,uS]=lS(Sm),jM=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,l=AR(Sm,t.__scopeTooltip),c=cS(e),[u,O]=$.useState(null),h=Kn(),m=$.useRef(0),g=o??l.disableHoverableContent,y=a??l.delayDuration,v=$.useRef(!1),[x,b]=ms({prop:r,defaultProp:i??!1,onChange:k=>{k?(l.onOpen(),document.dispatchEvent(new CustomEvent(Qk))):l.onClose(),s?.(k)},caller:Sm}),P=$.useMemo(()=>x?v.current?"delayed-open":"instant-open":"closed",[x]),R=$.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v.current=!1,b(!0)},[b]),j=$.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b(!1)},[b]),X=$.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{v.current=!0,b(!0),m.current=0},y)},[y,b]);return $.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),d.jsx($g,{...c,children:d.jsx(yOe,{scope:e,contentId:h,open:x,stateAttribute:P,trigger:u,onTriggerChange:O,onTriggerEnter:$.useCallback(()=>{l.isOpenDelayedRef.current?X():R()},[l.isOpenDelayedRef,X,R]),onTriggerLeave:$.useCallback(()=>{g?j():(window.clearTimeout(m.current),m.current=0)},[j,g]),onOpen:R,onClose:j,disableHoverableContent:g,children:n})})};jM.displayName=Sm;var vk="TooltipTrigger",WR=$.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=uS(vk,n),s=AR(vk,n),o=cS(n),a=$.useRef(null),l=ft(e,a,i.onTriggerChange),c=$.useRef(!1),u=$.useRef(!1),O=$.useCallback(()=>c.current=!1,[]);return $.useEffect(()=>()=>document.removeEventListener("pointerup",O),[O]),d.jsx(Ef,{asChild:!0,...o,children:d.jsx(ut.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Ce(t.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Ce(t.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Ce(t.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",O,{once:!0})}),onFocus:Ce(t.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ce(t.onBlur,i.onClose),onClick:Ce(t.onClick,i.onClose)})})});WR.displayName=vk;var QOe="TooltipPortal",[mFe,vOe]=lS(QOe,{forceMount:void 0}),rf="TooltipContent",EM=$.forwardRef((t,e)=>{const n=vOe(rf,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=uS(rf,t.__scopeTooltip);return d.jsx(Jn,{present:r||o.open,children:o.disableHoverableContent?d.jsx(zM,{side:i,...s,ref:e}):d.jsx(xOe,{side:i,...s,ref:e})})}),xOe=$.forwardRef((t,e)=>{const n=uS(rf,t.__scopeTooltip),r=AR(rf,t.__scopeTooltip),i=$.useRef(null),s=ft(e,i),[o,a]=$.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:O}=r,h=$.useCallback(()=>{a(null),O(!1)},[O]),m=$.useCallback((g,y)=>{const v=g.currentTarget,x={x:g.clientX,y:g.clientY},b=kOe(x,v.getBoundingClientRect()),P=TOe(x,b),R=XOe(y.getBoundingClientRect()),j=_Oe([...P,...R]);a(j),O(!0)},[O]);return $.useEffect(()=>()=>h(),[h]),$.useEffect(()=>{if(l&&u){const g=v=>m(v,u),y=v=>m(v,l);return l.addEventListener("pointerleave",g),u.addEventListener("pointerleave",y),()=>{l.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",y)}}},[l,u,m,h]),$.useEffect(()=>{if(o){const g=y=>{const v=y.target,x={x:y.clientX,y:y.clientY},b=l?.contains(v)||u?.contains(v),P=!ROe(x,o);b?h():P&&(h(),c())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,u,o,c,h]),d.jsx(zM,{...t,ref:s})}),[SOe,bOe]=lS(Sm,{isInside:!1}),POe=Xce("TooltipContent"),zM=$.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,l=uS(rf,n),c=cS(n),{onClose:u}=l;return $.useEffect(()=>(document.addEventListener(Qk,u),()=>document.removeEventListener(Qk,u)),[u]),$.useEffect(()=>{if(l.trigger){const O=h=>{h.target?.contains(l.trigger)&&u()};return window.addEventListener("scroll",O,{capture:!0}),()=>window.removeEventListener("scroll",O,{capture:!0})}},[l.trigger,u]),d.jsx(eu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:O=>O.preventDefault(),onDismiss:u,children:d.jsxs(yg,{"data-state":l.stateAttribute,...c,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[d.jsx(POe,{children:r}),d.jsx(SOe,{scope:n,isInside:!0,children:d.jsx(mOe,{id:l.contentId,role:"tooltip",children:i||r})})]})})});EM.displayName=rf;var YM="TooltipArrow",wOe=$.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=cS(n);return bOe(YM,n).isInside?null:d.jsx(Qg,{...i,...r,ref:e})});wOe.displayName=YM;function kOe(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function TOe(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function XOe(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function ROe(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s],l=e[o],c=a.x,u=a.y,O=l.x,h=l.y;u>r!=h>r&&n<(O-c)*(r-u)/(h-u)+c&&(i=!i)}return i}function _Oe(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),COe(e)}function COe(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var jOe=CM,EOe=jM,zOe=WR,VM=EM;function ZM(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=ZM(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function NM(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=ZM(t))&&(r&&(r+=" "),r+=e);return r}const UR="-",YOe=t=>{const e=ZOe(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const a=o.split(UR);return a[0]===""&&a.length!==1&&a.shift(),AM(a,e)||VOe(o)},getConflictingClassGroupIds:(o,a)=>{const l=n[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},AM=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?AM(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(UR);return e.validators.find(({validator:o})=>o(s))?.classGroupId},eY=/^\[(.+)\]$/,VOe=t=>{if(eY.test(t)){const e=eY.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},ZOe=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return AOe(Object.entries(t.classGroups),n).forEach(([s,o])=>{xk(o,r,s,e)}),r},xk=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:tY(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(NOe(i)){xk(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{xk(o,tY(e,s),n,r)})})},tY=(t,e)=>{let n=t;return e.split(UR).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},NOe=t=>t.isThemeGetter,AOe=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[e+o,a])):s);return[n,i]}):t,WOe=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},WM="!",UOe=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=a=>{const l=[];let c=0,u=0,O;for(let v=0;v<a.length;v++){let x=a[v];if(c===0){if(x===i&&(r||a.slice(v,v+s)===e)){l.push(a.slice(u,v)),u=v+s;continue}if(x==="/"){O=v;continue}}x==="["?c++:x==="]"&&c--}const h=l.length===0?a:a.substring(u),m=h.startsWith(WM),g=m?h.substring(1):h,y=O&&O>u?O-u:void 0;return{modifiers:l,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:y}};return n?a=>n({className:a,parseClassName:o}):o},qOe=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},MOe=t=>({cache:WOe(t.cacheSize),parseClassName:UOe(t),...YOe(t)}),IOe=/\s+/,DOe=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(IOe);let a="";for(let l=o.length-1;l>=0;l-=1){const c=o[l],{modifiers:u,hasImportantModifier:O,baseClassName:h,maybePostfixModifierPosition:m}=n(c);let g=!!m,y=r(g?h.substring(0,m):h);if(!y){if(!g){a=c+(a.length>0?" "+a:a);continue}if(y=r(h),!y){a=c+(a.length>0?" "+a:a);continue}g=!1}const v=qOe(u).join(":"),x=O?v+WM:v,b=x+y;if(s.includes(b))continue;s.push(b);const P=i(y,g);for(let R=0;R<P.length;++R){const j=P[R];s.push(x+j)}a=c+(a.length>0?" "+a:a)}return a};function GOe(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=UM(e))&&(r&&(r+=" "),r+=n);return r}const UM=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=UM(t[r]))&&(n&&(n+=" "),n+=e);return n};function LOe(t,...e){let n,r,i,s=o;function o(l){const c=e.reduce((u,O)=>O(u),t());return n=MOe(c),r=n.cache.get,i=n.cache.set,s=a,a(l)}function a(l){const c=r(l);if(c)return c;const u=DOe(l,n);return i(l,u),u}return function(){return s(GOe.apply(null,arguments))}}const Rn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},qM=/^\[(?:([a-z-]+):)?(.+)\]$/i,FOe=/^\d+\/\d+$/,BOe=new Set(["px","full","screen"]),HOe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,KOe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,JOe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,ede=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,tde=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,il=t=>zd(t)||BOe.has(t)||FOe.test(t),sc=t=>Yf(t,"length",cde),zd=t=>!!t&&!Number.isNaN(Number(t)),zP=t=>Yf(t,"number",zd),Fh=t=>!!t&&Number.isInteger(Number(t)),nde=t=>t.endsWith("%")&&zd(t.slice(0,-1)),bt=t=>qM.test(t),oc=t=>HOe.test(t),rde=new Set(["length","size","percentage"]),ide=t=>Yf(t,rde,MM),sde=t=>Yf(t,"position",MM),ode=new Set(["image","url"]),ade=t=>Yf(t,ode,Ode),lde=t=>Yf(t,"",ude),Bh=()=>!0,Yf=(t,e,n)=>{const r=qM.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},cde=t=>KOe.test(t)&&!JOe.test(t),MM=()=>!1,ude=t=>ede.test(t),Ode=t=>tde.test(t),dde=()=>{const t=Rn("colors"),e=Rn("spacing"),n=Rn("blur"),r=Rn("brightness"),i=Rn("borderColor"),s=Rn("borderRadius"),o=Rn("borderSpacing"),a=Rn("borderWidth"),l=Rn("contrast"),c=Rn("grayscale"),u=Rn("hueRotate"),O=Rn("invert"),h=Rn("gap"),m=Rn("gradientColorStops"),g=Rn("gradientColorStopPositions"),y=Rn("inset"),v=Rn("margin"),x=Rn("opacity"),b=Rn("padding"),P=Rn("saturate"),R=Rn("scale"),j=Rn("sepia"),X=Rn("skew"),k=Rn("space"),E=Rn("translate"),Y=()=>["auto","contain","none"],A=()=>["auto","hidden","clip","visible","scroll"],W=()=>["auto",bt,e],N=()=>[bt,e],G=()=>["",il,sc],U=()=>["auto",zd,bt],F=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],B=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>["start","end","center","between","around","evenly","stretch"],L=()=>["","0",bt],_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],q=()=>[zd,bt];return{cacheSize:500,separator:":",theme:{colors:[Bh],spacing:[il,sc],blur:["none","",oc,bt],brightness:q(),borderColor:[t],borderRadius:["none","","full",oc,bt],borderSpacing:N(),borderWidth:G(),contrast:q(),grayscale:L(),hueRotate:q(),invert:L(),gap:N(),gradientColorStops:[t],gradientColorStopPositions:[nde,sc],inset:W(),margin:W(),opacity:q(),padding:N(),saturate:q(),scale:q(),sepia:L(),skew:q(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",bt]}],container:["container"],columns:[{columns:[oc]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...F(),bt]}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:Y()}],"overscroll-x":[{"overscroll-x":Y()}],"overscroll-y":[{"overscroll-y":Y()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Fh,bt]}],basis:[{basis:W()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",bt]}],grow:[{grow:L()}],shrink:[{shrink:L()}],order:[{order:["first","last","none",Fh,bt]}],"grid-cols":[{"grid-cols":[Bh]}],"col-start-end":[{col:["auto",{span:["full",Fh,bt]},bt]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[Bh]}],"row-start-end":[{row:["auto",{span:[Fh,bt]},bt]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",bt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",bt]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...V()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...V(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...V(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[k]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[k]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",bt,e]}],"min-w":[{"min-w":[bt,e,"min","max","fit"]}],"max-w":[{"max-w":[bt,e,"none","full","min","max","fit","prose",{screen:[oc]},oc]}],h:[{h:[bt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[bt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[bt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[bt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",oc,sc]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",zP]}],"font-family":[{font:[Bh]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",bt]}],"line-clamp":[{"line-clamp":["none",zd,zP]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",il,bt]}],"list-image":[{"list-image":["none",bt]}],"list-style-type":[{list:["none","disc","decimal",bt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[x]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[x]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",il,sc]}],"underline-offset":[{"underline-offset":["auto",il,bt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",bt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",bt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[x]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...F(),sde]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ide]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},ade]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[x]}],"border-style":[{border:[...H(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[x]}],"divide-style":[{divide:H()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...H()]}],"outline-offset":[{"outline-offset":[il,bt]}],"outline-w":[{outline:[il,sc]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[x]}],"ring-offset-w":[{"ring-offset":[il,sc]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",oc,lde]}],"shadow-color":[{shadow:[Bh]}],opacity:[{opacity:[x]}],"mix-blend":[{"mix-blend":[...B(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":B()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",oc,bt]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[O]}],saturate:[{saturate:[P]}],sepia:[{sepia:[j]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[O]}],"backdrop-opacity":[{"backdrop-opacity":[x]}],"backdrop-saturate":[{"backdrop-saturate":[P]}],"backdrop-sepia":[{"backdrop-sepia":[j]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",bt]}],duration:[{duration:q()}],ease:[{ease:["linear","in","out","in-out",bt]}],delay:[{delay:q()}],animate:[{animate:["none","spin","ping","pulse","bounce",bt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[R]}],"scale-x":[{"scale-x":[R]}],"scale-y":[{"scale-y":[R]}],rotate:[{rotate:[Fh,bt]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[X]}],"skew-y":[{"skew-y":[X]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",bt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",bt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",bt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[il,sc,zP]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},fde=LOe(dde);function oe(...t){return fde(NM(t))}const qR=jOe,gi=EOe,zi=zOe,Jr=$.forwardRef(({className:t,sideOffset:e=4,...n},r)=>d.jsx(VM,{ref:r,sideOffset:e,className:oe("z-50 overflow-hidden rounded-md border bg-bg-primary px-3 py-2 text-sm text-fg-primary shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));Jr.displayName=VM.displayName;var hde=Symbol.for("react.lazy"),Qv=dR[" use ".trim().toString()];function pde(t){return typeof t=="object"&&t!==null&&"then"in t}function IM(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===hde&&"_payload"in t&&pde(t._payload)}function MR(t){const e=mde(t),n=$.forwardRef((r,i)=>{let{children:s,...o}=r;IM(s)&&typeof Qv=="function"&&(s=Qv(s._payload));const a=$.Children.toArray(s),l=a.find($de);if(l){const c=l.props.children,u=a.map(O=>O===l?$.Children.count(c)>1?$.Children.only(null):$.isValidElement(c)?c.props.children:null:O);return d.jsx(e,{...o,ref:i,children:$.isValidElement(c)?$.cloneElement(c,void 0,u):null})}return d.jsx(e,{...o,ref:i,children:s})});return n.displayName=`${t}.Slot`,n}var kO=MR("Slot");function mde(t){const e=$.forwardRef((n,r)=>{let{children:i,...s}=n;if(IM(i)&&typeof Qv=="function"&&(i=Qv(i._payload)),$.isValidElement(i)){const o=Qde(i),a=yde(s,i.props);return i.type!==$.Fragment&&(a.ref=r?za(r,o):o),$.cloneElement(i,a)}return $.Children.count(i)>1?$.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var gde=Symbol("radix.slottable");function $de(t){return $.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===gde}function yde(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function Qde(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}const nY=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,rY=NM,IR=(t,e)=>n=>{var r;if(e?.variants==null)return rY(t,n?.class,n?.className);const{variants:i,defaultVariants:s}=e,o=Object.keys(i).map(c=>{const u=n?.[c],O=s?.[c];if(u===null)return null;const h=nY(u)||nY(O);return i[c][h]}),a=n&&Object.entries(n).reduce((c,u)=>{let[O,h]=u;return h===void 0||(c[O]=h),c},{}),l=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:O,className:h,...m}=u;return Object.entries(m).every(g=>{let[y,v]=g;return Array.isArray(v)?v.includes({...s,...a}[y]):{...s,...a}[y]===v})?[...c,O,h]:c},[]);return rY(t,o,l,n?.class,n?.className)},vde="disabled:text-fg-disabled disabled:pointer-events-none disabled:opacity-50 aria-disabled:text-fg-disabled aria-disabled:pointer-events-none aria-disabled:opacity-50",Wy="disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary aria-disabled:bg-bg-disabled aria-disabled:text-fg-disabled aria-disabled:border aria-disabled:border-border-primary",Sk=IR(oe("inline-flex items-center justify-center whitespace-nowrap rounded-md text-fg-primary text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",vde),{variants:{variant:{default:oe("cursor-pointer","border border-border-brand-primary","bg-bg-brand-primary text-fg-brand-primary","hover:bg-bg-brand-primary-hover hover:text-fg-brand-primary-hover",Wy),destructive:oe("cursor-pointer","border border-bg-error-primary","bg-bg-error-primary text-fg-error-primary hover:bg-bg-error-primary-hover disabled:text-fg-error-primary aria-disabled:text-fg-error-primary"),warning:oe("cursor-pointer","border border-bg-warning-secondary","bg-bg-warning-secondary text-fg-warning-secondary hover:bg-bg-warning-secondary-hover disabled:text-fg-warning-secondary aria-disabled:text-fg-warning-secondary"),outline:oe("cursor-pointer","border border-transparent","bg-bg-background hover:bg-bg-secondary",Wy),secondary:oe("cursor-pointer","border border-border-secondary","bg-bg-secondary text-fg-secondary hover:bg-bg-secondary-hover",Wy),ghost:oe("cursor-pointer","border border-transparent","bg-bg-background hover:bg-bg-secondary",Wy,"hover:bg-bg-secondary-hover hover:text-fg-secondary"),link:oe("cursor-pointer","border border-transparent","text-fg-primary underline-offset-4 hover:underline")},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",xs:"h-8 rounded-md px-2",lg:"h-11 rounded-md px-8",icon:"h-10 w-10","icon-sm":"h-8 w-8"}},defaultVariants:{variant:"default",size:"default"}}),Me=$.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,disabled:i,...s},o)=>{const a=r?kO:"button";return d.jsx(a,{className:oe(Sk({variant:e,size:n,className:t})),ref:o,disabled:i,"aria-disabled":i||void 0,...s})});Me.displayName="Button";function DM(t,e=[]){let n=[];function r(s,o){const a=$.createContext(o);a.displayName=s+"Context";const l=n.length;n=[...n,o];const c=O=>{const{scope:h,children:m,...g}=O,y=h?.[t]?.[l]||a,v=$.useMemo(()=>g,Object.values(g));return d.jsx(y.Provider,{value:v,children:m})};c.displayName=s+"Provider";function u(O,h){const m=h?.[t]?.[l]||a,g=$.useContext(m);if(g)return g;if(o!==void 0)return o;throw new Error(`\`${O}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=n.map(o=>$.createContext(o));return function(a){const l=a?.[t]||s;return $.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[r,xde(i,...e)]}function xde(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const O=l(s)[`__scope${c}`];return{...a,...O}},{});return $.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Sde=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ar=Sde.reduce((t,e)=>{const n=MR(`Primitive.${e}`),r=$.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),YP="focusScope.autoFocusOnMount",VP="focusScope.autoFocusOnUnmount",iY={bubbles:!1,cancelable:!0},bde="FocusScope",GM=$.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[a,l]=$.useState(null),c=Qr(i),u=Qr(s),O=$.useRef(null),h=ft(e,y=>l(y)),m=$.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;$.useEffect(()=>{if(r){let y=function(P){if(m.paused||!a)return;const R=P.target;a.contains(R)?O.current=R:fc(O.current,{select:!0})},v=function(P){if(m.paused||!a)return;const R=P.relatedTarget;R!==null&&(a.contains(R)||fc(O.current,{select:!0}))},x=function(P){if(document.activeElement===document.body)for(const j of P)j.removedNodes.length>0&&fc(a)};document.addEventListener("focusin",y),document.addEventListener("focusout",v);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",v),b.disconnect()}}},[r,a,m.paused]),$.useEffect(()=>{if(a){oY.add(m);const y=document.activeElement;if(!a.contains(y)){const x=new CustomEvent(YP,iY);a.addEventListener(YP,c),a.dispatchEvent(x),x.defaultPrevented||(Pde(Rde(LM(a)),{select:!0}),document.activeElement===y&&fc(a))}return()=>{a.removeEventListener(YP,c),setTimeout(()=>{const x=new CustomEvent(VP,iY);a.addEventListener(VP,u),a.dispatchEvent(x),x.defaultPrevented||fc(y??document.body,{select:!0}),a.removeEventListener(VP,u),oY.remove(m)},0)}}},[a,c,u,m]);const g=$.useCallback(y=>{if(!n&&!r||m.paused)return;const v=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,x=document.activeElement;if(v&&x){const b=y.currentTarget,[P,R]=wde(b);P&&R?!y.shiftKey&&x===R?(y.preventDefault(),n&&fc(P,{select:!0})):y.shiftKey&&x===P&&(y.preventDefault(),n&&fc(R,{select:!0})):x===b&&y.preventDefault()}},[n,r,m.paused]);return d.jsx(Ar.div,{tabIndex:-1,...o,ref:h,onKeyDown:g})});GM.displayName=bde;function Pde(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(fc(r,{select:e}),document.activeElement!==n)return}function wde(t){const e=LM(t),n=sY(e,t),r=sY(e.reverse(),t);return[n,r]}function LM(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function sY(t,e){for(const n of t)if(!kde(n,{upTo:e}))return n}function kde(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Tde(t){return t instanceof HTMLInputElement&&"select"in t}function fc(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&Tde(t)&&e&&t.select()}}var oY=Xde();function Xde(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=aY(t,e),t.unshift(e)},remove(e){t=aY(t,e),t[0]?.resume()}}}function aY(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function Rde(t){return t.filter(e=>e.tagName!=="A")}var _de="Portal",FM=$.forwardRef((t,e)=>{const{container:n,...r}=t,[i,s]=$.useState(!1);Sr(()=>s(!0),[]);const o=n||i&&globalThis?.document?.body;return o?RR.createPortal(d.jsx(Ar.div,{...r,ref:e}),o):null});FM.displayName=_de;var ZP=0;function vg(){$.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??lY()),document.body.insertAdjacentElement("beforeend",t[1]??lY()),ZP++,()=>{ZP===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),ZP--}},[])}function lY(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var $a=function(){return $a=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},$a.apply(this,arguments)};function BM(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function Cde(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var NQ="right-scroll-bar-position",AQ="width-before-scroll-bar",jde="with-scroll-bars-hidden",Ede="--removed-body-scroll-bar-size";function NP(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function zde(t,e){var n=$.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var Yde=typeof window<"u"?$.useLayoutEffect:$.useEffect,cY=new WeakMap;function Vde(t,e){var n=zde(null,function(r){return t.forEach(function(i){return NP(i,r)})});return Yde(function(){var r=cY.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(a){s.has(a)||NP(a,null)}),s.forEach(function(a){i.has(a)||NP(a,o)})}cY.set(n,t)},[t]),n}function Zde(t){return t}function Nde(t,e){e===void 0&&(e=Zde);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function Ade(t){t===void 0&&(t={});var e=Nde(null);return e.options=$a({async:!0,ssr:!1},t),e}var HM=function(t){var e=t.sideCar,n=BM(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return $.createElement(r,$a({},n))};HM.isSideCarExport=!0;function Wde(t,e){return t.useMedium(e),HM}var KM=Ade(),AP=function(){},OS=$.forwardRef(function(t,e){var n=$.useRef(null),r=$.useState({onScrollCapture:AP,onWheelCapture:AP,onTouchMoveCapture:AP}),i=r[0],s=r[1],o=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,u=t.enabled,O=t.shards,h=t.sideCar,m=t.noRelative,g=t.noIsolation,y=t.inert,v=t.allowPinchZoom,x=t.as,b=x===void 0?"div":x,P=t.gapMode,R=BM(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,X=Vde([n,e]),k=$a($a({},R),i);return $.createElement($.Fragment,null,u&&$.createElement(j,{sideCar:KM,removeScrollBar:c,shards:O,noRelative:m,noIsolation:g,inert:y,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:P}),o?$.cloneElement($.Children.only(a),$a($a({},k),{ref:X})):$.createElement(b,$a({},k,{className:l,ref:X}),a))});OS.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};OS.classNames={fullWidth:AQ,zeroRight:NQ};var Ude=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qde(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=Ude();return e&&t.setAttribute("nonce",e),t}function Mde(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function Ide(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var Dde=function(){var t=0,e=null;return{add:function(n){t==0&&(e=qde())&&(Mde(e,n),Ide(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Gde=function(){var t=Dde();return function(e,n){$.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},JM=function(){var t=Gde(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},Lde={left:0,top:0,right:0,gap:0},WP=function(t){return parseInt(t||"",10)||0},Fde=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[WP(n),WP(r),WP(i)]},Bde=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Lde;var e=Fde(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},Hde=JM(),Yd="data-scroll-locked",Kde=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
|
|
56
56
|
.`.concat(jde,` {
|
|
57
57
|
overflow: hidden `).concat(r,`;
|
|
58
58
|
padding-right: `).concat(a,"px ").concat(r,`;
|