friend-assistant 0.1.34 → 0.1.35
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/README.md +1 -0
- package/dist/BUILD.json +2 -2
- package/dist/friend.mjs +155 -26
- package/dist/web/assets/{index-Cy29c71B.js → index-rcj5RQNW.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -62,7 +62,7 @@ some-mcp-server`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(
|
|
|
62
62
|
|
|
63
63
|
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=st,c=!rn.jitless,l=c&&ct.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Pi([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Li(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Dt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Mt(e,r,an())))}),t)}var Ri=G(`$ZodUnion`,(e,t)=>{Pr.init(e,t),qt(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),qt(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),qt(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),qt(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Je(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Li(t,r,e,i)):Li(o,r,e,i)}});function zi(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Bi=G(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ri.init(e,t);let n=e._zod.parse;qt(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Xe(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Ze(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Ke(()=>zi(t));e._zod.parse=(i,a)=>{let o=i.value;if(!st(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Vi=G(`$ZodIntersection`,(e,t)=>{Pr.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Ui(e,t,n)):Ui(e,i,a)}});function Hi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(lt(e)&<(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Hi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Hi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ui(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Hi(t.value,n.value);if(!c.valid){if(Dt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Wi=G(`$ZodRecord`,(e,t)=>{Pr.init(e,t);let n=rn.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!lt(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Mt(e,i,an())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...kt(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...kt(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&ur.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Mt(e,i,an())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...kt(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...kt(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Gi=G(`$ZodEnum`,(e,t)=>{Pr.init(e,t);let n=He(t.entries),r=new Set(n);e._zod.values=r,qt(e,`pattern`,e=>{let t=He(e.def.entries).filter(e=>dt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>ft(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ki=G(`$ZodLiteral`,(e,t)=>{Pr.init(e,t);let n=new Set(t.values);e._zod.values=n,qt(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?ft(e):e?ft(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),qi=G(`$ZodTransform`,(e,t)=>{Pr.init(e,t),e._zod.optin=`optional`,rn.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new tn;return n.value=i,n}});function Ji(e,t){return e.value=t.issues.length?void 0:t.value,e}var Yi=G(`$ZodOptional`,(e,t)=>{Pr.init(e,t),qt(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,qt(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),qt(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Je(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ji(e,t)):Ji(e,r)}return t.innerType._zod.run(e,n)}}),Xi=G(`$ZodExactOptional`,(e,t)=>{Yi.init(e,t),qt(e,`values`,e=>e.def.innerType._zod.values),qt(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Zi=G(`$ZodNullable`,(e,t)=>{Pr.init(e,t),qt(e,`optin`,e=>e.def.innerType._zod.optin),qt(e,`optout`,e=>e.def.innerType._zod.optout),qt(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Je(t.source)}|null)$`):void 0}),qt(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Qi=G(`$ZodDefault`,(e,t)=>{Pr.init(e,t),e._zod.optin=`defaulted`,qt(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>$i(e,t)):$i(r,t)}});function $i(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ea=G(`$ZodPrefault`,(e,t)=>{Pr.init(e,t),e._zod.optin=`defaulted`,qt(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ta=G(`$ZodNonOptional`,(e,t)=>{Pr.init(e,t),qt(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>na(t,e)):na(i,e)}});function na(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function ra(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Mt(e,r,an()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var ia=G(`$ZodCatch`,(e,t)=>{Pr.init(e,t),qt(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),qt(e,`optout`,e=>e.def.innerType._zod.optout),qt(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>ra(e,r,t,n)):ra(e,r,t,n)}}),aa=G(`$ZodPipe`,(e,t)=>{Pr.init(e,t),qt(e,`values`,e=>e.def.in._zod.values),qt(e,`optin`,e=>e.def.in._zod.optin),qt(e,`optout`,e=>e.def.out._zod.optout),qt(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>oa(e,t.in,n)):oa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>oa(e,t.out,n)):oa(r,t.out,n)}});function oa(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var sa=G(`$ZodReadonly`,(e,t)=>{Pr.init(e,t),qt(e,`propValues`,e=>e.def.innerType._zod.propValues),qt(e,`values`,e=>e.def.innerType._zod.values),qt(e,`optin`,e=>e.def.innerType?._zod?.optin),qt(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ca):ca(r)}});function ca(e){return e.memo||(e.value=Object.freeze(e.value)),e}var la=G(`$ZodCustom`,(e,t)=>{mr.init(e,t),Pr.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ua(t,n,r,e));ua(i,n,r,e)}});function ua(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Lt(e))}}var da=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},fa=`~memo`,pa=[];function ma(e){return typeof e==`object`&&!!e}function ha(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var ga=new WeakMap,_a=0,va=1,ya=2;function ba(e,t,n){let r=ga.get(e);if(r!==void 0)return r?ya:_a;if(t.has(e))return ya;t.add(e);let i=_a,a=e=>{if(i!==ya&&e?._zod){let r=ba(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=_a;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?va:o.value?._zod?ba(o.value,t,n):_a;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Ze(c);s(e?o(e,!0):va),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?ba(r,t,!1):va);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),xa(e,i)}function xa(e,t){return t!==va&&ga.set(e,t===ya),t}function Sa(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Ca,wa=[],Ta={alloc(e,t,n){let r=Ca;if(!r)return n;Ca=void 0;let i={value:n,issues:null};return r.set(t.value,i),wa.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Da(n,e.value))throw new da;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=ba(e,new Set,!1);if(i===_a)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===ya||r?n=!0:r=!0}let l=s.value;if(!ma(l))return t(s,c);let u=c[fa];u||(u={buckets:new WeakMap,backEdges:void 0},c[fa]=u);let d;i===c?d=a:(d=Sa(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ha(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Ca=d;let p=wa.length,m=t(s,c);Ca=void 0;let h=wa.length>p?wa.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ha(e.issues):pa),e)):(h&&(h.issues=m.issues.length?ha(m.issues):pa),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Ea(){return Ta}function Da(e,t){let n=e[fa]?.backEdges;return n!==void 0&&ma(t)&&n.has(t)}var Oa=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(It(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${mt(e.values[0])}`:`Invalid option: expected one of ${Ue(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Ue(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function ka(){return{localeError:Oa()}}var Aa,ja=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ma(){return new ja}(Aa=globalThis).__zod_globalRegistry??(Aa.__zod_globalRegistry=Ma());var Na=globalThis.__zod_globalRegistry;function Pa(e){return e.checks&&=[...e.checks],e}function Fa(e,t){return new e(Pa({type:`string`,...W(t)}))}function Ia(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...W(t)})}function La(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...W(t)})}function Ra(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...W(t)})}function za(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...W(t)})}function Ba(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...W(t)})}function Va(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...W(t)})}function Ha(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...W(t)})}function Ua(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...W(t)})}function Wa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...W(t)})}function Ga(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...W(t)})}function Ka(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...W(t)})}function qa(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...W(t)})}function Ja(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...W(t)})}function Ya(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...W(t)})}function Xa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...W(t)})}function Za(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...W(t)})}function Qa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...W(t)})}function $a(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...W(t)})}function eo(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...W(t)})}function to(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...W(t)})}function no(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...W(t)})}function ro(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...W(t)})}function io(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...W(t)})}function ao(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...W(t)})}function oo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...W(t)})}function so(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...W(t)})}function co(e,t){return new e(Pa({type:`number`,checks:[],...W(t)}))}function lo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...W(t)})}function uo(e,t){return new e({type:`boolean`,...W(t)})}function fo(e){return new e({type:`unknown`})}function po(e,t){return new e({type:`never`,...W(t)})}function mo(e,t){return new _r({check:`less_than`,...W(t),value:e,inclusive:!1})}function ho(e,t){return new _r({check:`less_than`,...W(t),value:e,inclusive:!0})}function go(e,t){return new vr({check:`greater_than`,...W(t),value:e,inclusive:!1})}function _o(e,t){return new vr({check:`greater_than`,...W(t),value:e,inclusive:!0})}function vo(e,t){return new yr({check:`multiple_of`,...W(t),value:e})}function yo(e,t){return new xr({check:`max_length`,...W(t),maximum:e})}function bo(e,t){return new Sr({check:`min_length`,...W(t),minimum:e})}function xo(e,t){return new Cr({check:`length_equals`,...W(t),length:e})}function So(e,t){return new Tr({check:`string_format`,format:`regex`,...W(t),pattern:e})}function Co(e){return new Er({check:`string_format`,format:`lowercase`,...W(e)})}function wo(e){return new Dr({check:`string_format`,format:`uppercase`,...W(e)})}function To(e,t){return new Or({check:`string_format`,format:`includes`,...W(t),includes:e})}function Eo(e,t){return new kr({check:`string_format`,format:`starts_with`,...W(t),prefix:e})}function Do(e,t){return new Ar({check:`string_format`,format:`ends_with`,...W(t),suffix:e})}function Oo(e){return new jr({check:`overwrite`,tx:e})}function ko(e){return Oo(t=>t.normalize(e))}function Ao(){return Oo(e=>e.trim())}function jo(){return Oo(e=>e.toLowerCase())}function Mo(){return Oo(e=>e.toUpperCase())}function No(){return Oo(e=>at(e))}function Po(e,t,n){return new e({type:`array`,element:t,...W(n)})}function Fo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...W(n)})}function Io(e,t){let n=Lo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Lt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Lt(r))}},e(t.value,t)),t);return n}function Lo(e,t){let n=new mr({check:`custom`,...W(t)});return n._zod.check=e,n}function Ro(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Xe(e,t,n[t]);return e}function zo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Na,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Bo(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Vo(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Vo(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ro(o.schema,c),t.io===`input`&&Zo(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ho(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Uo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Ho(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ho(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
64
64
|
|
|
65
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Wo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Wo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Go=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ko=[`oneOf`,`anyOf`];function qo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Jo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Go.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??qo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Xe(n,r,e.length===1?e[0]:Jo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=qo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Yo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Go)if(t in e)return;let n=t.filter(e=>Ko.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Jo(t);else{let e=n[0],i=Ko.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Jo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ro(e,r))}function Xo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Ro(i,s),Ro(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Wo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Yo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Ro(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Xe(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:$o(t,`input`,e.processors),output:$o(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Zo(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Zo(r.element,n);if(r.type===`set`)return Zo(r.valueType,n);if(r.type===`lazy`)return Zo(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Zo(r.innerType,n);if(r.type===`intersection`)return Zo(r.left,n)||Zo(r.right,n);if(r.type===`record`||r.type===`map`)return Zo(r.keyType,n)||Zo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Zo(r.in,n)||Zo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Zo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Zo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Zo(e,n))return!0;return!!(r.rest&&Zo(r.rest,n))}return!1}var Qo=(e,t={})=>n=>{let r=zo({...n,processors:t});return Vo(e,r),Uo(r,e),Xo(r,e)},$o=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=zo({...i??{},target:a,io:t,processors:n});return Vo(e,o),Uo(o,e),Xo(o,e)},es=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},ts=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},ns=(e,t)=>{es(e,`minimum`,t),ts(e,`maximum`,t)},rs=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},is=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},as=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},os=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},ss=(e,t)=>es(e,`minimum`,t.minimum),cs=(e,t)=>ts(e,`maximum`,t.maximum),ls=e=>(t,n)=>{os(t,n.format);let[r,i]=e[n.format];es(t,`minimum`,r),ts(t,`maximum`,i)},us={greater_than:(e,t)=>es(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>ts(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>rs(e,t.value),number_format:ls(gt),bigint_format:ls(_t),min_length:ss,max_length:cs,length_equals:(e,t)=>ns(e,t.length),min_size:ss,max_size:cs,size_equals:(e,t)=>ns(e,t.size),string_format:(e,t)=>{os(e,t.format),t.pattern&&is(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>as(e,t.mime)};function ds(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)us[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&es(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&es(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&ts(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&ts(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&rs(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&as(t,i.mime);for(let e of i.patterns??[])is(t,e);return t}var fs={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ps=new Map([[gi,Qn],[vi,$n]]),ms=e=>ps.get(e)??e,hs=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=ds(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=fs[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(ms);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},gs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ds(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Bo(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},_s=(e,t,n,r)=>{n.type=`boolean`},vs=(e,t,n,r)=>{n.not={}},ys=(e,t,n,r)=>{let i=e._zod.def,a=He(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},bs=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Bo(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Bo(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},xs=(e,t,n,r)=>{Bo(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ss=(e,t,n,r)=>{Bo(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Cs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=ds(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Vo(a.element,t,{...r,path:[...r.path,`items`]})};function ws(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ws(t.out):t.type===`catch`?ws(t.innerType):e._zod.optin}var Ts=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Bo(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Xe(i.properties,e,Vo(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ws(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Vo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Es=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Vo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ds=(e,t,n,r)=>{let i=e._zod.def,a=Vo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Vo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Os(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Os(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Os(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?ur:lr).source),p):p}var ks=new WeakMap;function As(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of ks.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Os(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var js=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=ds(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Vo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Xe(i.patternProperties,ms(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Vo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=ks.get(t);n||(n=[],ks.set(t,n),t.deferred.push(()=>As(t))),n.push(e)}i.additionalProperties=Vo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ws(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Ms=(e,t,n,r)=>{let i=e._zod.def,a=Vo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ns=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ps=Symbol();function Fs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Bo(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Ps):JSON.parse(o)}var Is=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Fs(i.defaultValue,e,t,n,r);o!==Ps&&(n.default=o)},Ls=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Fs(i.defaultValue,e,t,n,r);o!==Ps&&(n._prefault=o)},Rs=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Bo(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},zs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Vo(o,t,r);let s=t.seen.get(e);s.ref=o},Bs=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Vs=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Hs=new WeakSet([Object.prototype,Error.prototype]);function Us(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Ws=G(`ZodError`,(e,t)=>{fn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Hs.has(n)||(Hs.add(n),Us(n,`format`,e=>t=>hn(e,t)),Us(n,`flatten`,e=>t=>mn(e,t)),Us(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,We,2)}),Us(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,We,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Gs=_n(Ws),Ks=vn(Ws),qs=yn(Ws),Js=xn(Ws),Ys=Dn(Ws),Xs=On(Ws),Zs=kn(Ws),Qs=An(Ws),$s=jn(Ws),ec=Mn(Ws),tc=Nn(Ws),nc=Pn(Ws);function rc(){rn.localeError||an(ka())}function ic(){rn.memoizer||an({memoizer:Ea()})}var ac=G(`ZodType`,(e,t)=>(rc(),Pr.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(rt(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return pt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Sl(e,t))},superRefine(e,t){return this.check(Cl(e,t))},overwrite(e){return this.check(Oo(e))},optional(){return il(this)},exactOptional(){return ol(this)},nullable(){return cl(this)},nullish(){return il(cl(this))},nonoptional(e){return ml(this,e)},array(){return Uc(this)},or(e){return Kc([this,e])},and(e){return Xc(this,e)},transform(e){return vl(this,nl(e))},default(e){return ul(this,e)},prefault(e){return fl(this,e)},catch(e){return gl(this,e)},pipe(e){return vl(this,e)},readonly(){return bl(this)},describe(e){let t=this.clone();return Na.add(t,{description:e}),t},meta(...e){if(e.length===0)return Na.get(this);let t=this.clone();return Na.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Bt(this,`~standard`,{...Lr(this),jsonSchema:{input:$o(this,`input`),output:$o(this,`output`)}})},set"~standard"(e){zt(this,`~standard`,e)},parse:function e(t,n){return Gs(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ks(this,t,n,{callee:e})},safeParse(e,t){return qs(this,e,t)},async safeParseAsync(e,t){return Js(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){zt(this,`spa`,e)},validate(e,t){return wn(this,e,t)},validateAsync(e,t){return En(this,e,t)},encode:function e(t,n){return Ys(this,t,n,{callee:e})},decode:function e(t,n){return Xs(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Zs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Qs(this,t,n,{callee:e})},safeEncode(e,t){return $s(this,e,t)},safeDecode(e,t){return ec(this,e,t)},async safeEncodeAsync(e,t){return tc(this,e,t)},async safeDecodeAsync(e,t){return nc(this,e,t)},toJSONSchema(e){return Qo(this,{})(e)},get description(){return Na.get(this)?.description},get _def(){return this._zod.def}}),oc=G(`_ZodString`,(e,t)=>{Rr.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)},Vt({format:e=>ds(e).format??null,minLength:e=>ds(e).minimum??null,maxLength:e=>ds(e).maximum??null},{regex(...e){return this.check(So(...e))},includes(...e){return this.check(To(...e))},startsWith(...e){return this.check(Eo(...e))},endsWith(...e){return this.check(Do(...e))},min(...e){return this.check(bo(...e))},max(...e){return this.check(yo(...e))},length(...e){return this.check(xo(...e))},nonempty(...e){return this.check(bo(1,...e))},lowercase(e){return this.check(Co(e))},uppercase(e){return this.check(wo(e))},trim(){return this.check(Ao())},normalize(...e){return this.check(ko(...e))},toLowerCase(){return this.check(jo())},toUpperCase(){return this.check(Mo())},slugify(){return this.check(No())}})),sc=G(`ZodString`,(e,t)=>{Rr.init(e,t),oc.init(e,t)},{email(e){return this.check(Ia(pc,e))},url(e){return this.check(Ha(gc,e))},jwt(e){return this.check(ro(jc,e))},emoji(e){return this.check(Ua(_c,e))},guid(e){return this.check(La(mc,e))},uuid(e){return this.check(Ra(hc,e))},uuidv4(e){return this.check(za(hc,e))},uuidv6(e){return this.check(Ba(hc,e))},uuidv7(e){return this.check(Va(hc,e))},nanoid(e){return this.check(Wa(vc,e))},cuid(e){return this.check(Ga(yc,e))},cuid2(e){return this.check(Ka(bc,e))},ulid(e){return this.check(qa(xc,e))},base64(e){return this.check(eo(Oc,e))},base64url(e){return this.check(to(kc,e))},xid(e){return this.check(Ja(Sc,e))},ksuid(e){return this.check(Ya(Cc,e))},ipv4(e){return this.check(Xa(wc,e))},ipv6(e){return this.check(Za(Tc,e))},cidrv4(e){return this.check(Qa(Ec,e))},cidrv6(e){return this.check($a(Dc,e))},e164(e){return this.check(no(Ac,e))},datetime(e){return this.check(io(lc,e))},date(e){return this.check(ao(uc,e))},time(e){return this.check(oo(dc,e))},duration(e){return this.check(so(fc,e))}});function K(e){return Fa(sc,e)}var cc=G(`ZodStringFormat`,(e,t)=>{zr.init(e,t),oc.init(e,t)}),lc=G(`ZodISODateTime`,(e,t)=>{ii.init(e,t),cc.init(e,t)}),uc=G(`ZodISODate`,(e,t)=>{ai.init(e,t),cc.init(e,t)}),dc=G(`ZodISOTime`,(e,t)=>{oi.init(e,t),cc.init(e,t)}),fc=G(`ZodISODuration`,(e,t)=>{si.init(e,t),cc.init(e,t)}),pc=G(`ZodEmail`,(e,t)=>{Hr.init(e,t),cc.init(e,t)}),mc=G(`ZodGUID`,(e,t)=>{Br.init(e,t),cc.init(e,t)}),hc=G(`ZodUUID`,(e,t)=>{Vr.init(e,t),cc.init(e,t)}),gc=G(`ZodURL`,(e,t)=>{Xr.init(e,t),cc.init(e,t)}),_c=G(`ZodEmoji`,(e,t)=>{Zr.init(e,t),cc.init(e,t)}),vc=G(`ZodNanoID`,(e,t)=>{Qr.init(e,t),cc.init(e,t)}),yc=G(`ZodCUID`,(e,t)=>{$r.init(e,t),cc.init(e,t)}),bc=G(`ZodCUID2`,(e,t)=>{ei.init(e,t),cc.init(e,t)}),xc=G(`ZodULID`,(e,t)=>{ti.init(e,t),cc.init(e,t)}),Sc=G(`ZodXID`,(e,t)=>{ni.init(e,t),cc.init(e,t)}),Cc=G(`ZodKSUID`,(e,t)=>{ri.init(e,t),cc.init(e,t)}),wc=G(`ZodIPv4`,(e,t)=>{ci.init(e,t),cc.init(e,t)}),Tc=G(`ZodIPv6`,(e,t)=>{di.init(e,t),cc.init(e,t)}),Ec=G(`ZodCIDRv4`,(e,t)=>{fi.init(e,t),cc.init(e,t)}),Dc=G(`ZodCIDRv6`,(e,t)=>{mi.init(e,t),cc.init(e,t)}),Oc=G(`ZodBase64`,(e,t)=>{_i.init(e,t),cc.init(e,t)}),kc=G(`ZodBase64URL`,(e,t)=>{bi.init(e,t),cc.init(e,t)}),Ac=G(`ZodE164`,(e,t)=>{xi.init(e,t),cc.init(e,t)}),jc=G(`ZodJWT`,(e,t)=>{Ci.init(e,t),cc.init(e,t)}),Mc=G(`ZodNumber`,(e,t)=>{wi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.isFinite=!0},Vt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=ds(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=ds(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=ds(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ds(e).format??null},{gt(e,t){return this.check(go(e,t))},gte(e,t){return this.check(_o(e,t))},min(e,t){return this.check(_o(e,t))},lt(e,t){return this.check(mo(e,t))},lte(e,t){return this.check(ho(e,t))},max(e,t){return this.check(ho(e,t))},int(e){return this.check(Fc(e))},safe(e){return this.check(Fc(e))},positive(e){return this.check(go(0,e))},nonnegative(e){return this.check(_o(0,e))},negative(e){return this.check(mo(0,e))},nonpositive(e){return this.check(ho(0,e))},multipleOf(e,t){return this.check(vo(e,t))},step(e,t){return this.check(vo(e,t))},finite(){return this}}));function Nc(e){return co(Mc,e)}var Pc=G(`ZodNumberFormat`,(e,t)=>{Ti.init(e,t),Mc.init(e,t)});function Fc(e){return lo(Pc,e)}var Ic=G(`ZodBoolean`,(e,t)=>{Ei.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r)});function Lc(e){return uo(Ic,e)}var Rc=G(`ZodUnknown`,(e,t)=>{Di.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function zc(){return fo(Rc)}var Bc=G(`ZodNever`,(e,t)=>{Oi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r)});function Vc(e){return po(Bc,e)}var Hc=G(`ZodArray`,(e,t)=>{ic(),Ai.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.element=t.element},{min(e,t){return this.check(bo(e,t))},nonempty(e){return this.check(bo(1,e))},max(e,t){return this.check(yo(e,t))},length(e,t){return this.check(xo(e,t))},unwrap(){return this.element}});function Uc(e,t){return Po(Hc,e,t)}var Wc=G(`ZodObject`,(e,t)=>{ic(),Ii.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),Jt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return J(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(rt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(rt(this._zod.def,{catchall:zc()}))},loose(){return this.clone(rt(this._zod.def,{catchall:zc()}))},strict(){return this.clone(rt(this._zod.def,{catchall:Vc()}))},strip(){return this.clone(rt(this._zod.def,{catchall:void 0}))},extend(e){return xt(this,e)},safeExtend(e){return Ct(this,e)},merge(e){return wt(this,e)},pick(e){return vt(this,e)},omit(e){return bt(this,e)},partial(...e){return Tt(rl,this,e[0])},exactPartial(...e){return Tt(al,this,e[0],`exactPartial`)},required(...e){return Et(pl,this,e[0])}});function q(e,t){return new Wc({type:`object`,shape:e??{},...W(t)})}var Gc=G(`ZodUnion`,(e,t)=>{Ri.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.options=t.options});function Kc(e,t){return new Gc({type:`union`,options:e,...W(t)})}var qc=G(`ZodDiscriminatedUnion`,(e,t)=>{Gc.init(e,t),Bi.init(e,t)});function Jc(e,t,n){return new qc({type:`union`,options:t,discriminator:e,...W(n)})}var Yc=G(`ZodIntersection`,(e,t)=>{Vi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r)});function Xc(e,t){return new Yc({type:`intersection`,left:e,right:t})}var Zc=G(`ZodRecord`,(e,t)=>{ic(),Wi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Qc(e,t,n){return!t||!t._zod?new Zc({type:`record`,keyType:K(),valueType:e,...W(t)}):new Zc({type:`record`,keyType:e,valueType:t,...W(n)})}var $c=G(`ZodEnum`,(e,t)=>{Gi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new $c({...t,checks:[],...W(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new $c({...t,checks:[],...W(r),entries:i})}});function J(e,t){return new $c({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...W(t)})}var el=G(`ZodLiteral`,(e,t)=>{Ki.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Y(e,t){return new el({type:`literal`,values:Array.isArray(e)?e:[e],...W(t)})}var tl=G(`ZodTransform`,(e,t)=>{ic(),qi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Lt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Lt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function nl(e){return new tl({type:`transform`,transform:e})}var rl=G(`ZodOptional`,(e,t)=>{Yi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function il(e){return new rl({type:`optional`,innerType:e})}var al=G(`ZodExactOptional`,(e,t)=>{Xi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ol(e){return new al({type:`optional`,innerType:e})}var sl=G(`ZodNullable`,(e,t)=>{Zi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cl(e){return new sl({type:`nullable`,innerType:e})}var ll=G(`ZodDefault`,(e,t)=>{Qi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ul(e,t){return new ll({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ut(t)}})}var dl=G(`ZodPrefault`,(e,t)=>{ea.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fl(e,t){return new dl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ut(t)}})}var pl=G(`ZodNonOptional`,(e,t)=>{ta.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ml(e,t){return new pl({type:`nonoptional`,innerType:e,...W(t)})}var hl=G(`ZodCatch`,(e,t)=>{ia.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gl(e,t){return new hl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Xt(t)})}var _l=G(`ZodPipe`,(e,t)=>{aa.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.in=t.in,e.out=t.out});function vl(e,t){return new _l({type:`pipe`,in:e,out:t})}var yl=G(`ZodReadonly`,(e,t)=>{sa.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bl(e){return new yl({type:`readonly`,innerType:e})}var xl=G(`ZodCustom`,(e,t)=>{la.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Sl(e,t={}){return Fo(xl,e,t)}function Cl(e,t){return Io(e,t)}var wl=J([`T0`,`T1`,`T2`,`T3`]);J([`owner`,`guest`,`member`,`voice-device`]);var Tl=Nc().min(0).max(1),El=Kc([J([`auto`,`center`,`left`,`right`,`top`,`bottom`]),q({x:Tl,y:Tl,w:Tl,h:Tl})]),Dl=J([`ambient`,`conversation`,`focus`,`multi`]),Ol=J([`idle`,`listening`,`thinking`,`speaking`]),kl=J([`sphere`,`orb`,`ring`]),Al=q({id:K().min(1).max(64),type:J([`card`,`stat`,`list`,`table`,`code`,`chart`,`gauge`,`timeline`,`graph`,`sandbox`,`markdown`,`image`,`video`,`pdf`,`gallery`,`group`,`tabs`,`progress`,`checklist`,`countdown`,`kv`]),props:Qc(K(),zc()),placement:El,ttl:Nc().positive().max(3600).optional(),style:J([`glass`,`alert`]).optional(),layer:J([`base`,`overlay`]).optional(),pinned:Lc().optional()}),jl=Jc(`cmd`,[q({cmd:Y(`scene`),mode:Dl}),q({cmd:Y(`show`),object:Al}),q({cmd:Y(`update`),id:K(),props:Qc(K(),zc())}),q({cmd:Y(`hide`),id:K()}),q({cmd:Y(`clear`)}),q({cmd:Y(`pin`),id:K()}),q({cmd:Y(`unpin`),id:K()}),q({cmd:Y(`place`),id:K(),placement:El}),q({cmd:Y(`presence`),state:Ol.optional(),style:kl.optional()}),q({cmd:Y(`mood`),accent:K().max(16).optional(),intensity:Tl.optional()})]),Ml=q({scene:Dl,objects:Uc(Al),presence:q({state:Ol,style:kl}),mood:q({accent:K(),intensity:Tl})}),Nl={center:[20,18,60,58],left:[3,12,30,70],right:[67,12,30,70],top:[20,4,60,30],bottom:[20,62,60,30]};Object.keys(Nl);var Pl=[{id:`en_US-amy-medium`,name:`Amy`,gender:`female`,accent:`American`},{id:`en_US-kristin-medium`,name:`Kristin`,gender:`female`,accent:`American`},{id:`en_US-hfc_female-medium`,name:`Hannah`,gender:`female`,accent:`American`,note:`clear and steady`},{id:`en_GB-jenny_dioco-medium`,name:`Jenny`,gender:`female`,accent:`British`},{id:`en_GB-alba-medium`,name:`Alba`,gender:`female`,accent:`Scottish`},{id:`en_US-kathleen-low`,name:`Kathleen`,gender:`female`,accent:`American`,note:`smaller and faster`},{id:`en_US-ryan-medium`,name:`Ryan`,gender:`male`,accent:`American`},{id:`en_US-joe-medium`,name:`Joe`,gender:`male`,accent:`American`},{id:`en_US-norman-medium`,name:`Norman`,gender:`male`,accent:`American`},{id:`en_US-hfc_male-medium`,name:`Henry`,gender:`male`,accent:`American`,note:`clear and steady`},{id:`en_GB-alan-medium`,name:`Alan`,gender:`male`,accent:`British`},{id:`en_GB-northern_english_male-medium`,name:`Tom`,gender:`male`,accent:`Northern English`}],Fl=[{id:`hi_IN-priyamvada-medium`,name:`Priyamvada`,gender:`female`,accent:`Hindi`,note:`for personal use (non-commercial licence)`},{id:`hi_IN-pratham-medium`,name:`Pratham`,gender:`male`,accent:`Hindi`,note:`for personal use (non-commercial licence)`},{id:`hi_IN-rohan-medium`,name:`Rohan`,gender:`male`,accent:`Hindi`}],Il=[{id:`mr_IN-google-medium`,name:`Marathi`,gender:`female`,accent:`Marathi`}],Ll={id:`en_US-lessac-medium`,name:`Lessac`,accent:`American`,note:`the original voice`},Rl=e=>e===Ll.id||Pl.some(t=>t.id===e),zl=[{id:`aurora`,name:`Aurora`,style:`sphere`,accent:`#3fd8ff`,intensity:.6},{id:`ocean`,name:`Ocean`,style:`sphere`,accent:`#2b7bff`,intensity:.6},{id:`ember`,name:`Ember`,style:`orb`,accent:`#ff9b3d`,intensity:.7},{id:`violet`,name:`Violet storm`,style:`orb`,accent:`#a066ff`,intensity:.8},{id:`matrix`,name:`Matrix`,style:`ring`,accent:`#3dff8c`,intensity:.6},{id:`rose`,name:`Rose`,style:`ring`,accent:`#ff6fae`,intensity:.7},{id:`ghost`,name:`Ghost`,style:`sphere`,accent:`#e8f4ff`,intensity:.4}],Bl=[`local`,`spotify`,`soundcloud`,`audius`],Vl=/^[0-9a-f]{16}$/,Hl=/^[0-9]{1,20}$/,Ul=/^[A-Za-z0-9_-]{1,64}$/;function Wl(e){if(typeof e!=`string`)return null;if(Vl.test(e))return{source:`local`,id:e};let t=e.indexOf(`:`);if(t<1)return null;let n=e.slice(0,t),r=e.slice(t+1);return!Bl.includes(n)||!(n===`local`?Vl:n===`soundcloud`?Hl:Ul).test(r)?null:{source:n,id:r}}var Gl=J([`minimal`,`companion`,`workspace`]),Kl=q({size:Nc().min(.5).max(1.5),reactivity:Nc().min(0).max(1),ambient:Lc(),captions:Lc(),captionSize:J([`small`,`medium`,`large`])}),ql={width:Nc().int().min(100).max(1e4),height:Nc().int().min(100).max(1e4),kind:J([`phone`,`tablet`,`desktop`]),orientation:J([`portrait`,`landscape`]),touch:Lc()};q(ql);var Jl=q({id:K(),tool:K(),summary:K(),tier:wl,needsPin:Lc()}),Yl=q({id:K().refine(e=>Wl(e)!==null,`A track id or a source:id ref`),title:K().max(200),artist:K().max(200),album:K().max(200),durationSec:Nc().nullable()}),Xl=q({playing:Lc(),trackId:K().max(80).nullable(),title:K().max(200),artist:K().max(200),album:K().max(200),position:Nc().min(0),duration:Nc().min(0),volume:Nc().min(0).max(100),muted:Lc(),shuffle:Lc(),repeat:J([`off`,`all`,`one`]),view:J([`mini`,`full`,`hidden`]),queue:Uc(q({id:K().max(80),title:K().max(200)})).max(50),index:Nc().int().min(-1),active:Lc()}),Zl=q({action:J([`play`,`pause`,`resume`,`toggle`,`stop`,`next`,`previous`,`seek`,`volume`,`mute`,`shuffle`,`repeat`,`view`,`queue.remove`,`queue.clear`,`jump`]),tracks:Uc(Yl).max(500).optional(),mode:J([`replace`,`add`,`next`,`off`,`all`,`one`]).optional(),shuffle:Lc().optional(),seconds:Nc().min(0).optional(),percent:Nc().min(0).max(100).optional(),level:Nc().min(0).max(100).optional(),delta:Nc().min(-100).max(100).optional(),on:Lc().optional(),view:J([`mini`,`full`,`hidden`]).optional(),index:Nc().int().min(0).optional()}),Ql=q({terminalLabel:K().max(24),clock:q({hour12:Lc(),seconds:Lc(),locale:K().max(35)}),launcher:Uc(q({id:K().max(20),label:K().max(24),icon:K().max(16),action:q({type:J([`url`,`prompt`,`panel`,`music`]),value:K().max(500)})})).max(12),animations:J([`full`,`reduced`,`off`])}),$l=q({folderSet:Lc(),volume:Nc().min(0).max(100),shuffle:Lc(),repeat:J([`off`,`all`,`one`]),visualizer:Lc(),startView:J([`mini`,`full`]),output:J([`screen`,`host`]).optional()}),eu=Jc(`type`,[q({type:Y(`music.command`)}).merge(Zl),q({type:Y(`music.host`),state:Xl}),q({type:Y(`stage`),command:jl}),q({type:Y(`caption.delta`),text:K()}),q({type:Y(`caption.end`)}),q({type:Y(`approval.request`)}).merge(Jl),q({type:Y(`approval.resolved`),id:K()}),q({type:Y(`alert`),level:J([`info`,`warn`,`error`]),text:K()}),q({type:Y(`chat.user`),text:K()}),q({type:Y(`ui`),view:Gl,look:Kl.optional(),ownerName:K().max(40).optional(),assistantName:K().max(40).optional(),hud:Ql.optional(),music:$l.optional()}),q({type:Y(`activity`),text:K().max(80).nullable()}),q({type:Y(`status`),busy:Lc(),deviceOnline:Lc(),voiceAvailable:Lc().optional(),voiceEnrolled:Lc().optional(),message:K().optional()}),q({type:Y(`voice.heard`),text:K(),trust:J([`owner`,`guest`,`unverified`,`member`]).optional(),speaker:K().max(60).optional()}),q({type:Y(`voice.challenge`),id:K(),text:K()}),q({type:Y(`voice.challenge.end`),id:K()}),q({type:Y(`audio.chunk`),id:K(),seq:Nc().int().min(0),last:Lc(),mime:K(),data:K()}),q({type:Y(`audio.stop`)}),q({type:Y(`camera.request`),id:K()}),q({type:Y(`camera.cancel`),id:K()}),q({type:Y(`ui.open`),panel:Y(`plugins`),integration:K().max(40).optional()}),q({type:Y(`screen.request`),id:K()}),q({type:Y(`screen.cancel`),id:K()}),q({type:Y(`snapshot`),stage:Ml,pendingApproval:Jl.nullable().optional()}),q({type:Y(`error`),message:K()})]),tu=q({type:Y(`approval.respond`),id:K(),decision:J([`approve`,`deny`,`approve_always`]),pin:K().max(32).optional()});Jc(`type`,[q({type:Y(`chat.send`),text:K().min(1).max(8e3)}),q({type:Y(`stage.event`),objectId:K(),event:K().max(64)}),tu,q({type:Y(`voice.interrupt`)}),q({type:Y(`voice.confirm`),id:K(),pin:K().max(32)}),q({type:Y(`voice.cancel`),id:K()}),q({type:Y(`camera.denied`),id:K(),reason:J([`off`,`no-camera`,`permission`,`busy`])}),q({type:Y(`screen.denied`),id:K(),reason:J([`unsupported`,`failed`,`busy`])}),q({type:Y(`ui.panels`),open:Uc(J([`chat`,`tasks`])).max(2)}),q({type:Y(`ui.screen`),...ql}),q({type:Y(`stage.move`),objectId:K().max(64),rect:q({x:Nc().min(0).max(1),y:Nc().min(0).max(1),w:Nc().min(0).max(1),h:Nc().min(0).max(1)})}),q({type:Y(`stage.pin`),objectId:K().max(64),pinned:Lc()}),q({type:Y(`music.state`),state:Xl}),q({type:Y(`music.remote`),command:Zl}),q({type:Y(`ping`)})]),q({type:Y(`tool.exec`),id:K(),tool:K(),args:zc(),approvedOutside:Lc().optional()}),Jc(`type`,[q({type:Y(`tool.result`),id:K(),result:q({output:K(),truncated:Lc()})}),q({type:Y(`tool.error`),id:K(),error:K()})]),q({path:K()}),q({path:K()}),q({path:K(),content:K()}),q({}),q({}),q({command:K().min(1),cwd:K().optional()}),q({city:K().min(1).max(80)}),q({plugin:K().min(1).max(40),name:K().min(1).max(40)}),q({language:J([`python`,`node`,`shell`]),code:K().min(1).max(5e4),timeoutSec:Nc().int().min(1).max(60).optional()}),q({text:K().min(1).max(4e3)}),q({query:K().min(1).max(200)}),q({id:Nc().int().positive()}),q({title:K().min(1).max(1e3),inMinutes:Nc().int().min(1).max(525600).optional(),dueAt:K().max(40).optional(),repeat:J([`hourly`,`daily`,`weekly`]).optional()}),q({}),q({id:Nc().int().positive()}),q({id:Nc().int().positive()}),q({}),q({path:K().min(1).max(1e3),id:K().min(1).max(64).optional(),title:K().max(120).optional(),placement:El.optional()}),q({}),q({}),q({id:K().min(1).max(40)}),q({id:J([`telegram`,`twilio`,`zerodha`,`alexa`]).optional()}),q({id:J([`telegram`,`twilio`,`zerodha`,`alexa`]),enabled:Lc().optional(),accountSid:K().max(64).optional(),smsFrom:K().max(30).optional(),whatsappFrom:K().max(30).optional(),ownerNumber:K().max(30).optional()}).strict(),q({id:J([`telegram`,`twilio`,`zerodha`,`alexa`])}),q({id:J([`telegram`,`twilio`,`zerodha`,`alexa`])}),q({channel:J([`telegram`,`sms`,`whatsapp`]),to:K().min(1).max(40),text:K().min(1).max(1500)}),q({channel:J([`telegram`,`sms`,`whatsapp`]).optional(),unread:Lc().optional(),limit:Nc().int().min(1).max(20).optional()}),q({}).strict(),q({}).strict(),q({}).strict(),q({}).strict(),q({}).strict(),q({}).strict(),q({kind:J([`morning`,`close`,`custom`]).optional(),send:Lc().optional()}).strict(),q({name:K().min(1).max(60),kind:J([`morning`,`close`,`custom`]),time:K().regex(/^([01]\d|2[0-3]):[0-5]\d$/),days:Uc(Nc().int().min(1).max(7)).min(1).max(7).optional(),channel:J([`telegram`,`whatsapp`,`sms`]),commentary:Lc().optional()}).strict(),q({}).strict(),q({id:Nc().int().min(1)}).strict(),q({query:K().max(200).optional(),title:K().max(200).optional(),artist:K().max(200).optional(),album:K().max(200).optional(),shuffle:Lc().optional(),mode:J([`replace`,`add`,`next`]).optional(),limit:Nc().int().min(1).max(500).optional(),source:J([`local`,`spotify`,`soundcloud`,`audius`,`any`]).optional()}).strict(),q({action:J([`pause`,`resume`,`toggle`,`stop`,`next`,`previous`,`seek`,`volume`,`mute`,`shuffle`,`repeat`,`view`]),level:Nc().min(0).max(100).optional(),delta:Nc().min(-100).max(100).optional(),seconds:Nc().min(0).optional(),percent:Nc().min(0).max(100).optional(),on:Lc().optional(),mode:J([`off`,`all`,`one`]).optional(),view:J([`mini`,`full`,`hidden`]).optional()}).strict(),q({action:J([`add`,`remove`,`clear`,`show`]),query:K().max(200).optional(),index:Nc().int().min(1).optional(),source:J([`local`,`spotify`,`soundcloud`,`audius`,`any`]).optional()}).strict(),q({query:K().max(200),limit:Nc().int().min(1).max(15).optional(),source:J([`local`,`spotify`,`soundcloud`,`audius`,`any`]).optional()}).strict(),q({}).strict(),q({}),q({settings:Qc(K(),zc())}),q({style:kl.optional(),accent:K().regex(/^#[0-9a-fA-F]{6}$/).optional(),intensity:Nc().min(0).max(1).optional(),size:Nc().min(.5).max(1.5).optional(),reactivity:Nc().min(0).max(1).optional(),ambient:Lc().optional(),captions:Lc().optional(),captionSize:J([`small`,`medium`,`large`]).optional()}),q({view:Gl}),q({}),q({id:K().min(1).max(16),name:K().min(1).max(60),kind:J([`stdio`,`http`]),command:K().max(260).optional(),args:Uc(K().max(500)).max(20).optional(),url:K().max(2e3).optional()}),q({id:K().min(1).max(16)}),q({id:K().min(1).max(16)}),q({id:K().min(1).max(16)}),q({id:K().min(1).max(16)}),q({}),q({id:K().min(1).max(40),name:K().min(1).max(80),description:K().max(500).optional(),skills:Uc(q({name:K().min(1).max(40),description:K().min(1).max(300),text:K().min(1).max(2e4)})).max(10).optional(),tools:Uc(q({name:K().min(1).max(40),description:K().min(1).max(500),language:J([`python`,`node`,`shell`]),code:K().min(1).max(5e4),parameters:Qc(K(),q({type:J([`string`,`number`,`integer`,`boolean`]),description:K().max(300).optional(),enum:Uc(K().max(100)).max(50).optional()})).optional(),required:Uc(K()).optional()})).max(10).optional()}),q({}),q({id:K().min(1).max(40)}),q({id:K().min(1).max(40)}),q({id:K().min(1).max(40)}),q({mode:Dl}),q({object:Al}),q({topic:J([`all`,`widgets`,`layout`,`overlay`,`theme`,`files`,`recipes`]).optional()}),q({id:K(),props:Qc(K(),zc())}),q({id:K()}),q({}),q({id:K()}),q({id:K()}),q({state:Ol.optional(),style:kl.optional()}),q({accent:K().max(16).optional(),intensity:Nc().min(0).max(1).optional()});var nu=new Set([`alexa`,`amazon`,`echo`,`skill`,`app`,`ask`,`tell`,`open`,`start`,`run`,`enable`,`launch`,`load`,`begin`,`use`]),ru=50;function iu(e){let t=e.trim().split(/\s+/).filter(Boolean);if(t.length<1)return`Enter the name you will say after "Alexa, ask".`;if(e.length>ru)return`That is too long (at most ${ru} characters).`;if(!/^[a-z' ]+$/.test(e))return`Use lower-case letters, spaces and apostrophes only. Spell numbers out as words.`;let n=t.find(e=>nu.has(e));return n?`The word "${n}" cannot be in the name (it is reserved by Alexa).`:null}var au=[`mp3`,`m4a`,`aac`,`ogg`,`opus`,`wav`,`flac`],ou={maxTracks:{min:100,max:5e4,def:5e3},scanDepth:{min:1,max:12,def:6},volume:{min:0,max:100,def:70},searchLimit:{min:3,max:50,def:10}},su=[`chat`,`tasks`,`plugins`,`settings`,`music`],cu=[`toggle`,`play`,`pause`,`next`,`previous`],lu=[`url`,`prompt`,`panel`,`music`];function uu(e){let t=e&&typeof e==`object`?e:null;if(!t)return`A button needs a label and an action.`;let n=typeof t.label==`string`?t.label.trim():``;if(n.length<1||n.length>24)return`A button label is 1 to 24 characters.`;let r=typeof t.icon==`string`?t.icon.trim():``;if(r.length<1||[...r].length>4)return`A button icon is 1 to 4 characters (a symbol or an emoji).`;let i=t.action&&typeof t.action==`object`?t.action:null;if(!i||!lu.includes(i.type)||typeof i.value!=`string`)return`A button needs an action: an address, a question, a panel or a music control.`;let a=i.value.trim();switch(i.type){case`url`:if(a.length>500)return`A button address is at most 500 characters.`;try{let e=new URL(a);return e.protocol===`https:`||e.protocol===`http:`?null:`A button address must start with https:// or http://.`}catch{return`A button address must start with https:// or http://.`}case`prompt`:return a.length>=1&&a.length<=500?null:`A question for the assistant is 1 to 500 characters.`;case`panel`:return su.includes(a)?null:`A panel is one of: ${su.join(`, `)}.`;default:return cu.includes(a)?null:`A music control is one of: ${cu.join(`, `)}.`}}function du(e){return e===``?null:e.length>260?`That program name is too long.`:/\s/.test(e)?`Use the program's name, or a short path with no spaces (or add the program to your PATH). Arguments cannot be added here.`:e.startsWith(`-`)||!/^[A-Za-z0-9._:\\/~+-]+$/.test(e)?`A program is a name or a path made of letters, digits and . _ : / \\ ~ + - only, and cannot start with a dash.`:null}var fu=2e3,pu=3,mu=e=>({queue:[],index:-1,playing:!1,position:0,duration:0,volume:e.volume,muted:!1,shuffle:e.shuffle,repeat:e.repeat,view:e.view});function hu(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;e--){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var gu=(e,t,n)=>Math.min(n,Math.max(t,e)),_u=(e,t,n)=>({...e,index:t,playing:n,position:0,duration:0});function vu(e,t,n={}){let r=n.shuffle??hu,i=e.queue.length-1;switch(t.type){case`play`:{if(t.tracks.length===0)return e;let n=t.tracks.slice(0,fu);if(t.mode===`replace`){let i=t.shuffle?r(n):n;return{..._u(e,t.shuffle?0:gu(t.start??0,0,i.length-1),!0),queue:i,shuffle:t.shuffle?!0:e.shuffle}}if(e.queue.length===0)return{..._u(e,0,!0),queue:n};let i=t.mode===`next`?e.index+1:e.queue.length;return{...e,queue:[...e.queue.slice(0,i),...n,...e.queue.slice(i)].slice(0,fu)}}case`next`:return i<0?e:e.index<i?_u(e,e.index+1,!0):e.repeat===`off`?{...e,playing:!1,position:0}:_u(e,0,!0);case`previous`:return i<0?e:e.position>pu?{...e,position:0}:e.index>0?_u(e,e.index-1,e.playing||!0):e.repeat===`all`?_u(e,i,!0):{...e,position:0};case`ended`:return i<0?e:e.repeat===`one`?_u(e,e.index,!0):e.index<i?_u(e,e.index+1,!0):e.repeat===`all`?_u(e,0,!0):{...e,playing:!1,position:0};case`failed`:return i<0?e:e.index<i?_u(e,e.index+1,!0):{...e,playing:!1,position:0};case`pause`:return e.playing?{...e,playing:!1}:e;case`resume`:return e.index>=0&&!e.playing?{...e,playing:!0}:e;case`toggle`:return e.index<0?e:{...e,playing:!e.playing};case`stop`:return{...e,playing:!1,position:0};case`volume`:{let n=typeof t.level==`number`?Math.round(t.level):typeof t.delta==`number`?e.volume+Math.round(t.delta):e.volume;return{...e,volume:gu(n,0,100),muted:typeof t.level==`number`||(t.delta??0)>0?!1:e.muted}}case`mute`:return{...e,muted:t.on??!e.muted};case`seek`:{let n=typeof t.seconds==`number`?t.seconds:typeof t.percent==`number`?e.duration*gu(t.percent,0,100)/100:e.position;return{...e,position:gu(n,0,e.duration>0?e.duration:Math.max(n,0))}}case`repeat`:return{...e,repeat:t.mode};case`shuffle`:{if(!(t.on??!e.shuffle))return{...e,shuffle:!1};let n=e.queue.slice(0,e.index+1);return{...e,shuffle:!0,queue:[...n,...r(e.queue.slice(e.index+1))]}}case`view`:return{...e,view:t.view};case`remove`:{if(!Number.isInteger(t.index)||t.index<0||t.index>i)return e;let n=e.queue.filter((e,n)=>n!==t.index);return n.length===0?{...e,queue:n,index:-1,playing:!1,position:0,duration:0}:t.index<e.index?{...e,queue:n,index:e.index-1}:t.index>e.index?{...e,queue:n}:t.index<n.length?{..._u(e,t.index,e.playing),queue:n}:e.repeat===`all`?{..._u(e,0,e.playing),queue:n}:{...e,queue:n,index:n.length-1,playing:!1,position:0}}case`clear`:return{...e,queue:[],index:-1,playing:!1,position:0,duration:0};case`jump`:return Number.isInteger(t.index)&&t.index>=0&&t.index<=i?_u(e,t.index,!0):e;case`time`:return{...e,position:Math.max(0,t.position),duration:Math.max(0,t.duration)}}}function yu(e){switch(e.action){case`play`:return{type:`play`,tracks:e.tracks??[],mode:e.mode===`add`||e.mode===`next`?e.mode:`replace`,...e.shuffle?{shuffle:!0}:{},...e.index===void 0?{}:{start:e.index}};case`pause`:case`resume`:case`toggle`:case`stop`:case`next`:case`previous`:return{type:e.action};case`seek`:return{type:`seek`,...e.seconds===void 0?{}:{seconds:e.seconds},...e.percent===void 0?{}:{percent:e.percent}};case`volume`:return{type:`volume`,...e.level===void 0?{}:{level:e.level},...e.delta===void 0?{}:{delta:e.delta}};case`mute`:return{type:`mute`,...e.on===void 0?{}:{on:e.on}};case`shuffle`:return{type:`shuffle`,...e.on===void 0?{}:{on:e.on}};case`repeat`:return e.mode===`off`||e.mode===`all`||e.mode===`one`?{type:`repeat`,mode:e.mode}:null;case`view`:return e.view?{type:`view`,view:e.view}:null;case`queue.remove`:return e.index===void 0?null:{type:`remove`,index:e.index};case`queue.clear`:return{type:`clear`};case`jump`:return e.index===void 0?null:{type:`jump`,index:e.index};default:return null}}function bu(e){switch(e.type){case`play`:return{action:`play`,tracks:e.tracks,mode:e.mode,...e.shuffle?{shuffle:!0}:{},...e.start===void 0?{}:{index:e.start}};case`next`:case`previous`:case`pause`:case`resume`:case`toggle`:case`stop`:return{action:e.type};case`volume`:return{action:`volume`,...e.level===void 0?{}:{level:e.level},...e.delta===void 0?{}:{delta:e.delta}};case`mute`:return{action:`mute`,...e.on===void 0?{}:{on:e.on}};case`seek`:return{action:`seek`,...e.seconds===void 0?{}:{seconds:e.seconds},...e.percent===void 0?{}:{percent:e.percent}};case`repeat`:return{action:`repeat`,mode:e.mode};case`shuffle`:return{action:`shuffle`,...e.on===void 0?{}:{on:e.on}};case`view`:return{action:`view`,view:e.view};case`remove`:return{action:`queue.remove`,index:e.index};case`clear`:return{action:`queue.clear`};case`jump`:return{action:`jump`,index:e.index};default:return null}}function xu({label:e,value:t,onChange:n,min:r,max:i,step:a}){let[o,s]=(0,l.useState)(String(t));return(0,l.useEffect)(()=>{s(e=>Number(e)===t?e:String(t))},[t]),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`number`,min:r,max:i,step:a,value:o,onChange:e=>{s(e.target.value),e.target.value.trim()!==``&&Number.isFinite(Number(e.target.value))&&n(Number(e.target.value))},onBlur:()=>s(String(t)),style:d})]})}async function Su(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var Cu={status:()=>Su(`/api/alexa`),allow:async(e,t)=>void await Su(`/api/alexa/devices/allow`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e,pin:t})}),forget:async e=>void await Su(`/api/alexa/devices/${encodeURIComponent(e)}`,{method:`DELETE`})},wu=/^amzn1\.ask\.skill\.[A-Za-z0-9-]{8,80}$/;function Tu(e){return e.skillId.trim()&&!wu.test(e.skillId.trim())?`A skill ID looks like amzn1.ask.skill.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (copy it from the console).`:e.invocationName.trim()?iu(e.invocationName):null}var Eu={"skill.json":`the skill's manifest (name, endpoint)`,"en-IN.json":`the English (India) interaction model`,"hi-IN.json":`the Hindi (India) interaction model`},Du={"en-IN":`English (India)`,"hi-IN":`Hindi (India)`},Ou=e=>{let t=Math.max(0,Math.round((Date.now()-e)/6e4));return t<1?`just now`:t<60?`${t} min ago`:`${Math.round(t/60)} h ago`};function ku({view:e,setView:t,api:n=Cu}){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(``),[u,f]=(0,l.useState)(null),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(!1),v=(0,l.useRef)(!0),y=(0,l.useCallback)(()=>n.status().then(e=>v.current&&i(e)).catch(()=>{}),[n]);(0,l.useEffect)(()=>(v.current=!0,y(),()=>{v.current=!1}),[y]);let b=async e=>{_(!0),f(null);try{await e()}catch(e){v.current&&f(e.message)}finally{v.current&&_(!1)}},S=Tu(e),C=r?.invocationName||e.invocationName,w=!!r?.endpoint&&!!r.invocationName;return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Friend talks to a skill of your own on Alexa. It is free: the skill stays in development mode in your own Amazon developer account and is never published, and only the Echo devices you allow can use it. Alexa can look things up and answer; anything that changes something is refused, or sent to your phone for a yes.`}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`In the Alexa developer console`}),r&&r.endpoint?(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Endpoint to paste (HTTPS, "My development endpoint has a certificate from a trusted certificate authority"): `,(0,p.jsx)(`code`,{children:r.endpoint}),` `,(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{navigator.clipboard?.writeText(r.endpoint).then(()=>h(!0),()=>{})},children:m?`Copied`:`Copy`})]}):r&&(0,p.jsx)(`p`,{className:`auth-note`,children:`No public address is set yet, so Amazon cannot reach Friend (friend config set publicUrl https://…).`}),(0,p.jsx)(`p`,{className:`auth-note`,children:`If your address changes later, paste the new address into the console again. Nothing else needs to change.`}),w?(0,p.jsx)(`ul`,{className:`plugins-list`,children:r.files.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`a`,{href:`/api/alexa/package/${e}`,download:e,children:e}),` `,(0,p.jsx)(`small`,{className:`auth-note`,children:Eu[e]??``})]},e))}):r&&r.endpoint&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Save an invocation name first; the files are made with it.`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Skill ID`}),(0,p.jsx)(`input`,{value:e.skillId,autoComplete:`off`,onChange:n=>t({...e,skillId:n.target.value}),placeholder:`amzn1.ask.skill.…`,style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Invocation name`}),(0,p.jsx)(`input`,{value:e.invocationName,autoComplete:`off`,onChange:n=>t({...e,invocationName:n.target.value}),placeholder:`jarvis assistant`,style:d})]}),S&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:S}),(0,p.jsxs)(`details`,{children:[(0,p.jsx)(`summary`,{className:`plugins-heading`,children:`Advanced`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Skill name`}),(0,p.jsx)(`input`,{value:e.skillName,onChange:n=>t({...e,skillName:n.target.value}),style:d})]}),(0,p.jsx)(`div`,{className:`settings-field`,role:`group`,"aria-label":`Languages`,children:Object.entries(Du).map(([n,r])=>(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.locales.includes(n),onChange:r=>{let i=r.target.checked?[...e.locales,n]:e.locales.filter(e=>e!==n);i.length>0&&t({...e,locales:Object.keys(Du).filter(e=>i.includes(e))})}}),(0,p.jsx)(`span`,{children:r})]},n))}),(0,p.jsx)(xu,{label:`Seconds to work on an answer`,value:e.answerSeconds,min:2,max:7.5,step:.5,onChange:n=>t({...e,answerSeconds:n})}),(0,p.jsx)(xu,{label:`Minutes to keep a late answer`,value:e.holdMinutes,min:1,max:60,onChange:n=>t({...e,holdMinutes:n})}),(0,p.jsx)(xu,{label:`Seconds to wait for your yes on your phone`,value:e.permissionSeconds,min:30,max:600,onChange:n=>t({...e,permissionSeconds:n})}),(0,p.jsx)(xu,{label:`Requests a minute allowed`,value:e.requestsPerMinute,min:10,max:600,onChange:n=>t({...e,requestsPerMinute:n})}),(0,p.jsx)(xu,{label:`Echo devices allowed`,value:e.maxDevices,min:1,max:50,onChange:n=>t({...e,maxDevices:n})}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Extra tools a voice may use without asking (one per line)`}),(0,p.jsx)(`textarea`,{rows:2,value:e.extraVoiceTools.join(`
|
|
65
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Wo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Wo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Go=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ko=[`oneOf`,`anyOf`];function qo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Jo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Go.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??qo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Xe(n,r,e.length===1?e[0]:Jo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=qo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Yo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Go)if(t in e)return;let n=t.filter(e=>Ko.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Jo(t);else{let e=n[0],i=Ko.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Jo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ro(e,r))}function Xo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Ro(i,s),Ro(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Wo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Yo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Ro(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Xe(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:$o(t,`input`,e.processors),output:$o(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Zo(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Zo(r.element,n);if(r.type===`set`)return Zo(r.valueType,n);if(r.type===`lazy`)return Zo(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Zo(r.innerType,n);if(r.type===`intersection`)return Zo(r.left,n)||Zo(r.right,n);if(r.type===`record`||r.type===`map`)return Zo(r.keyType,n)||Zo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Zo(r.in,n)||Zo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Zo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Zo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Zo(e,n))return!0;return!!(r.rest&&Zo(r.rest,n))}return!1}var Qo=(e,t={})=>n=>{let r=zo({...n,processors:t});return Vo(e,r),Uo(r,e),Xo(r,e)},$o=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=zo({...i??{},target:a,io:t,processors:n});return Vo(e,o),Uo(o,e),Xo(o,e)},es=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},ts=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},ns=(e,t)=>{es(e,`minimum`,t),ts(e,`maximum`,t)},rs=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},is=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},as=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},os=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},ss=(e,t)=>es(e,`minimum`,t.minimum),cs=(e,t)=>ts(e,`maximum`,t.maximum),ls=e=>(t,n)=>{os(t,n.format);let[r,i]=e[n.format];es(t,`minimum`,r),ts(t,`maximum`,i)},us={greater_than:(e,t)=>es(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>ts(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>rs(e,t.value),number_format:ls(gt),bigint_format:ls(_t),min_length:ss,max_length:cs,length_equals:(e,t)=>ns(e,t.length),min_size:ss,max_size:cs,size_equals:(e,t)=>ns(e,t.size),string_format:(e,t)=>{os(e,t.format),t.pattern&&is(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>as(e,t.mime)};function ds(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)us[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&es(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&es(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&ts(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&ts(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&rs(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&as(t,i.mime);for(let e of i.patterns??[])is(t,e);return t}var fs={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ps=new Map([[gi,Qn],[vi,$n]]),ms=e=>ps.get(e)??e,hs=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=ds(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=fs[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(ms);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},gs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ds(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Bo(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},_s=(e,t,n,r)=>{n.type=`boolean`},vs=(e,t,n,r)=>{n.not={}},ys=(e,t,n,r)=>{let i=e._zod.def,a=He(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},bs=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Bo(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Bo(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},xs=(e,t,n,r)=>{Bo(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ss=(e,t,n,r)=>{Bo(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Cs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=ds(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Vo(a.element,t,{...r,path:[...r.path,`items`]})};function ws(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ws(t.out):t.type===`catch`?ws(t.innerType):e._zod.optin}var Ts=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Bo(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Xe(i.properties,e,Vo(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ws(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Vo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Es=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Vo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ds=(e,t,n,r)=>{let i=e._zod.def,a=Vo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Vo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Os(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Os(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Os(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?ur:lr).source),p):p}var ks=new WeakMap;function As(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of ks.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Os(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var js=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=ds(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Vo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Xe(i.patternProperties,ms(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Vo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=ks.get(t);n||(n=[],ks.set(t,n),t.deferred.push(()=>As(t))),n.push(e)}i.additionalProperties=Vo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ws(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Ms=(e,t,n,r)=>{let i=e._zod.def,a=Vo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ns=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ps=Symbol();function Fs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Bo(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Ps):JSON.parse(o)}var Is=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Fs(i.defaultValue,e,t,n,r);o!==Ps&&(n.default=o)},Ls=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Fs(i.defaultValue,e,t,n,r);o!==Ps&&(n._prefault=o)},Rs=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Bo(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},zs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Vo(o,t,r);let s=t.seen.get(e);s.ref=o},Bs=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Vs=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Hs=new WeakSet([Object.prototype,Error.prototype]);function Us(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Ws=G(`ZodError`,(e,t)=>{fn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Hs.has(n)||(Hs.add(n),Us(n,`format`,e=>t=>hn(e,t)),Us(n,`flatten`,e=>t=>mn(e,t)),Us(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,We,2)}),Us(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,We,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Gs=_n(Ws),Ks=vn(Ws),qs=yn(Ws),Js=xn(Ws),Ys=Dn(Ws),Xs=On(Ws),Zs=kn(Ws),Qs=An(Ws),$s=jn(Ws),ec=Mn(Ws),tc=Nn(Ws),nc=Pn(Ws);function rc(){rn.localeError||an(ka())}function ic(){rn.memoizer||an({memoizer:Ea()})}var ac=G(`ZodType`,(e,t)=>(rc(),Pr.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(rt(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return pt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Sl(e,t))},superRefine(e,t){return this.check(Cl(e,t))},overwrite(e){return this.check(Oo(e))},optional(){return il(this)},exactOptional(){return ol(this)},nullable(){return cl(this)},nullish(){return il(cl(this))},nonoptional(e){return ml(this,e)},array(){return Uc(this)},or(e){return Kc([this,e])},and(e){return Xc(this,e)},transform(e){return vl(this,nl(e))},default(e){return ul(this,e)},prefault(e){return fl(this,e)},catch(e){return gl(this,e)},pipe(e){return vl(this,e)},readonly(){return bl(this)},describe(e){let t=this.clone();return Na.add(t,{description:e}),t},meta(...e){if(e.length===0)return Na.get(this);let t=this.clone();return Na.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Bt(this,`~standard`,{...Lr(this),jsonSchema:{input:$o(this,`input`),output:$o(this,`output`)}})},set"~standard"(e){zt(this,`~standard`,e)},parse:function e(t,n){return Gs(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ks(this,t,n,{callee:e})},safeParse(e,t){return qs(this,e,t)},async safeParseAsync(e,t){return Js(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){zt(this,`spa`,e)},validate(e,t){return wn(this,e,t)},validateAsync(e,t){return En(this,e,t)},encode:function e(t,n){return Ys(this,t,n,{callee:e})},decode:function e(t,n){return Xs(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Zs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Qs(this,t,n,{callee:e})},safeEncode(e,t){return $s(this,e,t)},safeDecode(e,t){return ec(this,e,t)},async safeEncodeAsync(e,t){return tc(this,e,t)},async safeDecodeAsync(e,t){return nc(this,e,t)},toJSONSchema(e){return Qo(this,{})(e)},get description(){return Na.get(this)?.description},get _def(){return this._zod.def}}),oc=G(`_ZodString`,(e,t)=>{Rr.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)},Vt({format:e=>ds(e).format??null,minLength:e=>ds(e).minimum??null,maxLength:e=>ds(e).maximum??null},{regex(...e){return this.check(So(...e))},includes(...e){return this.check(To(...e))},startsWith(...e){return this.check(Eo(...e))},endsWith(...e){return this.check(Do(...e))},min(...e){return this.check(bo(...e))},max(...e){return this.check(yo(...e))},length(...e){return this.check(xo(...e))},nonempty(...e){return this.check(bo(1,...e))},lowercase(e){return this.check(Co(e))},uppercase(e){return this.check(wo(e))},trim(){return this.check(Ao())},normalize(...e){return this.check(ko(...e))},toLowerCase(){return this.check(jo())},toUpperCase(){return this.check(Mo())},slugify(){return this.check(No())}})),sc=G(`ZodString`,(e,t)=>{Rr.init(e,t),oc.init(e,t)},{email(e){return this.check(Ia(pc,e))},url(e){return this.check(Ha(gc,e))},jwt(e){return this.check(ro(jc,e))},emoji(e){return this.check(Ua(_c,e))},guid(e){return this.check(La(mc,e))},uuid(e){return this.check(Ra(hc,e))},uuidv4(e){return this.check(za(hc,e))},uuidv6(e){return this.check(Ba(hc,e))},uuidv7(e){return this.check(Va(hc,e))},nanoid(e){return this.check(Wa(vc,e))},cuid(e){return this.check(Ga(yc,e))},cuid2(e){return this.check(Ka(bc,e))},ulid(e){return this.check(qa(xc,e))},base64(e){return this.check(eo(Oc,e))},base64url(e){return this.check(to(kc,e))},xid(e){return this.check(Ja(Sc,e))},ksuid(e){return this.check(Ya(Cc,e))},ipv4(e){return this.check(Xa(wc,e))},ipv6(e){return this.check(Za(Tc,e))},cidrv4(e){return this.check(Qa(Ec,e))},cidrv6(e){return this.check($a(Dc,e))},e164(e){return this.check(no(Ac,e))},datetime(e){return this.check(io(lc,e))},date(e){return this.check(ao(uc,e))},time(e){return this.check(oo(dc,e))},duration(e){return this.check(so(fc,e))}});function K(e){return Fa(sc,e)}var cc=G(`ZodStringFormat`,(e,t)=>{zr.init(e,t),oc.init(e,t)}),lc=G(`ZodISODateTime`,(e,t)=>{ii.init(e,t),cc.init(e,t)}),uc=G(`ZodISODate`,(e,t)=>{ai.init(e,t),cc.init(e,t)}),dc=G(`ZodISOTime`,(e,t)=>{oi.init(e,t),cc.init(e,t)}),fc=G(`ZodISODuration`,(e,t)=>{si.init(e,t),cc.init(e,t)}),pc=G(`ZodEmail`,(e,t)=>{Hr.init(e,t),cc.init(e,t)}),mc=G(`ZodGUID`,(e,t)=>{Br.init(e,t),cc.init(e,t)}),hc=G(`ZodUUID`,(e,t)=>{Vr.init(e,t),cc.init(e,t)}),gc=G(`ZodURL`,(e,t)=>{Xr.init(e,t),cc.init(e,t)}),_c=G(`ZodEmoji`,(e,t)=>{Zr.init(e,t),cc.init(e,t)}),vc=G(`ZodNanoID`,(e,t)=>{Qr.init(e,t),cc.init(e,t)}),yc=G(`ZodCUID`,(e,t)=>{$r.init(e,t),cc.init(e,t)}),bc=G(`ZodCUID2`,(e,t)=>{ei.init(e,t),cc.init(e,t)}),xc=G(`ZodULID`,(e,t)=>{ti.init(e,t),cc.init(e,t)}),Sc=G(`ZodXID`,(e,t)=>{ni.init(e,t),cc.init(e,t)}),Cc=G(`ZodKSUID`,(e,t)=>{ri.init(e,t),cc.init(e,t)}),wc=G(`ZodIPv4`,(e,t)=>{ci.init(e,t),cc.init(e,t)}),Tc=G(`ZodIPv6`,(e,t)=>{di.init(e,t),cc.init(e,t)}),Ec=G(`ZodCIDRv4`,(e,t)=>{fi.init(e,t),cc.init(e,t)}),Dc=G(`ZodCIDRv6`,(e,t)=>{mi.init(e,t),cc.init(e,t)}),Oc=G(`ZodBase64`,(e,t)=>{_i.init(e,t),cc.init(e,t)}),kc=G(`ZodBase64URL`,(e,t)=>{bi.init(e,t),cc.init(e,t)}),Ac=G(`ZodE164`,(e,t)=>{xi.init(e,t),cc.init(e,t)}),jc=G(`ZodJWT`,(e,t)=>{Ci.init(e,t),cc.init(e,t)}),Mc=G(`ZodNumber`,(e,t)=>{wi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.isFinite=!0},Vt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=ds(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=ds(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=ds(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ds(e).format??null},{gt(e,t){return this.check(go(e,t))},gte(e,t){return this.check(_o(e,t))},min(e,t){return this.check(_o(e,t))},lt(e,t){return this.check(mo(e,t))},lte(e,t){return this.check(ho(e,t))},max(e,t){return this.check(ho(e,t))},int(e){return this.check(Fc(e))},safe(e){return this.check(Fc(e))},positive(e){return this.check(go(0,e))},nonnegative(e){return this.check(_o(0,e))},negative(e){return this.check(mo(0,e))},nonpositive(e){return this.check(ho(0,e))},multipleOf(e,t){return this.check(vo(e,t))},step(e,t){return this.check(vo(e,t))},finite(){return this}}));function Nc(e){return co(Mc,e)}var Pc=G(`ZodNumberFormat`,(e,t)=>{Ti.init(e,t),Mc.init(e,t)});function Fc(e){return lo(Pc,e)}var Ic=G(`ZodBoolean`,(e,t)=>{Ei.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r)});function Lc(e){return uo(Ic,e)}var Rc=G(`ZodUnknown`,(e,t)=>{Di.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function zc(){return fo(Rc)}var Bc=G(`ZodNever`,(e,t)=>{Oi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r)});function Vc(e){return po(Bc,e)}var Hc=G(`ZodArray`,(e,t)=>{ic(),Ai.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.element=t.element},{min(e,t){return this.check(bo(e,t))},nonempty(e){return this.check(bo(1,e))},max(e,t){return this.check(yo(e,t))},length(e,t){return this.check(xo(e,t))},unwrap(){return this.element}});function Uc(e,t){return Po(Hc,e,t)}var Wc=G(`ZodObject`,(e,t)=>{ic(),Ii.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),Jt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return J(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(rt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(rt(this._zod.def,{catchall:zc()}))},loose(){return this.clone(rt(this._zod.def,{catchall:zc()}))},strict(){return this.clone(rt(this._zod.def,{catchall:Vc()}))},strip(){return this.clone(rt(this._zod.def,{catchall:void 0}))},extend(e){return xt(this,e)},safeExtend(e){return Ct(this,e)},merge(e){return wt(this,e)},pick(e){return vt(this,e)},omit(e){return bt(this,e)},partial(...e){return Tt(rl,this,e[0])},exactPartial(...e){return Tt(al,this,e[0],`exactPartial`)},required(...e){return Et(pl,this,e[0])}});function q(e,t){return new Wc({type:`object`,shape:e??{},...W(t)})}var Gc=G(`ZodUnion`,(e,t)=>{Ri.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.options=t.options});function Kc(e,t){return new Gc({type:`union`,options:e,...W(t)})}var qc=G(`ZodDiscriminatedUnion`,(e,t)=>{Gc.init(e,t),Bi.init(e,t)});function Jc(e,t,n){return new qc({type:`union`,options:t,discriminator:e,...W(n)})}var Yc=G(`ZodIntersection`,(e,t)=>{Vi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r)});function Xc(e,t){return new Yc({type:`intersection`,left:e,right:t})}var Zc=G(`ZodRecord`,(e,t)=>{ic(),Wi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Qc(e,t,n){return!t||!t._zod?new Zc({type:`record`,keyType:K(),valueType:e,...W(t)}):new Zc({type:`record`,keyType:e,valueType:t,...W(n)})}var $c=G(`ZodEnum`,(e,t)=>{Gi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new $c({...t,checks:[],...W(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new $c({...t,checks:[],...W(r),entries:i})}});function J(e,t){return new $c({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...W(t)})}var el=G(`ZodLiteral`,(e,t)=>{Ki.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Y(e,t){return new el({type:`literal`,values:Array.isArray(e)?e:[e],...W(t)})}var tl=G(`ZodTransform`,(e,t)=>{ic(),qi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Lt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Lt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function nl(e){return new tl({type:`transform`,transform:e})}var rl=G(`ZodOptional`,(e,t)=>{Yi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function il(e){return new rl({type:`optional`,innerType:e})}var al=G(`ZodExactOptional`,(e,t)=>{Xi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ol(e){return new al({type:`optional`,innerType:e})}var sl=G(`ZodNullable`,(e,t)=>{Zi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cl(e){return new sl({type:`nullable`,innerType:e})}var ll=G(`ZodDefault`,(e,t)=>{Qi.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ul(e,t){return new ll({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ut(t)}})}var dl=G(`ZodPrefault`,(e,t)=>{ea.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fl(e,t){return new dl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ut(t)}})}var pl=G(`ZodNonOptional`,(e,t)=>{ta.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ml(e,t){return new pl({type:`nonoptional`,innerType:e,...W(t)})}var hl=G(`ZodCatch`,(e,t)=>{ia.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gl(e,t){return new hl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Xt(t)})}var _l=G(`ZodPipe`,(e,t)=>{aa.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.in=t.in,e.out=t.out});function vl(e,t){return new _l({type:`pipe`,in:e,out:t})}var yl=G(`ZodReadonly`,(e,t)=>{sa.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bl(e){return new yl({type:`readonly`,innerType:e})}var xl=G(`ZodCustom`,(e,t)=>{la.init(e,t),ac.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Sl(e,t={}){return Fo(xl,e,t)}function Cl(e,t){return Io(e,t)}var wl=J([`T0`,`T1`,`T2`,`T3`]);J([`owner`,`guest`,`member`,`voice-device`]);var Tl=Nc().min(0).max(1),El=Kc([J([`auto`,`center`,`left`,`right`,`top`,`bottom`]),q({x:Tl,y:Tl,w:Tl,h:Tl})]),Dl=J([`ambient`,`conversation`,`focus`,`multi`]),Ol=J([`idle`,`listening`,`thinking`,`speaking`]),kl=J([`sphere`,`orb`,`ring`]),Al=q({id:K().min(1).max(64),type:J([`card`,`stat`,`list`,`table`,`code`,`chart`,`gauge`,`timeline`,`graph`,`sandbox`,`markdown`,`image`,`video`,`pdf`,`gallery`,`group`,`tabs`,`progress`,`checklist`,`countdown`,`kv`]),props:Qc(K(),zc()),placement:El,ttl:Nc().positive().max(3600).optional(),style:J([`glass`,`alert`]).optional(),layer:J([`base`,`overlay`]).optional(),pinned:Lc().optional()}),jl=Jc(`cmd`,[q({cmd:Y(`scene`),mode:Dl}),q({cmd:Y(`show`),object:Al}),q({cmd:Y(`update`),id:K(),props:Qc(K(),zc())}),q({cmd:Y(`hide`),id:K()}),q({cmd:Y(`clear`)}),q({cmd:Y(`pin`),id:K()}),q({cmd:Y(`unpin`),id:K()}),q({cmd:Y(`place`),id:K(),placement:El}),q({cmd:Y(`presence`),state:Ol.optional(),style:kl.optional()}),q({cmd:Y(`mood`),accent:K().max(16).optional(),intensity:Tl.optional()})]),Ml=q({scene:Dl,objects:Uc(Al),presence:q({state:Ol,style:kl}),mood:q({accent:K(),intensity:Tl})}),Nl={center:[20,18,60,58],left:[3,12,30,70],right:[67,12,30,70],top:[20,4,60,30],bottom:[20,62,60,30]};Object.keys(Nl);var Pl=[{id:`en_US-amy-medium`,name:`Amy`,gender:`female`,accent:`American`},{id:`en_US-kristin-medium`,name:`Kristin`,gender:`female`,accent:`American`},{id:`en_US-hfc_female-medium`,name:`Hannah`,gender:`female`,accent:`American`,note:`clear and steady`},{id:`en_GB-jenny_dioco-medium`,name:`Jenny`,gender:`female`,accent:`British`},{id:`en_GB-alba-medium`,name:`Alba`,gender:`female`,accent:`Scottish`},{id:`en_US-kathleen-low`,name:`Kathleen`,gender:`female`,accent:`American`,note:`smaller and faster`},{id:`en_US-ryan-medium`,name:`Ryan`,gender:`male`,accent:`American`},{id:`en_US-joe-medium`,name:`Joe`,gender:`male`,accent:`American`},{id:`en_US-norman-medium`,name:`Norman`,gender:`male`,accent:`American`},{id:`en_US-hfc_male-medium`,name:`Henry`,gender:`male`,accent:`American`,note:`clear and steady`},{id:`en_GB-alan-medium`,name:`Alan`,gender:`male`,accent:`British`},{id:`en_GB-northern_english_male-medium`,name:`Tom`,gender:`male`,accent:`Northern English`}],Fl=[{id:`hi_IN-priyamvada-medium`,name:`Priyamvada`,gender:`female`,accent:`Hindi`,note:`for personal use (non-commercial licence)`},{id:`hi_IN-pratham-medium`,name:`Pratham`,gender:`male`,accent:`Hindi`,note:`for personal use (non-commercial licence)`},{id:`hi_IN-rohan-medium`,name:`Rohan`,gender:`male`,accent:`Hindi`}],Il=[{id:`mr_IN-google-medium`,name:`Marathi`,gender:`female`,accent:`Marathi`}],Ll={id:`en_US-lessac-medium`,name:`Lessac`,accent:`American`,note:`the original voice`},Rl=e=>e===Ll.id||Pl.some(t=>t.id===e),zl=[{id:`aurora`,name:`Aurora`,style:`sphere`,accent:`#3fd8ff`,intensity:.6},{id:`ocean`,name:`Ocean`,style:`sphere`,accent:`#2b7bff`,intensity:.6},{id:`ember`,name:`Ember`,style:`orb`,accent:`#ff9b3d`,intensity:.7},{id:`violet`,name:`Violet storm`,style:`orb`,accent:`#a066ff`,intensity:.8},{id:`matrix`,name:`Matrix`,style:`ring`,accent:`#3dff8c`,intensity:.6},{id:`rose`,name:`Rose`,style:`ring`,accent:`#ff6fae`,intensity:.7},{id:`ghost`,name:`Ghost`,style:`sphere`,accent:`#e8f4ff`,intensity:.4}],Bl=[`local`,`spotify`,`soundcloud`,`audius`],Vl=/^[0-9a-f]{16}$/,Hl=/^[0-9]{1,20}$/,Ul=/^[A-Za-z0-9_-]{1,64}$/;function Wl(e){if(typeof e!=`string`)return null;if(Vl.test(e))return{source:`local`,id:e};let t=e.indexOf(`:`);if(t<1)return null;let n=e.slice(0,t),r=e.slice(t+1);return!Bl.includes(n)||!(n===`local`?Vl:n===`soundcloud`?Hl:Ul).test(r)?null:{source:n,id:r}}var Gl=J([`minimal`,`companion`,`workspace`]),Kl=q({size:Nc().min(.5).max(1.5),reactivity:Nc().min(0).max(1),ambient:Lc(),captions:Lc(),captionSize:J([`small`,`medium`,`large`])}),ql={width:Nc().int().min(100).max(1e4),height:Nc().int().min(100).max(1e4),kind:J([`phone`,`tablet`,`desktop`]),orientation:J([`portrait`,`landscape`]),touch:Lc()};q(ql);var Jl=q({id:K(),tool:K(),summary:K(),tier:wl,needsPin:Lc()}),Yl=q({id:K().refine(e=>Wl(e)!==null,`A track id or a source:id ref`),title:K().max(200),artist:K().max(200),album:K().max(200),durationSec:Nc().nullable()}),Xl=q({playing:Lc(),trackId:K().max(80).nullable(),title:K().max(200),artist:K().max(200),album:K().max(200),position:Nc().min(0),duration:Nc().min(0),volume:Nc().min(0).max(100),muted:Lc(),shuffle:Lc(),repeat:J([`off`,`all`,`one`]),view:J([`mini`,`full`,`hidden`]),queue:Uc(q({id:K().max(80),title:K().max(200)})).max(50),index:Nc().int().min(-1),active:Lc()}),Zl=q({action:J([`play`,`pause`,`resume`,`toggle`,`stop`,`next`,`previous`,`seek`,`volume`,`mute`,`shuffle`,`repeat`,`view`,`queue.remove`,`queue.clear`,`jump`]),tracks:Uc(Yl).max(500).optional(),mode:J([`replace`,`add`,`next`,`off`,`all`,`one`]).optional(),shuffle:Lc().optional(),seconds:Nc().min(0).optional(),percent:Nc().min(0).max(100).optional(),level:Nc().min(0).max(100).optional(),delta:Nc().min(-100).max(100).optional(),on:Lc().optional(),view:J([`mini`,`full`,`hidden`]).optional(),index:Nc().int().min(0).optional()}),Ql=q({terminalLabel:K().max(24),clock:q({hour12:Lc(),seconds:Lc(),locale:K().max(35)}),launcher:Uc(q({id:K().max(20),label:K().max(24),icon:K().max(16),action:q({type:J([`url`,`prompt`,`panel`,`music`]),value:K().max(500)})})).max(12),animations:J([`full`,`reduced`,`off`])}),$l=q({folderSet:Lc(),volume:Nc().min(0).max(100),shuffle:Lc(),repeat:J([`off`,`all`,`one`]),visualizer:Lc(),startView:J([`mini`,`full`]),output:J([`screen`,`host`]).optional()}),eu=Jc(`type`,[q({type:Y(`music.command`)}).merge(Zl),q({type:Y(`music.host`),state:Xl}),q({type:Y(`stage`),command:jl}),q({type:Y(`caption.delta`),text:K()}),q({type:Y(`caption.end`)}),q({type:Y(`approval.request`)}).merge(Jl),q({type:Y(`approval.resolved`),id:K()}),q({type:Y(`alert`),level:J([`info`,`warn`,`error`]),text:K()}),q({type:Y(`chat.user`),text:K()}),q({type:Y(`ui`),view:Gl,look:Kl.optional(),ownerName:K().max(40).optional(),assistantName:K().max(40).optional(),hud:Ql.optional(),music:$l.optional()}),q({type:Y(`activity`),text:K().max(80).nullable()}),q({type:Y(`status`),busy:Lc(),deviceOnline:Lc(),voiceAvailable:Lc().optional(),voiceEnrolled:Lc().optional(),message:K().optional()}),q({type:Y(`voice.heard`),text:K(),trust:J([`owner`,`guest`,`unverified`,`member`]).optional(),speaker:K().max(60).optional()}),q({type:Y(`voice.challenge`),id:K(),text:K()}),q({type:Y(`voice.challenge.end`),id:K()}),q({type:Y(`audio.chunk`),id:K(),seq:Nc().int().min(0),last:Lc(),mime:K(),data:K()}),q({type:Y(`audio.stop`)}),q({type:Y(`camera.request`),id:K()}),q({type:Y(`camera.cancel`),id:K()}),q({type:Y(`ui.open`),panel:Y(`plugins`),integration:K().max(40).optional()}),q({type:Y(`screen.request`),id:K()}),q({type:Y(`screen.cancel`),id:K()}),q({type:Y(`snapshot`),stage:Ml,pendingApproval:Jl.nullable().optional()}),q({type:Y(`error`),message:K()})]),tu=q({type:Y(`approval.respond`),id:K(),decision:J([`approve`,`deny`,`approve_always`]),pin:K().max(32).optional()});Jc(`type`,[q({type:Y(`chat.send`),text:K().min(1).max(8e3)}),q({type:Y(`stage.event`),objectId:K(),event:K().max(64)}),tu,q({type:Y(`voice.interrupt`)}),q({type:Y(`voice.confirm`),id:K(),pin:K().max(32)}),q({type:Y(`voice.cancel`),id:K()}),q({type:Y(`camera.denied`),id:K(),reason:J([`off`,`no-camera`,`permission`,`busy`])}),q({type:Y(`screen.denied`),id:K(),reason:J([`unsupported`,`failed`,`busy`])}),q({type:Y(`ui.panels`),open:Uc(J([`chat`,`tasks`])).max(2)}),q({type:Y(`ui.screen`),...ql}),q({type:Y(`stage.move`),objectId:K().max(64),rect:q({x:Nc().min(0).max(1),y:Nc().min(0).max(1),w:Nc().min(0).max(1),h:Nc().min(0).max(1)})}),q({type:Y(`stage.pin`),objectId:K().max(64),pinned:Lc()}),q({type:Y(`music.state`),state:Xl}),q({type:Y(`music.remote`),command:Zl}),q({type:Y(`ping`)})]),q({type:Y(`tool.exec`),id:K(),tool:K(),args:zc(),approvedOutside:Lc().optional()}),Jc(`type`,[q({type:Y(`tool.result`),id:K(),result:q({output:K(),truncated:Lc()})}),q({type:Y(`tool.error`),id:K(),error:K()})]),q({path:K()}),q({path:K()}),q({path:K(),content:K()}),q({}),q({}),q({command:K().min(1),cwd:K().optional()}),q({city:K().min(1).max(80)}),q({plugin:K().min(1).max(40),name:K().min(1).max(40)}),q({language:J([`python`,`node`,`shell`]),code:K().min(1).max(5e4),timeoutSec:Nc().int().min(1).max(60).optional()}),q({text:K().min(1).max(4e3)}),q({query:K().min(1).max(200)}),q({id:Nc().int().positive()}),q({title:K().min(1).max(1e3),inMinutes:Nc().int().min(1).max(525600).optional(),dueAt:K().max(40).optional(),repeat:J([`hourly`,`daily`,`weekly`]).optional()}),q({}),q({id:Nc().int().positive()}),q({id:Nc().int().positive()}),q({}),q({path:K().min(1).max(1e3),id:K().min(1).max(64).optional(),title:K().max(120).optional(),placement:El.optional()}),q({}),q({}),q({id:K().min(1).max(40)}),q({id:J([`telegram`,`twilio`,`zerodha`,`alexa`]).optional()}),q({id:J([`telegram`,`twilio`,`zerodha`,`alexa`]),enabled:Lc().optional(),accountSid:K().max(64).optional(),smsFrom:K().max(30).optional(),whatsappFrom:K().max(30).optional(),ownerNumber:K().max(30).optional()}).strict(),q({id:J([`telegram`,`twilio`,`zerodha`,`alexa`])}),q({id:J([`telegram`,`twilio`,`zerodha`,`alexa`])}),q({channel:J([`telegram`,`sms`,`whatsapp`]),to:K().min(1).max(40),text:K().min(1).max(1500)}),q({channel:J([`telegram`,`whatsapp`]),to:Y(`me`),path:K().min(1).max(500),caption:K().max(1e3).optional()}).strict(),q({channel:J([`telegram`,`sms`,`whatsapp`]).optional(),unread:Lc().optional(),limit:Nc().int().min(1).max(20).optional()}),q({}).strict(),q({}).strict(),q({}).strict(),q({}).strict(),q({}).strict(),q({}).strict(),q({kind:J([`morning`,`close`,`custom`]).optional(),send:Lc().optional()}).strict(),q({name:K().min(1).max(60),kind:J([`morning`,`close`,`custom`]),time:K().regex(/^([01]\d|2[0-3]):[0-5]\d$/),days:Uc(Nc().int().min(1).max(7)).min(1).max(7).optional(),channel:J([`telegram`,`whatsapp`,`sms`]),commentary:Lc().optional()}).strict(),q({}).strict(),q({id:Nc().int().min(1)}).strict(),q({query:K().max(200).optional(),title:K().max(200).optional(),artist:K().max(200).optional(),album:K().max(200).optional(),shuffle:Lc().optional(),mode:J([`replace`,`add`,`next`]).optional(),limit:Nc().int().min(1).max(500).optional(),source:J([`local`,`spotify`,`soundcloud`,`audius`,`any`]).optional()}).strict(),q({action:J([`pause`,`resume`,`toggle`,`stop`,`next`,`previous`,`seek`,`volume`,`mute`,`shuffle`,`repeat`,`view`]),level:Nc().min(0).max(100).optional(),delta:Nc().min(-100).max(100).optional(),seconds:Nc().min(0).optional(),percent:Nc().min(0).max(100).optional(),on:Lc().optional(),mode:J([`off`,`all`,`one`]).optional(),view:J([`mini`,`full`,`hidden`]).optional()}).strict(),q({action:J([`add`,`remove`,`clear`,`show`]),query:K().max(200).optional(),index:Nc().int().min(1).optional(),source:J([`local`,`spotify`,`soundcloud`,`audius`,`any`]).optional()}).strict(),q({query:K().max(200),limit:Nc().int().min(1).max(15).optional(),source:J([`local`,`spotify`,`soundcloud`,`audius`,`any`]).optional()}).strict(),q({}).strict(),q({}),q({settings:Qc(K(),zc())}),q({style:kl.optional(),accent:K().regex(/^#[0-9a-fA-F]{6}$/).optional(),intensity:Nc().min(0).max(1).optional(),size:Nc().min(.5).max(1.5).optional(),reactivity:Nc().min(0).max(1).optional(),ambient:Lc().optional(),captions:Lc().optional(),captionSize:J([`small`,`medium`,`large`]).optional()}),q({view:Gl}),q({}),q({id:K().min(1).max(16),name:K().min(1).max(60),kind:J([`stdio`,`http`]),command:K().max(260).optional(),args:Uc(K().max(500)).max(20).optional(),url:K().max(2e3).optional()}),q({id:K().min(1).max(16)}),q({id:K().min(1).max(16)}),q({id:K().min(1).max(16)}),q({id:K().min(1).max(16)}),q({}),q({id:K().min(1).max(40),name:K().min(1).max(80),description:K().max(500).optional(),skills:Uc(q({name:K().min(1).max(40),description:K().min(1).max(300),text:K().min(1).max(2e4)})).max(10).optional(),tools:Uc(q({name:K().min(1).max(40),description:K().min(1).max(500),language:J([`python`,`node`,`shell`]),code:K().min(1).max(5e4),parameters:Qc(K(),q({type:J([`string`,`number`,`integer`,`boolean`]),description:K().max(300).optional(),enum:Uc(K().max(100)).max(50).optional()})).optional(),required:Uc(K()).optional()})).max(10).optional()}),q({}),q({id:K().min(1).max(40)}),q({id:K().min(1).max(40)}),q({id:K().min(1).max(40)}),q({mode:Dl}),q({object:Al}),q({topic:J([`all`,`widgets`,`layout`,`overlay`,`theme`,`files`,`recipes`]).optional()}),q({id:K(),props:Qc(K(),zc())}),q({id:K()}),q({}),q({id:K()}),q({id:K()}),q({state:Ol.optional(),style:kl.optional()}),q({accent:K().max(16).optional(),intensity:Nc().min(0).max(1).optional()});var nu=new Set([`alexa`,`amazon`,`echo`,`skill`,`app`,`ask`,`tell`,`open`,`start`,`run`,`enable`,`launch`,`load`,`begin`,`use`]),ru=50;function iu(e){let t=e.trim().split(/\s+/).filter(Boolean);if(t.length<1)return`Enter the name you will say after "Alexa, ask".`;if(e.length>ru)return`That is too long (at most ${ru} characters).`;if(!/^[a-z' ]+$/.test(e))return`Use lower-case letters, spaces and apostrophes only. Spell numbers out as words.`;let n=t.find(e=>nu.has(e));return n?`The word "${n}" cannot be in the name (it is reserved by Alexa).`:null}var au=[`mp3`,`m4a`,`aac`,`ogg`,`opus`,`wav`,`flac`],ou={maxTracks:{min:100,max:5e4,def:5e3},scanDepth:{min:1,max:12,def:6},volume:{min:0,max:100,def:70},searchLimit:{min:3,max:50,def:10}},su=[`chat`,`tasks`,`plugins`,`settings`,`music`],cu=[`toggle`,`play`,`pause`,`next`,`previous`],lu=[`url`,`prompt`,`panel`,`music`];function uu(e){let t=e&&typeof e==`object`?e:null;if(!t)return`A button needs a label and an action.`;let n=typeof t.label==`string`?t.label.trim():``;if(n.length<1||n.length>24)return`A button label is 1 to 24 characters.`;let r=typeof t.icon==`string`?t.icon.trim():``;if(r.length<1||[...r].length>4)return`A button icon is 1 to 4 characters (a symbol or an emoji).`;let i=t.action&&typeof t.action==`object`?t.action:null;if(!i||!lu.includes(i.type)||typeof i.value!=`string`)return`A button needs an action: an address, a question, a panel or a music control.`;let a=i.value.trim();switch(i.type){case`url`:if(a.length>500)return`A button address is at most 500 characters.`;try{let e=new URL(a);return e.protocol===`https:`||e.protocol===`http:`?null:`A button address must start with https:// or http://.`}catch{return`A button address must start with https:// or http://.`}case`prompt`:return a.length>=1&&a.length<=500?null:`A question for the assistant is 1 to 500 characters.`;case`panel`:return su.includes(a)?null:`A panel is one of: ${su.join(`, `)}.`;default:return cu.includes(a)?null:`A music control is one of: ${cu.join(`, `)}.`}}function du(e){return e===``?null:e.length>260?`That program name is too long.`:/\s/.test(e)?`Use the program's name, or a short path with no spaces (or add the program to your PATH). Arguments cannot be added here.`:e.startsWith(`-`)||!/^[A-Za-z0-9._:\\/~+-]+$/.test(e)?`A program is a name or a path made of letters, digits and . _ : / \\ ~ + - only, and cannot start with a dash.`:null}var fu=2e3,pu=3,mu=e=>({queue:[],index:-1,playing:!1,position:0,duration:0,volume:e.volume,muted:!1,shuffle:e.shuffle,repeat:e.repeat,view:e.view});function hu(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;e--){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var gu=(e,t,n)=>Math.min(n,Math.max(t,e)),_u=(e,t,n)=>({...e,index:t,playing:n,position:0,duration:0});function vu(e,t,n={}){let r=n.shuffle??hu,i=e.queue.length-1;switch(t.type){case`play`:{if(t.tracks.length===0)return e;let n=t.tracks.slice(0,fu);if(t.mode===`replace`){let i=t.shuffle?r(n):n;return{..._u(e,t.shuffle?0:gu(t.start??0,0,i.length-1),!0),queue:i,shuffle:t.shuffle?!0:e.shuffle}}if(e.queue.length===0)return{..._u(e,0,!0),queue:n};let i=t.mode===`next`?e.index+1:e.queue.length;return{...e,queue:[...e.queue.slice(0,i),...n,...e.queue.slice(i)].slice(0,fu)}}case`next`:return i<0?e:e.index<i?_u(e,e.index+1,!0):e.repeat===`off`?{...e,playing:!1,position:0}:_u(e,0,!0);case`previous`:return i<0?e:e.position>pu?{...e,position:0}:e.index>0?_u(e,e.index-1,e.playing||!0):e.repeat===`all`?_u(e,i,!0):{...e,position:0};case`ended`:return i<0?e:e.repeat===`one`?_u(e,e.index,!0):e.index<i?_u(e,e.index+1,!0):e.repeat===`all`?_u(e,0,!0):{...e,playing:!1,position:0};case`failed`:return i<0?e:e.index<i?_u(e,e.index+1,!0):{...e,playing:!1,position:0};case`pause`:return e.playing?{...e,playing:!1}:e;case`resume`:return e.index>=0&&!e.playing?{...e,playing:!0}:e;case`toggle`:return e.index<0?e:{...e,playing:!e.playing};case`stop`:return{...e,playing:!1,position:0};case`volume`:{let n=typeof t.level==`number`?Math.round(t.level):typeof t.delta==`number`?e.volume+Math.round(t.delta):e.volume;return{...e,volume:gu(n,0,100),muted:typeof t.level==`number`||(t.delta??0)>0?!1:e.muted}}case`mute`:return{...e,muted:t.on??!e.muted};case`seek`:{let n=typeof t.seconds==`number`?t.seconds:typeof t.percent==`number`?e.duration*gu(t.percent,0,100)/100:e.position;return{...e,position:gu(n,0,e.duration>0?e.duration:Math.max(n,0))}}case`repeat`:return{...e,repeat:t.mode};case`shuffle`:{if(!(t.on??!e.shuffle))return{...e,shuffle:!1};let n=e.queue.slice(0,e.index+1);return{...e,shuffle:!0,queue:[...n,...r(e.queue.slice(e.index+1))]}}case`view`:return{...e,view:t.view};case`remove`:{if(!Number.isInteger(t.index)||t.index<0||t.index>i)return e;let n=e.queue.filter((e,n)=>n!==t.index);return n.length===0?{...e,queue:n,index:-1,playing:!1,position:0,duration:0}:t.index<e.index?{...e,queue:n,index:e.index-1}:t.index>e.index?{...e,queue:n}:t.index<n.length?{..._u(e,t.index,e.playing),queue:n}:e.repeat===`all`?{..._u(e,0,e.playing),queue:n}:{...e,queue:n,index:n.length-1,playing:!1,position:0}}case`clear`:return{...e,queue:[],index:-1,playing:!1,position:0,duration:0};case`jump`:return Number.isInteger(t.index)&&t.index>=0&&t.index<=i?_u(e,t.index,!0):e;case`time`:return{...e,position:Math.max(0,t.position),duration:Math.max(0,t.duration)}}}function yu(e){switch(e.action){case`play`:return{type:`play`,tracks:e.tracks??[],mode:e.mode===`add`||e.mode===`next`?e.mode:`replace`,...e.shuffle?{shuffle:!0}:{},...e.index===void 0?{}:{start:e.index}};case`pause`:case`resume`:case`toggle`:case`stop`:case`next`:case`previous`:return{type:e.action};case`seek`:return{type:`seek`,...e.seconds===void 0?{}:{seconds:e.seconds},...e.percent===void 0?{}:{percent:e.percent}};case`volume`:return{type:`volume`,...e.level===void 0?{}:{level:e.level},...e.delta===void 0?{}:{delta:e.delta}};case`mute`:return{type:`mute`,...e.on===void 0?{}:{on:e.on}};case`shuffle`:return{type:`shuffle`,...e.on===void 0?{}:{on:e.on}};case`repeat`:return e.mode===`off`||e.mode===`all`||e.mode===`one`?{type:`repeat`,mode:e.mode}:null;case`view`:return e.view?{type:`view`,view:e.view}:null;case`queue.remove`:return e.index===void 0?null:{type:`remove`,index:e.index};case`queue.clear`:return{type:`clear`};case`jump`:return e.index===void 0?null:{type:`jump`,index:e.index};default:return null}}function bu(e){switch(e.type){case`play`:return{action:`play`,tracks:e.tracks,mode:e.mode,...e.shuffle?{shuffle:!0}:{},...e.start===void 0?{}:{index:e.start}};case`next`:case`previous`:case`pause`:case`resume`:case`toggle`:case`stop`:return{action:e.type};case`volume`:return{action:`volume`,...e.level===void 0?{}:{level:e.level},...e.delta===void 0?{}:{delta:e.delta}};case`mute`:return{action:`mute`,...e.on===void 0?{}:{on:e.on}};case`seek`:return{action:`seek`,...e.seconds===void 0?{}:{seconds:e.seconds},...e.percent===void 0?{}:{percent:e.percent}};case`repeat`:return{action:`repeat`,mode:e.mode};case`shuffle`:return{action:`shuffle`,...e.on===void 0?{}:{on:e.on}};case`view`:return{action:`view`,view:e.view};case`remove`:return{action:`queue.remove`,index:e.index};case`clear`:return{action:`queue.clear`};case`jump`:return{action:`jump`,index:e.index};default:return null}}function xu({label:e,value:t,onChange:n,min:r,max:i,step:a}){let[o,s]=(0,l.useState)(String(t));return(0,l.useEffect)(()=>{s(e=>Number(e)===t?e:String(t))},[t]),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`number`,min:r,max:i,step:a,value:o,onChange:e=>{s(e.target.value),e.target.value.trim()!==``&&Number.isFinite(Number(e.target.value))&&n(Number(e.target.value))},onBlur:()=>s(String(t)),style:d})]})}async function Su(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var Cu={status:()=>Su(`/api/alexa`),allow:async(e,t)=>void await Su(`/api/alexa/devices/allow`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e,pin:t})}),forget:async e=>void await Su(`/api/alexa/devices/${encodeURIComponent(e)}`,{method:`DELETE`})},wu=/^amzn1\.ask\.skill\.[A-Za-z0-9-]{8,80}$/;function Tu(e){return e.skillId.trim()&&!wu.test(e.skillId.trim())?`A skill ID looks like amzn1.ask.skill.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (copy it from the console).`:e.invocationName.trim()?iu(e.invocationName):null}var Eu={"skill.json":`the skill's manifest (name, endpoint)`,"en-IN.json":`the English (India) interaction model`,"hi-IN.json":`the Hindi (India) interaction model`},Du={"en-IN":`English (India)`,"hi-IN":`Hindi (India)`},Ou=e=>{let t=Math.max(0,Math.round((Date.now()-e)/6e4));return t<1?`just now`:t<60?`${t} min ago`:`${Math.round(t/60)} h ago`};function ku({view:e,setView:t,api:n=Cu}){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(``),[u,f]=(0,l.useState)(null),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(!1),v=(0,l.useRef)(!0),y=(0,l.useCallback)(()=>n.status().then(e=>v.current&&i(e)).catch(()=>{}),[n]);(0,l.useEffect)(()=>(v.current=!0,y(),()=>{v.current=!1}),[y]);let b=async e=>{_(!0),f(null);try{await e()}catch(e){v.current&&f(e.message)}finally{v.current&&_(!1)}},S=Tu(e),C=r?.invocationName||e.invocationName,w=!!r?.endpoint&&!!r.invocationName;return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Friend talks to a skill of your own on Alexa. It is free: the skill stays in development mode in your own Amazon developer account and is never published, and only the Echo devices you allow can use it. Alexa can look things up and answer; anything that changes something is refused, or sent to your phone for a yes.`}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`In the Alexa developer console`}),r&&r.endpoint?(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Endpoint to paste (HTTPS, "My development endpoint has a certificate from a trusted certificate authority"): `,(0,p.jsx)(`code`,{children:r.endpoint}),` `,(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{navigator.clipboard?.writeText(r.endpoint).then(()=>h(!0),()=>{})},children:m?`Copied`:`Copy`})]}):r&&(0,p.jsx)(`p`,{className:`auth-note`,children:`No public address is set yet, so Amazon cannot reach Friend (friend config set publicUrl https://…).`}),(0,p.jsx)(`p`,{className:`auth-note`,children:`If your address changes later, paste the new address into the console again. Nothing else needs to change.`}),w?(0,p.jsx)(`ul`,{className:`plugins-list`,children:r.files.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`a`,{href:`/api/alexa/package/${e}`,download:e,children:e}),` `,(0,p.jsx)(`small`,{className:`auth-note`,children:Eu[e]??``})]},e))}):r&&r.endpoint&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Save an invocation name first; the files are made with it.`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Skill ID`}),(0,p.jsx)(`input`,{value:e.skillId,autoComplete:`off`,onChange:n=>t({...e,skillId:n.target.value}),placeholder:`amzn1.ask.skill.…`,style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Invocation name`}),(0,p.jsx)(`input`,{value:e.invocationName,autoComplete:`off`,onChange:n=>t({...e,invocationName:n.target.value}),placeholder:`jarvis assistant`,style:d})]}),S&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:S}),(0,p.jsxs)(`details`,{children:[(0,p.jsx)(`summary`,{className:`plugins-heading`,children:`Advanced`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Skill name`}),(0,p.jsx)(`input`,{value:e.skillName,onChange:n=>t({...e,skillName:n.target.value}),style:d})]}),(0,p.jsx)(`div`,{className:`settings-field`,role:`group`,"aria-label":`Languages`,children:Object.entries(Du).map(([n,r])=>(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.locales.includes(n),onChange:r=>{let i=r.target.checked?[...e.locales,n]:e.locales.filter(e=>e!==n);i.length>0&&t({...e,locales:Object.keys(Du).filter(e=>i.includes(e))})}}),(0,p.jsx)(`span`,{children:r})]},n))}),(0,p.jsx)(xu,{label:`Seconds to work on an answer`,value:e.answerSeconds,min:2,max:7.5,step:.5,onChange:n=>t({...e,answerSeconds:n})}),(0,p.jsx)(xu,{label:`Minutes to keep a late answer`,value:e.holdMinutes,min:1,max:60,onChange:n=>t({...e,holdMinutes:n})}),(0,p.jsx)(xu,{label:`Seconds to wait for your yes on your phone`,value:e.permissionSeconds,min:30,max:600,onChange:n=>t({...e,permissionSeconds:n})}),(0,p.jsx)(xu,{label:`Requests a minute allowed`,value:e.requestsPerMinute,min:10,max:600,onChange:n=>t({...e,requestsPerMinute:n})}),(0,p.jsx)(xu,{label:`Echo devices allowed`,value:e.maxDevices,min:1,max:50,onChange:n=>t({...e,maxDevices:n})}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Extra tools a voice may use without asking (one per line)`}),(0,p.jsx)(`textarea`,{rows:2,value:e.extraVoiceTools.join(`
|
|
66
66
|
`),onChange:n=>t({...e,extraVoiceTools:n.target.value.split(/[\s,]+/).filter(Boolean)})})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Tools that reach your PC, files, settings, add-ons or camera, and anything that needs your PIN, can never be added.`})]}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Echo devices`}),r&&r.waiting.length===0&&r.allowed.length===0&&(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Say "Alexa, ask `,C||`your invocation name`,`" on your Echo once; it will appear here for you to allow.`]}),(0,p.jsxs)(`ul`,{className:`plugins-list`,children:[(r?.waiting??[]).map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`b`,{children:[`Echo …`,e.short]}),` `,(0,p.jsxs)(`small`,{className:`auth-note`,children:[`waiting (`,e.locale,`), asked `,Ou(e.at)]}),` `,(0,p.jsx)(`button`,{type:`button`,style:d,disabled:g,onClick:()=>{o(e.short),c(``),f(null)},children:`Allow`})]},e.short)),(r?.allowed??[]).map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`b`,{children:e.name}),` `,(0,p.jsxs)(`small`,{className:`auth-note`,children:[`…`,e.short]}),` `,(0,p.jsx)(`button`,{type:`button`,style:d,disabled:g,onClick:()=>void b(async()=>{await n.forget(e.short),await y()}),children:`Forget`})]},e.short))]}),a&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Enter your PIN to allow Echo …`,a,`. Anyone who can speak to that Echo can then ask Friend things.`]}),(0,p.jsx)(x,{pin:s,onChange:c,onSubmit:()=>!g&&s.length>=6&&void b(async()=>{await n.allow(a,s),o(null),c(``),await y()})}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:g||s.length<6,onClick:()=>void b(async()=>{await n.allow(a,s),o(null),c(``),await y()}),children:`Allow this Echo`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{o(null),c(``),f(null)},children:`Back`})]})]}),u&&!S&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:u})]})}async function Au(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var ju=(e,t)=>Au(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),Mu={info:async()=>{let e=await Au(`/api/music/sources`);return{status:e.sources.find(e=>e.id===`soundcloud`)?.status??{connected:!1,needs:null,account:null},redirectUri:e.soundcloud.redirectUri,clientId:e.soundcloud.clientId,secretSet:e.soundcloud.secretSet}},saveCredentials:async(e,t,n)=>void await ju(`/api/music/soundcloud/credentials`,{clientId:e,...t?{clientSecret:t}:{},pin:n}),connect:async e=>(await ju(`/api/music/soundcloud/connect`,{pin:e})).url,disconnect:async e=>void await ju(`/api/music/soundcloud/disconnect`,{pin:e})},Nu=e=>e.trim()===``||/^[A-Za-z0-9]{8,64}$/.test(e.trim())?null:`A client id is letters and digits only, copied from your app at soundcloud.com/you/apps.`;function Pu({api:e=Mu,navigate:t=e=>window.location.assign(e)}){let[n,r]=(0,l.useState)(null),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(null),[f,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(null),[y,b]=(0,l.useState)(!1),S=(0,l.useRef)(!0),C=(0,l.useCallback)(async()=>{try{let t=await e.info();if(!S.current)return;r(t),a(t.clientId)}catch(e){S.current&&v(e.message)}},[e]);(0,l.useEffect)(()=>(S.current=!0,C(),()=>{S.current=!1}),[C]);let w=async()=>{if(c){g(!0),v(null);try{c===`save`?(await e.saveCredentials(i.trim(),o.trim()||void 0,f),S.current&&s(``),await C()):c===`connect`?t(await e.connect(f)):(await e.disconnect(f),await C()),S.current&&u(null)}catch(e){S.current&&v(e.message)}finally{S.current&&(g(!1),m(``))}}};if(c)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Enter your PIN `,c===`save`?`to save the SoundCloud app details`:c===`connect`?`to connect SoundCloud`:`to disconnect SoundCloud`,`.`]}),(0,p.jsx)(x,{pin:f,onChange:m,onSubmit:()=>!h&&f.length>=6&&void w()}),_&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:_}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:h||f.length<6,onClick:()=>void w(),children:c===`save`?`Save`:`Continue`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{u(null),m(``),v(null)},children:`Back`})]})]});let T=Nu(i),E=!!n&&i.trim()!==n.clientId||o.trim()!==``,D=!!n?.clientId&&n.secretSet,O=n?.status;return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Redirect address to add in your SoundCloud app`}),(0,p.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,p.jsx)(`input`,{type:`text`,readOnly:!0,value:n?.redirectUri??``,style:{flex:1},onFocus:e=>e.currentTarget.select()}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard?.writeText(n?.redirectUri??``).then(()=>b(!0),()=>{})},children:y?`Copied`:`Copy`})]})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Client id of your SoundCloud app`}),(0,p.jsx)(`input`,{type:`text`,value:i,maxLength:64,autoComplete:`off`,spellCheck:!1,onChange:e=>a(e.target.value)})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Client secret of your SoundCloud app`}),(0,p.jsx)(`input`,{type:`password`,value:o,maxLength:200,autoComplete:`new-password`,spellCheck:!1,onChange:e=>s(e.target.value)}),n?.secretSet&&(0,p.jsx)(`small`,{className:`auth-note`,children:`The secret is saved. Type a new one only to replace it.`})]}),T&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:T}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:!E||!i.trim()||T!==null||!n?.secretSet&&!o.trim(),onClick:()=>u(`save`),children:`Save`}),O?.connected?(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>u(`disconnect`),children:`Disconnect SoundCloud`}):(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:!D||E,onClick:()=>u(`connect`),children:`Connect SoundCloud`})]}),O?.connected&&(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Connected as `,O.account??`your account`,`.`]}),O?.needs&&(0,p.jsx)(`p`,{className:`auth-note`,children:O.needs}),_&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:_}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Sign-in is on SoundCloud's own page: Friend never sees your SoundCloud password. SoundCloud decides who can register an app, and some tracks only play with the right SoundCloud plan.`})]})}async function Fu(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var Iu=(e,t)=>Fu(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),Lu={info:async()=>{let e=await Fu(`/api/music/sources`);return{status:e.sources.find(e=>e.id===`spotify`)?.status??{connected:!1,needs:null,account:null},redirectUri:e.spotify.redirectUri,clientId:e.spotify.clientId}},saveClientId:async(e,t)=>void await Iu(`/api/music/spotify/client-id`,{clientId:e,pin:t}),connect:async e=>(await Iu(`/api/music/spotify/connect`,{pin:e})).url,disconnect:async e=>void await Iu(`/api/music/spotify/disconnect`,{pin:e})},Ru=e=>e.trim()===``||/^[A-Za-z0-9]{8,64}$/.test(e.trim())?null:`A client id is letters and digits only, copied from your app at developer.spotify.com.`;function zu({api:e=Lu,navigate:t=e=>window.location.assign(e)}){let[n,r]=(0,l.useState)(null),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(``),[f,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(!1),y=(0,l.useRef)(!0),b=(0,l.useCallback)(async()=>{try{let t=await e.info();if(!y.current)return;r(t),a(t.clientId)}catch(e){y.current&&g(e.message)}},[e]);(0,l.useEffect)(()=>(y.current=!0,b(),()=>{y.current=!1}),[b]);let S=async()=>{if(o){m(!0),g(null);try{o===`client`?(await e.saveClientId(i.trim(),c),await b()):o===`connect`?t(await e.connect(c)):(await e.disconnect(c),await b()),y.current&&s(null)}catch(e){y.current&&g(e.message)}finally{y.current&&(m(!1),u(``))}}};if(o)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Enter your PIN `,o===`client`?`to save the client id`:o===`connect`?`to connect Spotify`:`to disconnect Spotify`,`.`]}),(0,p.jsx)(x,{pin:c,onChange:u,onSubmit:()=>!f&&c.length>=6&&void S()}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:f||c.length<6,onClick:()=>void S(),children:o===`client`?`Save`:`Continue`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{s(null),u(``),g(null)},children:`Back`})]})]});let C=Ru(i),w=!!n&&i.trim()!==n.clientId,T=!!n?.clientId,E=n?.status;return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Redirect address to add in your Spotify app`}),(0,p.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,p.jsx)(`input`,{type:`text`,readOnly:!0,value:n?.redirectUri??``,style:{flex:1},onFocus:e=>e.currentTarget.select()}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard?.writeText(n?.redirectUri??``).then(()=>v(!0),()=>{})},children:_?`Copied`:`Copy`})]})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Client id of your Spotify app`}),(0,p.jsx)(`input`,{type:`text`,value:i,maxLength:64,autoComplete:`off`,spellCheck:!1,onChange:e=>a(e.target.value)})]}),C&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:C}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:!w||!i.trim()||C!==null,onClick:()=>s(`client`),children:`Save client id`}),E?.connected?(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>s(`disconnect`),children:`Disconnect Spotify`}):(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:!T||w,onClick:()=>s(`connect`),children:`Connect Spotify`})]}),E?.connected&&(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Connected as `,E.account??`your account`,`.`]}),E?.needs&&(0,p.jsx)(`p`,{className:`auth-note`,children:E.needs}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Sign-in is on Spotify's own page: Friend never sees your Spotify password. A development-mode Spotify app allows up to five people, and playing needs Spotify Premium on the account.`})]})}async function Bu(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var Vu=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),Hu={status:()=>Bu(`/api/brokers`),loginLink:e=>Bu(`/api/brokers/zerodha/login-link`,Vu(`POST`,{send:e})),runNow:e=>Bu(`/api/brokers/run`,Vu(`POST`,{kind:`custom`,send:e===!0})),addSchedule:async(e,t)=>void await Bu(`/api/brokers/schedules`,Vu(`POST`,{...e,pin:t})),removeSchedule:async e=>void await Bu(`/api/brokers/schedules/${e}`,{method:`DELETE`})},Uu=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Wu=[[`telegram`,`Telegram`],[`whatsapp`,`WhatsApp`],[`sms`,`SMS`]],Gu={telegram:`Telegram`,whatsapp:`WhatsApp`,sms:`SMS`};function Ku({view:e,setView:t,secret:n,setSecret:r,api:i=Hu}){let[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(null),[u,f]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[g,_]=(0,l.useState)(!1),[v,y]=(0,l.useState)(!1),[b,S]=(0,l.useState)(``),[C,w]=(0,l.useState)({name:`Morning report`,kind:`morning`,time:`09:30`,days:[1,2,3,4,5],channel:`telegram`}),[T,E]=(0,l.useState)(!1),D=(0,l.useRef)(!0),O=(0,l.useCallback)(()=>i.status().then(e=>D.current&&o(e)).catch(()=>{}),[i]);(0,l.useEffect)(()=>(D.current=!0,O(),()=>{D.current=!1}),[O]);let k=async e=>{E(!0),f(null),c(null);try{await e()}catch(e){D.current&&f(e.message)}finally{D.current&&E(!1)}},A=e.zerodha,j=n=>t({...e,...n}),ee=a?.schedules[0]?.channel??`telegram`,M=()=>/^([01]\d|2[0-3]):[0-5]\d$/.test(C.time)?C.days.length===0?`Choose at least one day.`:C.name.trim()?null:`Give the report a name.`:`Write the time like 09:30 (HH:MM, 24 hour).`,N=()=>k(async()=>{await i.addSchedule({...C,name:C.name.trim()},b),_(!1),y(!1),S(``),await O()});return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Friend only reads your account. It cannot place orders. The figures you ask about pass through the AI model you chose (Claude from Anthropic, or Ollama on this PC), and a report you schedule goes to the messaging app you pick (Telegram or WhatsApp). Nothing else leaves this PC.`}),(0,p.jsx)(`p`,{className:`auth-note`,children:a?.redirectUrl?(0,p.jsxs)(p.Fragment,{children:[`In your Kite Connect app, set the redirect URL to `,(0,p.jsx)(`code`,{children:a.redirectUrl})]}):`No public address is set yet, so Zerodha cannot send you back to Friend after login (friend config set publicUrl https://…).`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`API key`}),(0,p.jsx)(`input`,{value:A.apiKey,autoComplete:`off`,onChange:e=>j({zerodha:{...A,apiKey:e.target.value}}),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`API secret`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,value:n,placeholder:A.secretSet?`A secret is saved. Type to replace it.`:``,onChange:e=>r(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Time zone`}),(0,p.jsx)(`input`,{value:e.timezone,onChange:e=>j({timezone:e.target.value}),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Days with no reports (one per line, YYYY-MM-DD)`}),(0,p.jsx)(`textarea`,{value:e.skipDates.join(`
|
|
67
67
|
`),rows:3,onChange:e=>j({skipDates:e.target.value.split(/[\s,]+/).filter(Boolean)})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Remind me to log in (minutes before the first report, 0 = never)`}),(0,p.jsx)(`input`,{type:`number`,min:0,max:120,value:e.loginReminderMinutes,onChange:e=>j({loginReminderMinutes:Number(e.target.value)}),style:d})]}),(0,p.jsxs)(`details`,{children:[(0,p.jsx)(`summary`,{className:`plugins-heading`,children:`Report options`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Currency sign`}),(0,p.jsx)(`input`,{value:e.currencySymbol,maxLength:4,onChange:e=>j({currencySymbol:e.target.value}),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Currency word (spoken)`}),(0,p.jsx)(`input`,{value:e.currencyName,maxLength:20,onChange:e=>j({currencyName:e.target.value}),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Number format (locale)`}),(0,p.jsx)(`input`,{value:e.numberLocale,onChange:e=>j({numberLocale:e.target.value}),placeholder:`en-IN, en-US, de-DE`,style:d})]}),(0,p.jsx)(xu,{label:`Mention a holding above this share of the portfolio (%)`,value:e.concentrationPct,min:5,max:90,onChange:e=>j({concentrationPct:e})}),(0,p.jsx)(xu,{label:`Mention a holding down more than this today (%)`,value:e.bigDropPct,min:1,max:50,onChange:e=>j({bigDropPct:e})}),(0,p.jsx)(xu,{label:`Seconds to keep an account read`,value:e.cacheSeconds,min:5,max:300,onChange:e=>j({cacheSeconds:e})}),(0,p.jsx)(xu,{label:`Most report schedules`,value:e.maxSchedules,min:1,max:50,onChange:e=>j({maxSchedules:e})}),(0,p.jsx)(xu,{label:`Tries a day for a report`,value:e.maxTriesPerDay,min:1,max:10,onChange:e=>j({maxTriesPerDay:e})})]}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Daily login`}),(0,p.jsx)(`p`,{className:(a?.zerodha.loggedIn,`auth-note`),children:a?.zerodha.detail??`Checking…`}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:T,onClick:()=>void k(async()=>{let e=await i.loginLink(!1);e.url&&window.open(e.url,`_blank`,`noopener,noreferrer`)}),children:`Open Zerodha login`}),(0,p.jsxs)(`button`,{type:`button`,style:d,disabled:T,onClick:()=>void k(async()=>{let e=await i.loginLink(!0);c(`The login link was sent to your phone${e.via?` (${Gu[e.via]??e.via})`:``}.`)}),children:[`Send me the login link on `,Gu[ee]??`Telegram`]})]}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Reports`}),a&&a.schedules.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`No reports are scheduled.`}),(0,p.jsx)(`ul`,{className:`plugins-list`,children:(a?.schedules??[]).map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`b`,{children:e.name}),` `,(0,p.jsxs)(`small`,{className:`auth-note`,children:[e.time,`, `,e.days.map(e=>Uu[e-1]).join(` `),` to `,Gu[e.channel],e.lastRunDay?`, last sent ${e.lastRunDay}`:``]}),` `,(0,p.jsx)(`button`,{type:`button`,style:d,disabled:T,onClick:()=>void k(async()=>{await i.removeSchedule(e.id),await O()}),children:`Remove`})]},e.id))}),g&&!v&&(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Name`}),(0,p.jsx)(`input`,{value:C.name,onChange:e=>w({...C,name:e.target.value}),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Kind`}),(0,p.jsxs)(`select`,{value:C.kind,onChange:e=>w({...C,kind:e.target.value}),style:d,children:[(0,p.jsx)(`option`,{value:`morning`,children:`Morning`}),(0,p.jsx)(`option`,{value:`close`,children:`Market close`}),(0,p.jsx)(`option`,{value:`custom`,children:`Custom`})]})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Time (24 hour)`}),(0,p.jsx)(`input`,{value:C.time,onChange:e=>w({...C,time:e.target.value}),placeholder:`09:30`,style:d})]}),(0,p.jsx)(`div`,{className:`settings-field`,role:`group`,"aria-label":`Days`,children:Uu.map((e,t)=>(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:C.days.includes(t+1),onChange:e=>w({...C,days:e.target.checked?[...C.days,t+1].sort():C.days.filter(e=>e!==t+1)})}),(0,p.jsx)(`span`,{children:e})]},e))}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Send it on`}),(0,p.jsx)(`select`,{value:C.channel,onChange:e=>w({...C,channel:e.target.value}),style:d,children:Wu.map(([e,t])=>(0,p.jsx)(`option`,{value:e,children:t},e))})]}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:()=>{let e=M();f(e),e||y(!0)},children:`Add report…`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{_(!1),f(null)},children:`Cancel`})]})]}),g&&v&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Enter your PIN to add this report. It sends your portfolio figures to `,Gu[C.channel],`.`]}),(0,p.jsx)(x,{pin:b,onChange:S,onSubmit:()=>!T&&b.length>=6&&void N()}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:T||b.length<6,onClick:()=>void N(),children:`Add report`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{y(!1),S(``)},children:`Back`})]})]}),!g&&(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{_(!0),f(null),c(null)},children:`Add a report`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:T,onClick:()=>void k(async()=>h((await i.runNow()).text)),children:`Show a report now`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:T,onClick:()=>void k(async()=>{await i.runNow(!0),c(`The report was sent to your phone.`)}),children:`Send a report to my phone`})]}),m&&(0,p.jsx)(`pre`,{className:`auth-note`,style:{whiteSpace:`pre-wrap`},children:m}),s&&(0,p.jsx)(`p`,{className:`auth-note`,children:s}),u&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:u})]})}var qu={telegram:{installed:!1,enabled:!1,tokenSet:!1,linked:!1},twilio:{installed:!1,enabled:!1,accountSid:``,tokenSet:!1,smsFrom:``,whatsappFrom:``,ownerNumber:``}},Ju={zerodha:{installed:!1,enabled:!1,apiKey:``,secretSet:!1},timezone:`Asia/Kolkata`,skipDates:[],loginReminderMinutes:15,currencySymbol:`₹`,currencyName:`rupees`,numberLocale:`en-IN`,concentrationPct:30,bigDropPct:5,cacheSeconds:30,maxSchedules:20,maxTriesPerDay:3},Yu=[`currencySymbol`,`currencyName`,`numberLocale`,`concentrationPct`,`bigDropPct`,`cacheSeconds`,`maxSchedules`,`maxTriesPerDay`],Xu=[`skillName`,`locales`,`answerSeconds`,`holdMinutes`,`permissionSeconds`,`requestsPerMinute`,`maxDevices`,`extraVoiceTools`],Zu=(e,t,n)=>Object.fromEntries(n.filter(n=>JSON.stringify(e[n])!==JSON.stringify(t[n])).map(t=>[t,e[t]])),Qu={installed:!1,enabled:!1,skillId:``,invocationName:``,allowed:[],skillName:`Friend Assistant`,locales:[`en-IN`,`hi-IN`],answerSeconds:6.5,holdMinutes:10,permissionSeconds:120,requestsPerMinute:60,maxDevices:10,extraVoiceTools:[]};function $u({integration:e,onBack:t,settingsApi:n=ze,channelsApi:r=Me,brokersApi:i=Hu,alexaApi:a=Cu,spotifyApi:o=Lu,soundcloudApi:s=Mu}){let[c,u]=(0,l.useState)(null),[f,m]=(0,l.useState)(qu),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(Ju),[y,b]=(0,l.useState)(null),[S,C]=(0,l.useState)(Qu),[w,T]=(0,l.useState)(``),[E,D]=(0,l.useState)(null),[O,k]=(0,l.useState)(!1),[A,j]=(0,l.useState)(``),[ee,M]=(0,l.useState)(!1),[N,P]=(0,l.useState)(null),[F,I]=(0,l.useState)(null),te=(0,l.useRef)(!0),ne=e.id===`telegram`,L=e.id===`zerodha`,re=e.id===`alexa`,ie=e.id===`spotify`,ae=e.id===`soundcloud`,oe=e.id===`audius`;(0,l.useEffect)(()=>(te.current=!0,n.get().then(e=>{if(!te.current)return;let t=e.channels??qu;u(t),m(structuredClone(t));let n=e.brokers??Ju;g(n),v(structuredClone(n));let r=e.alexa??Qu;b(r),C(structuredClone(r))}).catch(e=>te.current&&P(e.message)),r.status().then(e=>te.current&&D(e)).catch(()=>{}),()=>{te.current=!1}),[n,r]);let se=(()=>{if(ie||ae||oe)return{};if(re){if(!y)return{};let e=Zu(S,y,Xu);return S.skillId.trim()!==y.skillId&&(e.skillId=S.skillId.trim()),S.invocationName.trim()!==y.invocationName&&(e.invocationName=S.invocationName.trim()),Object.keys(e).length?{alexa:e}:{}}if(L){if(!h)return{};let e={};_.zerodha.apiKey!==h.zerodha.apiKey&&(e.apiKey=_.zerodha.apiKey.trim()),w.trim()&&(e.apiSecret=w.trim());let t={};return Object.keys(e).length&&(t.zerodha=e),_.timezone!==h.timezone&&(t.timezone=_.timezone.trim()),JSON.stringify(_.skipDates)!==JSON.stringify(h.skipDates)&&(t.skipDates=_.skipDates),_.loginReminderMinutes!==h.loginReminderMinutes&&(t.loginReminderMinutes=_.loginReminderMinutes),Object.assign(t,Zu(_,h,Yu)),Object.keys(t).length?{brokers:t}:{}}if(!c)return{};if(ne)return w.trim()?{channels:{telegram:{botToken:w.trim()}}}:{};let e={};for(let t of[`accountSid`,`smsFrom`,`whatsappFrom`,`ownerNumber`])f.twilio[t]!==c.twilio[t]&&(e[t]=f.twilio[t]);return w.trim()&&(e.authToken=w.trim()),Object.keys(e).length?{channels:{twilio:e}}:{}})(),ce=Object.keys(se).length>0,le=async()=>{M(!0),P(null);try{let t=await n.save(se,A);if(!te.current)return;let r=t.settings.channels??qu;u(r),m(structuredClone(r));let i=t.settings.brokers??Ju;g(i),v(structuredClone(i));let a=t.settings.alexa??Qu;b(a),C(structuredClone(a)),T(``),k(!1),I(ne&&!e.enabled?`Saved. Now press Turn on in the plugins list.`:`Saved.`)}catch(e){te.current&&P(e.message)}finally{te.current&&(M(!1),j(``))}};return O?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Enter your PIN to save these changes.`}),(0,p.jsx)(x,{pin:A,onChange:j,onSubmit:()=>!ee&&void le()}),N&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:N}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:ee||A.length<6,onClick:()=>void le(),children:`Save`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{k(!1),j(``),P(null)},children:`Back`})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:e.name}),(0,p.jsx)(`p`,{className:`auth-note`,children:e.detail||e.description}),(0,p.jsx)(`ol`,{className:`integration-steps`,children:e.steps.map((e,t)=>(0,p.jsx)(`li`,{className:e.done?`done`:void 0,children:e.text},t))}),ie&&(0,p.jsx)(zu,{api:o}),ae&&(0,p.jsx)(Pu,{api:s}),re&&y&&(0,p.jsx)(ku,{view:S,setView:C,api:a}),L&&h&&(0,p.jsx)(Ku,{view:_,setView:v,secret:w,setSecret:T,api:i}),!L&&!re&&!ie&&!ae&&!oe&&c&&(ne?(0,p.jsx)(Ne,{view:{...f.telegram,enabled:e.enabled},secret:w,setSecret:T,api:r}):(0,p.jsx)(Pe,{view:f.twilio,setView:e=>m({...f,twilio:e}),secret:w,setSecret:T,webhook:E?.twilio.webhook??null})),F&&!ce&&(0,p.jsx)(`p`,{className:`auth-note`,children:F}),N&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:N}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[!ie&&!ae&&!oe&&(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:!ce||ee||re&&Tu(S)!==null,onClick:()=>k(!0),children:ce?`Save…`:`Save`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:`Back`})]})]})}async function ed(e,t={}){let n;try{n=await fetch(`/api/plugins${e}`,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!n.ok){let e=``;try{e=(await n.json()).error??``}catch{}throw Error(e||(n.status===401?`Please sign in again.`:n.status===429?`Too many attempts. Wait a moment.`:`The request failed (${n.status}).`))}return await n.json()}var td=(e,t)=>({method:e,...t===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(t)}}),nd={list:()=>ed(``),install:async(e,t)=>{await ed(`/install`,td(`POST`,{id:e,pin:t}))},setEnabled:async(e,t,n)=>{await ed(`/${encodeURIComponent(e)}/enabled`,td(`POST`,{enabled:t,...n?{pin:n}:{}}))},remove:async e=>{await ed(`/${encodeURIComponent(e)}`,td(`DELETE`))},reload:async()=>{await ed(`/reload`,td(`POST`,{}))}},rd=(e,t)=>`${e} ${t}${e===1?``:`s`}`,id={"not-installed":``,"needs-setup":`Needs setup`,off:`Off`,connecting:`Connecting…`,online:`On`,error:`Not working`},ad=e=>({id:e.id,name:e.name,version:``,description:e.description,tools:0,skills:0,error:null,installed:!1});function od({api:e=nd,onClose:t,initialConfigure:n}){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(n??null),[u,f]=(0,l.useState)(``),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(null),v=(0,l.useRef)(!0);(0,l.useEffect)(()=>{n&&c(n)},[n]);let y=(0,l.useCallback)(async()=>{try{let t=await e.list();v.current&&i(t)}catch(e){v.current&&_(e.message)}},[e]);(0,l.useEffect)(()=>(v.current=!0,y(),()=>{v.current=!1}),[y]);let b=async e=>{_(null),h(!0);try{if(await e(),!v.current)return;o(null),await y()}catch(e){v.current&&_(e.message)}finally{v.current&&(h(!1),f(``))}},S=()=>{a&&b(()=>a.kind===`install`?e.install(a.plugin.id,u):e.setEnabled(a.id,!0,u))},C=r?.integrations??[],w=(r?.catalog??[]).filter(e=>!e.installed),T=C.filter(e=>e.installed),E=C.filter(e=>!e.installed),D=s?C.find(e=>e.id===s&&e.installed):void 0;return(0,p.jsxs)(`div`,{className:`approval plugins glass`,role:`dialog`,"aria-label":`Plugins`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Plugins`})}),(0,p.jsx)(`div`,{className:`plugins-body`,children:a?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:a.kind===`install`?a.integration?`Install ${a.plugin.name}? It connects Friend to an outside service, and you set it up afterwards. Enter your PIN to confirm.`:`Install ${a.plugin.name}? ${a.plugin.tools>0?`Its tools run in a Docker sandbox with no network and no access to your files, and ask for your approval every time. `:``}Enter your PIN to confirm.`:`Switch on ${a.name}? Enter your PIN to confirm.`}),(0,p.jsx)(x,{pin:u,onChange:f,onSubmit:()=>!m&&S()}),g&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:g}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:m||u.length<6,onClick:S,children:`Confirm`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{o(null),f(``),_(null)},children:`Back`})]})]}):D?(0,p.jsx)($u,{integration:D,onBack:()=>{c(null),y()}}):(0,p.jsxs)(p.Fragment,{children:[g&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:g}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Installed`}),r&&r.installed.length===0&&T.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing installed yet.`}),(0,p.jsxs)(`ul`,{className:`plugin-list`,children:[T.map(t=>(0,p.jsxs)(`li`,{"data-integration":t.id,children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:t.name}),` `,(0,p.jsx)(`small`,{children:id[t.state]}),(0,p.jsx)(`div`,{className:t.state===`error`?`auth-error`:`auth-note`,children:t.detail})]}),(0,p.jsxs)(`div`,{className:`plugin-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:m,onClick:()=>c(t.id),children:`Configure`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:m,onClick:()=>t.enabled?void b(()=>e.setEnabled(t.id,!1,void 0)):o({kind:`enable`,id:t.id,name:t.name}),children:t.enabled?`Turn off`:`Turn on`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:m,onClick:()=>void b(()=>e.remove(t.id)),children:`Remove`})]})]},t.id)),(r?.installed??[]).map(t=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:t.name}),` `,(0,p.jsx)(`small`,{children:t.version}),(0,p.jsx)(`div`,{className:`auth-note`,children:t.error?`This plugin cannot be used: ${t.error}`:`${rd(t.skills.length,`skill`)}, ${rd(t.tools.length,`tool`)}${t.enabled?``:` (off)`}`})]}),(0,p.jsxs)(`div`,{className:`plugin-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:m,onClick:()=>t.enabled?void b(()=>e.setEnabled(t.id,!1,void 0)):o({kind:`enable`,id:t.id,name:t.name}),children:t.enabled?`Turn off`:`Turn on`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:m,onClick:()=>void b(()=>e.remove(t.id)),children:`Remove`})]})]},t.id))]}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Available`}),r&&w.length===0&&E.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Everything in the catalog is installed.`}),(0,p.jsxs)(`ul`,{className:`plugin-list`,children:[E.map(e=>(0,p.jsxs)(`li`,{"data-integration":e.id,children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:e.name}),` `,(0,p.jsx)(`small`,{children:`integration`}),(0,p.jsx)(`div`,{className:`auth-note`,children:e.description})]}),(0,p.jsx)(`div`,{className:`plugin-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:m,onClick:()=>o({kind:`install`,plugin:ad(e),integration:!0}),children:`Install`})})]},e.id)),w.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:e.name}),` `,(0,p.jsx)(`small`,{children:e.version}),(0,p.jsx)(`div`,{className:`auth-note`,children:e.error?`Cannot be installed: ${e.error}`:`${e.description} (${rd(e.skills,`skill`)}, ${rd(e.tools,`tool`)})`})]}),(0,p.jsx)(`div`,{className:`plugin-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:m||!!e.error,onClick:()=>o({kind:`install`,plugin:e}),children:`Install`})})]},e.id))]}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:m,onClick:()=>void b(()=>e.reload()),children:`Reload plugins`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:`Close`})]})]})})]})}function sd(e){return e.webgl?e.reducedMotion?6e3:e.memoryGb===void 0?8e3:e.memoryGb>=8?12e3:e.memoryGb>=4?9e3:6e3:0}function cd(){let e=!1;try{let t=document.createElement(`canvas`);e=!!(t.getContext(`webgl2`)||t.getContext(`webgl`))}catch{e=!1}return{webgl:e,memoryGb:navigator.deviceMemory,reducedMotion:typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}}var ld={idle:{speed:.15,noise:.05,brightness:.85,size:1.6,rotate:.08,tighten:0},listening:{speed:.4,noise:.1,brightness:1.1,size:1.9,rotate:.15,tighten:.08},thinking:{speed:1.1,noise:.22,brightness:1,size:1.7,rotate:.35,tighten:0},speaking:{speed:.6,noise:.12,brightness:1.25,size:1.8,rotate:.12,tighten:0}},ud=e=>Number.isFinite(e)?Math.min(1,Math.max(0,e)):0,dd=class{state=`idle`;amplitudeTarget=0;intensity=.6;amp=0;cur={...ld.idle};phase=0;angle=0;motion;constructor(e={}){this.motion=e.reducedMotion?.25:1}setState(e){this.state=e}setAmplitude(e){this.amplitudeTarget=ud(e)}setIntensity(e){this.intensity=ud(e)}tick(e){let t=ld[this.state],n=1-Math.exp(-e*3);for(let e of Object.keys(t))this.cur[e]+=(t[e]-this.cur[e])*n;this.amp+=(this.amplitudeTarget-this.amp)*(1-Math.exp(-e*12)),this.amplitudeTarget*=Math.exp(-e*3),this.phase+=e*this.cur.speed*this.motion,this.angle+=e*this.cur.rotate*this.motion}uniforms(){return{...this.cur,brightness:this.cur.brightness*(.5+this.intensity)/1.1,speed:this.cur.speed*this.motion,rotate:this.cur.rotate*this.motion,amplitude:this.amp*(this.motion===1?1:.5),phase:this.phase,angle:this.angle}}},fd=1e3,pd=1001,md=1002,hd=1003,gd=1004,_d=1005,vd=1006,yd=1007,bd=1008,xd=1009,Sd=1010,Cd=1011,wd=1012,Td=1013,Ed=1014,Dd=1015,Od=1016,kd=1017,Ad=1018,jd=1020,Md=35902,Nd=35899,Pd=1021,Fd=1022,Id=1023,Ld=1026,Rd=1027,zd=1028,Bd=1029,Vd=1030,Hd=1031,Ud=1033,Wd=33776,Gd=33777,Kd=33778,qd=33779,Jd=35840,Yd=35841,Xd=35842,Zd=35843,Qd=36196,$d=37492,ef=37496,tf=37488,nf=37489,rf=37490,af=37491,of=37808,sf=37809,cf=37810,lf=37811,uf=37812,df=37813,ff=37814,pf=37815,mf=37816,hf=37817,gf=37818,_f=37819,vf=37820,yf=37821,bf=36492,xf=36494,Sf=36495,Cf=36283,wf=36284,Tf=36285,Ef=36286,Df=2300,Of=2301,kf=2302,Af=2303,jf=2400,Mf=2401,Nf=2402,Pf=3200,Ff=`srgb`,If=`srgb-linear`,Lf=`linear`,Rf=`srgb`,zf=7680,Bf=35044,Vf=2e3;function Hf(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Uf(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Wf(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function Gf(){let e=Wf(`canvas`);return e.style.display=`block`,e}var Kf={};function qf(...e){let t=`THREE.`+e.shift();console.log(t,...e)}function Jf(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function X(...e){e=Jf(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function Z(...e){e=Jf(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Yf(...e){let t=e.join(` `);t in Kf||(Kf[t]=!0,X(...e))}function Xf(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var Zf={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Qf=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n!==void 0&&n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},$f=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),ep=Math.PI/180,tp=180/Math.PI;function np(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return($f[e&255]+$f[e>>8&255]+$f[e>>16&255]+$f[e>>24&255]+`-`+$f[t&255]+$f[t>>8&255]+`-`+$f[t>>16&15|64]+$f[t>>24&255]+`-`+$f[n&63|128]+$f[n>>8&255]+`-`+$f[n>>16&255]+$f[n>>24&255]+$f[r&255]+$f[r>>8&255]+$f[r>>16&255]+$f[r>>24&255]).toLowerCase()}function rp(e,t,n){return Math.max(t,Math.min(n,e))}function ip(e,t){return(e%t+t)%t}function ap(e,t,n){return(1-n)*e+n*t}function op(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}function sp(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}var cp=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`THREE.Vector2: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`THREE.Vector2: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=rp(this.x,e.x,t.x),this.y=rp(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=rp(this.x,e,t),this.y=rp(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(rp(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(rp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},lp=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:X(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(rp(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Q=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`THREE.Vector3: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`THREE.Vector3: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(dp.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(dp.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=rp(this.x,e.x,t.x),this.y=rp(this.y,e.y,t.y),this.z=rp(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=rp(this.x,e,t),this.y=rp(this.y,e,t),this.z=rp(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(rp(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return up.copy(this).projectOnVector(e),this.sub(up)}reflect(e){return this.sub(up.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(rp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},up=new Q,dp=new lp,fp=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return Yf(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(pp.makeScale(e,t)),this}rotate(e){return Yf(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(pp.makeRotation(-e)),this}translate(e,t){return Yf(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(pp.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},pp=new fp,mp=new fp().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),hp=new fp().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function gp(){let e={enabled:!0,workingColorSpace:If,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=vp(e.r),e.g=vp(e.g),e.b=vp(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=yp(e.r),e.g=yp(e.g),e.b=yp(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Lf:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Yf(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Yf(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[If]:{primaries:t,whitePoint:r,transfer:Lf,toXYZ:mp,fromXYZ:hp,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ff},outputColorSpaceConfig:{drawingBufferColorSpace:Ff}},[Ff]:{primaries:t,whitePoint:r,transfer:Rf,toXYZ:mp,fromXYZ:hp,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ff}}}),e}var _p=gp();function vp(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function yp(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var bp,xp=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{bp===void 0&&(bp=Wf(`canvas`)),bp.width=e.width,bp.height=e.height;let t=bp.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=bp}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Wf(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=vp(i[e]/255)*255;return n.putImageData(r,0,0),t}if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(vp(t[e]/255)*255):t[e]=vp(t[e]);return{data:t,width:e.width,height:e.height}}return X(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},Sp=0,Cp=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Sp++}),this.uuid=np(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(wp(r[t].image)):e.push(wp(r[t]))}else e=wp(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function wp(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?xp.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(X(`Texture: Unable to serialize Texture.`),{})}var Tp=0,Ep=new Q,Dp=class e extends Qf{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=pd,i=pd,a=vd,o=bd,s=Id,c=xd,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Tp++}),this.uuid=np(),this.name=``,this.source=new Cp(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new cp(0,0),this.repeat=new cp(1,1),this.center=new cp(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fp,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Ep).x}get height(){return this.source.getSize(Ep).y}get depth(){return this.source.getSize(Ep).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){X(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){X(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case fd:e.x-=Math.floor(e.x);break;case pd:e.x=e.x<0?0:1;break;case md:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case fd:e.y-=Math.floor(e.y);break;case pd:e.y=e.y<0?0:1;break;case md:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Dp.DEFAULT_IMAGE=null,Dp.DEFAULT_MAPPING=300,Dp.DEFAULT_ANISOTROPY=1;var Op=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`THREE.Vector4: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`THREE.Vector4: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=rp(this.x,e.x,t.x),this.y=rp(this.y,e.y,t.y),this.z=rp(this.z,e.z,t.z),this.w=rp(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=rp(this.x,e,t),this.y=rp(this.y,e,t),this.z=rp(this.z,e,t),this.w=rp(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(rp(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},kp=class extends Qf{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:vd,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Op(0,0,e,t),this.scissorTest=!1,this.viewport=new Op(0,0,e,t),this.textures=[];let r=new Dp({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:vd,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Cp(n)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null){if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture}return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:`dispose`})}},Ap=class extends kp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},jp=class extends Dp{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=hd,this.minFilter=hd,this.wrapR=pd,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Mp=class extends Dp{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=hd,this.minFilter=hd,this.wrapR=pd,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}},Np=class e{static{e.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,r=1/Pp.setFromMatrixColumn(e,0).length(),i=1/Pp.setFromMatrixColumn(e,1).length(),a=1/Pp.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ip,e,Lp)}lookAt(e,t,n){let r=this.elements;return Bp.subVectors(e,t),Bp.lengthSq()===0&&(Bp.z=1),Bp.normalize(),Rp.crossVectors(n,Bp),Rp.lengthSq()===0&&(Math.abs(n.z)===1?Bp.x+=1e-4:Bp.z+=1e-4,Bp.normalize(),Rp.crossVectors(n,Bp)),Rp.normalize(),zp.crossVectors(Bp,Rp),r[0]=Rp.x,r[4]=zp.x,r[8]=Bp.x,r[1]=Rp.y,r[5]=zp.y,r[9]=Bp.y,r[2]=Rp.z,r[6]=zp.z,r[10]=Bp.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],ee=r[14],M=r[3],N=r[7],P=r[11],F=r[15];return i[0]=a*x+o*T+s*k+c*M,i[4]=a*S+o*E+s*A+c*N,i[8]=a*C+o*D+s*j+c*P,i[12]=a*w+o*O+s*ee+c*F,i[1]=l*x+u*T+d*k+f*M,i[5]=l*S+u*E+d*A+f*N,i[9]=l*C+u*D+d*j+f*P,i[13]=l*w+u*O+d*ee+f*F,i[2]=p*x+m*T+h*k+g*M,i[6]=p*S+m*E+h*A+g*N,i[10]=p*C+m*D+h*j+g*P,i[14]=p*w+m*O+h*ee+g*F,i[3]=_*x+v*T+y*k+b*M,i[7]=_*S+v*E+y*A+b*N,i[11]=_*C+v*D+y*j+b*P,i[15]=_*w+v*O+y*ee+b*F,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],c=e[6],l=e[10];return t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinantAffine();if(i===0)return n.set(1,1,1),t.identity(),this;let a=Pp.set(r[0],r[1],r[2]).length(),o=Pp.set(r[4],r[5],r[6]).length(),s=Pp.set(r[8],r[9],r[10]).length();i<0&&(a=-a),Fp.copy(this);let c=1/a,l=1/o,u=1/s;return Fp.elements[0]*=c,Fp.elements[1]*=c,Fp.elements[2]*=c,Fp.elements[4]*=l,Fp.elements[5]*=l,Fp.elements[6]*=l,Fp.elements[8]*=u,Fp.elements[9]*=u,Fp.elements[10]*=u,t.setFromRotationMatrix(Fp),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=Vf,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Vf,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Pp=new Q,Fp=new Np,Ip=new Q(0,0,0),Lp=new Q(1,1,1),Rp=new Q,zp=new Q,Bp=new Q,Vp=new Np,Hp=new lp,Up=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(rp(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-rp(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(rp(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-rp(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(rp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-rp(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:X(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Vp.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Vp,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Hp.setFromEuler(this),this.setFromQuaternion(Hp,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Up.DEFAULT_ORDER=`XYZ`;var Wp=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return!!(this.mask&(1<<e|0))}},Gp=0,Kp=new Q,qp=new lp,Jp=new Np,Yp=new Q,Xp=new Q,Zp=new Q,Qp=new lp,$p=new Q(1,0,0),em=new Q(0,1,0),tm=new Q(0,0,1),nm={type:`added`},rm={type:`removed`},im={type:`childadded`,child:null},am={type:`childremoved`,child:null},om=class e extends Qf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gp++}),this.uuid=np(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new Q,n=new Up,r=new lp,i=new Q(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Np},normalMatrix:{value:new fp}}),this.matrix=new Np,this.matrixWorld=new Np,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Wp,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return qp.setFromAxisAngle(e,t),this.quaternion.multiply(qp),this}rotateOnWorldAxis(e,t){return qp.setFromAxisAngle(e,t),this.quaternion.premultiply(qp),this}rotateX(e){return this.rotateOnAxis($p,e)}rotateY(e){return this.rotateOnAxis(em,e)}rotateZ(e){return this.rotateOnAxis(tm,e)}translateOnAxis(e,t){return Kp.copy(e).applyQuaternion(this.quaternion),this.position.add(Kp.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($p,e)}translateY(e){return this.translateOnAxis(em,e)}translateZ(e){return this.translateOnAxis(tm,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Jp.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Yp.copy(e):Yp.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Xp.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Jp.lookAt(Xp,Yp,this.up):Jp.lookAt(Yp,Xp,this.up),this.quaternion.setFromRotationMatrix(Jp),r&&(Jp.extractRotation(r.matrixWorld),qp.setFromRotationMatrix(Jp),this.quaternion.premultiply(qp.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(Z(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(nm),im.child=e,this.dispatchEvent(im),im.child=null):Z(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(rm),am.child=e,this.dispatchEvent(am),am.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Jp.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Jp.multiply(e.parent.matrixWorld)),e.applyMatrix4(Jp),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(nm),im.child=e,this.dispatchEvent(im),im.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xp,e,Zp),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xp,Qp,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let e=this.children;for(let t=0,r=e.length;t<r;t++)e[t].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0){if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material)}if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}dispose(){this.dispatchEvent({type:`dispose`})}};om.DEFAULT_UP=new Q(0,1,0),om.DEFAULT_MATRIX_AUTO_UPDATE=!0,om.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var sm=class extends om{constructor(){super(),this.isGroup=!0,this.type=`Group`}},cm={type:`move`},lm=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new sm,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new sm,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Q,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Q),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new sm,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Q,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Q,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(cm)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new sm;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},um={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dm={h:0,s:0,l:0},fm={h:0,s:0,l:0};function pm(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var mm=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ff){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,_p.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=_p.workingColorSpace){return this.r=e,this.g=t,this.b=n,_p.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=_p.workingColorSpace){if(e=ip(e,1),t=rp(t,0,1),n=rp(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=pm(i,r,e+1/3),this.g=pm(i,r,e),this.b=pm(i,r,e-1/3)}return _p.colorSpaceToWorking(this,r),this}setStyle(e,t=Ff){function n(t){t!==void 0&&parseFloat(t)<1&&X(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:X(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);X(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ff){let n=um[e.toLowerCase()];return n===void 0?X(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=vp(e.r),this.g=vp(e.g),this.b=vp(e.b),this}copyLinearToSRGB(e){return this.r=yp(e.r),this.g=yp(e.g),this.b=yp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ff){return _p.workingToColorSpace(hm.copy(this),e),Math.round(rp(hm.r*255,0,255))*65536+Math.round(rp(hm.g*255,0,255))*256+Math.round(rp(hm.b*255,0,255))}getHexString(e=Ff){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=_p.workingColorSpace){_p.workingToColorSpace(hm.copy(this),t);let n=hm.r,r=hm.g,i=hm.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=_p.workingColorSpace){return _p.workingToColorSpace(hm.copy(this),t),e.r=hm.r,e.g=hm.g,e.b=hm.b,e}getStyle(e=Ff){_p.workingToColorSpace(hm.copy(this),e);let t=hm.r,n=hm.g,r=hm.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(dm),this.setHSL(dm.h+e,dm.s+t,dm.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(dm),e.getHSL(fm);let n=ap(dm.h,fm.h,t),r=ap(dm.s,fm.s,t),i=ap(dm.l,fm.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},hm=new mm;mm.NAMES=um;var gm=class extends om{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Up,this.environmentIntensity=1,this.environmentRotation=new Up,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},_m=new Q,vm=new Q,ym=new Q,bm=new Q,xm=new Q,Sm=new Q,Cm=new Q,wm=new Q,Tm=new Q,Em=new Q,Dm=new Op,Om=new Op,km=new Op,Am=class e{constructor(e=new Q,t=new Q,n=new Q){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),_m.subVectors(e,t),r.cross(_m);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){_m.subVectors(r,t),vm.subVectors(n,t),ym.subVectors(e,t);let a=_m.dot(_m),o=_m.dot(vm),s=_m.dot(ym),c=vm.dot(vm),l=vm.dot(ym),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,bm)!==null&&bm.x>=0&&bm.y>=0&&bm.x+bm.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,bm)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,bm.x),s.addScaledVector(a,bm.y),s.addScaledVector(o,bm.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Dm.setScalar(0),Om.setScalar(0),km.setScalar(0),Dm.fromBufferAttribute(e,t),Om.fromBufferAttribute(e,n),km.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Dm,i.x),a.addScaledVector(Om,i.y),a.addScaledVector(km,i.z),a}static isFrontFacing(e,t,n,r){return _m.subVectors(n,t),vm.subVectors(e,t),_m.cross(vm).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return _m.subVectors(this.c,this.b),vm.subVectors(this.a,this.b),_m.cross(vm).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;xm.subVectors(r,n),Sm.subVectors(i,n),wm.subVectors(e,n);let s=xm.dot(wm),c=Sm.dot(wm);if(s<=0&&c<=0)return t.copy(n);Tm.subVectors(e,r);let l=xm.dot(Tm),u=Sm.dot(Tm);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(xm,a);Em.subVectors(e,i);let f=xm.dot(Em),p=Sm.dot(Em);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Sm,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Cm.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Cm,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(xm,a).addScaledVector(Sm,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},jm=class{constructor(e=new Q(1/0,1/0,1/0),t=new Q(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Nm.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Nm.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Nm.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,Nm):Nm.fromBufferAttribute(r,t),Nm.applyMatrix4(e.matrixWorld),this.expandByPoint(Nm);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),Pm.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),Pm.copy(e.boundingBox)),Pm.applyMatrix4(e.matrixWorld),this.union(Pm)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Nm),Nm.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Vm),Hm.subVectors(this.max,Vm),Fm.subVectors(e.a,Vm),Im.subVectors(e.b,Vm),Lm.subVectors(e.c,Vm),Rm.subVectors(Im,Fm),zm.subVectors(Lm,Im),Bm.subVectors(Fm,Lm);let t=[0,-Rm.z,Rm.y,0,-zm.z,zm.y,0,-Bm.z,Bm.y,Rm.z,0,-Rm.x,zm.z,0,-zm.x,Bm.z,0,-Bm.x,-Rm.y,Rm.x,0,-zm.y,zm.x,0,-Bm.y,Bm.x,0];return!Gm(t,Fm,Im,Lm,Hm)||(t=[1,0,0,0,1,0,0,0,1],!Gm(t,Fm,Im,Lm,Hm))?!1:(Um.crossVectors(Rm,zm),t=[Um.x,Um.y,Um.z],Gm(t,Fm,Im,Lm,Hm))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Nm).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Nm).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Mm[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Mm[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Mm[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Mm[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Mm[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Mm[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Mm[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Mm[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Mm),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Mm=[new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q],Nm=new Q,Pm=new jm,Fm=new Q,Im=new Q,Lm=new Q,Rm=new Q,zm=new Q,Bm=new Q,Vm=new Q,Hm=new Q,Um=new Q,Wm=new Q;function Gm(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Wm.fromArray(e,a);let o=i.x*Math.abs(Wm.x)+i.y*Math.abs(Wm.y)+i.z*Math.abs(Wm.z),s=t.dot(Wm),c=n.dot(Wm),l=r.dot(Wm);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Km=new Q,qm=new cp,Jm=0,Ym=class extends Qf{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Jm++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Bf,this.updateRanges=[],this.gpuType=Dd,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)qm.fromBufferAttribute(this,t),qm.applyMatrix3(e),this.setXY(t,qm.x,qm.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Km.fromBufferAttribute(this,t),Km.applyMatrix3(e),this.setXYZ(t,Km.x,Km.y,Km.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Km.fromBufferAttribute(this,t),Km.applyMatrix4(e),this.setXYZ(t,Km.x,Km.y,Km.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Km.fromBufferAttribute(this,t),Km.applyNormalMatrix(e),this.setXYZ(t,Km.x,Km.y,Km.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Km.fromBufferAttribute(this,t),Km.transformDirection(e),this.setXYZ(t,Km.x,Km.y,Km.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=op(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=sp(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=op(t,this.array)),t}setX(e,t){return this.normalized&&(t=sp(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=op(t,this.array)),t}setY(e,t){return this.normalized&&(t=sp(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=op(t,this.array)),t}setZ(e,t){return this.normalized&&(t=sp(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=op(t,this.array)),t}setW(e,t){return this.normalized&&(t=sp(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=sp(t,this.array),n=sp(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=sp(t,this.array),n=sp(n,this.array),r=sp(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=sp(t,this.array),n=sp(n,this.array),r=sp(r,this.array),i=sp(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:`dispose`})}},Xm=class extends Ym{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Zm=class extends Ym{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Qm=class extends Ym{constructor(e,t,n){super(new Float32Array(e),t,n)}},$m=new jm,eh=new Q,th=new Q,nh=class{constructor(e=new Q,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?$m.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;eh.subVectors(e,this.center);let t=eh.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(eh,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(th.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(eh.copy(e.center).add(th)),this.expandByPoint(eh.copy(e.center).sub(th))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},rh=0,ih=new Np,ah=new om,oh=new Q,sh=new jm,ch=new jm,lh=new Q,uh=class e extends Qf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:rh++}),this.uuid=np(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(Hf(e)?Zm:Xm)(e,1):e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new fp().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return ih.makeRotationFromQuaternion(e),this.applyMatrix4(ih),this}rotateX(e){return ih.makeRotationX(e),this.applyMatrix4(ih),this}rotateY(e){return ih.makeRotationY(e),this.applyMatrix4(ih),this}rotateZ(e){return ih.makeRotationZ(e),this.applyMatrix4(ih),this}translate(e,t,n){return ih.makeTranslation(e,t,n),this.applyMatrix4(ih),this}scale(e,t,n){return ih.makeScale(e,t,n),this.applyMatrix4(ih),this}lookAt(e){return ah.lookAt(e),ah.updateMatrix(),this.applyMatrix4(ah.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(oh).negate(),this.translate(oh.x,oh.y,oh.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Qm(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&X(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new jm);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Z(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new Q(-1/0,-1/0,-1/0),new Q(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];sh.setFromBufferAttribute(n),this.morphTargetsRelative?(lh.addVectors(this.boundingBox.min,sh.min),this.boundingBox.expandByPoint(lh),lh.addVectors(this.boundingBox.max,sh.max),this.boundingBox.expandByPoint(lh)):(this.boundingBox.expandByPoint(sh.min),this.boundingBox.expandByPoint(sh.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Z(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nh);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Z(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new Q,1/0);return}if(e){let n=this.boundingSphere.center;if(sh.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];ch.setFromBufferAttribute(n),this.morphTargetsRelative?(lh.addVectors(sh.min,ch.min),sh.expandByPoint(lh),lh.addVectors(sh.max,ch.max),sh.expandByPoint(lh)):(sh.expandByPoint(ch.min),sh.expandByPoint(ch.max))}sh.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)lh.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(lh));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)lh.fromBufferAttribute(a,t),o&&(oh.fromBufferAttribute(e,t),lh.add(oh)),r=Math.max(r,n.distanceToSquared(lh))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Z(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Z(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv,a=this.getAttribute(`tangent`);(a===void 0||a.count!==n.count)&&(a=new Ym(new Float32Array(4*n.count),4),this.setAttribute(`tangent`,a));let o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new Q,s[e]=new Q;let c=new Q,l=new Q,u=new Q,d=new cp,f=new cp,p=new cp,m=new Q,h=new Q;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new Q,y=new Q,b=new Q,x=new Q;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0||n.count!==t.count)n=new Ym(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new Q,i=new Q,a=new Q,o=new Q,s=new Q,c=new Q,l=new Q,u=new Q;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)lh.fromBufferAttribute(e,t),lh.normalize(),e.setXYZ(t,lh.x,lh.y,lh.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Ym(a,r,i)}if(this.index===null)return X(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?`BufferGeometry`:this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:`dispose`})}},dh=new Q,fh=new Q,ph=new fp,mh=class{constructor(e=new Q(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=dh.subVectors(n,t).cross(fh.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(dh),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||ph.getNormalMatrix(e),r=this.coplanarPoint(dh).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},hh=0,gh=class extends Qf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:hh++}),this.uuid=np(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new mm(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=zf,this.stencilZFail=zf,this.stencilZPass=zf,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){X(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){X(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(e=>e.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new mm().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(e=>new mh().fromJSON(e))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0:e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new cp().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new cp().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},_h=new Q,vh=new Q,yh=new Q,bh=new Q,xh=class{constructor(e=new Q,t=new Q(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_h)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=_h.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_h.copy(this.origin).addScaledVector(this.direction,t),_h.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){vh.copy(e).add(t).multiplyScalar(.5),yh.copy(t).sub(e).normalize(),bh.copy(this.origin).sub(vh);let i=e.distanceTo(t)*.5,a=-this.direction.dot(yh),o=bh.dot(this.direction),s=-bh.dot(yh),c=bh.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(vh).addScaledVector(yh,d),f}intersectSphere(e,t){if(e.radius<0)return null;_h.subVectors(e.center,this.origin);let n=_h.dot(this.direction),r=_h.dot(_h)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,_h)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,o=this.direction,s=o.x,c=o.y,l=o.z,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,p=t.x-a.x,m=t.y-a.y,h=t.z-a.z,g=n.x-a.x,_=n.y-a.y,v=n.z-a.z,y=Math.abs(s),b=Math.abs(c),x=Math.abs(l),S,C,w,T,E,D,O,k,A,j,ee,M;if(y>=b&&y>=x?(w=s,D=u,A=p,M=g,s>=0?(S=c,C=l,T=d,E=f,O=m,k=h,j=_,ee=v):(S=l,C=c,T=f,E=d,O=h,k=m,j=v,ee=_)):b>=x?(w=c,D=d,A=m,M=_,c>=0?(S=l,C=s,T=f,E=u,O=h,k=p,j=v,ee=g):(S=s,C=l,T=u,E=f,O=p,k=h,j=g,ee=v)):(w=l,D=f,A=h,M=v,l>=0?(S=s,C=c,T=u,E=d,O=p,k=m,j=g,ee=_):(S=c,C=s,T=d,E=u,O=m,k=p,j=_,ee=g)),w===0)return null;let N=S/w,P=C/w,F=1/w,I=T-N*D,te=E-P*D,ne=O-N*A,L=k-P*A,re=j-N*M,ie=ee-P*M,ae=re*L-ie*ne,oe=I*ie-te*re,se=ne*te-L*I;if(r){if(ae<0||oe<0||se<0)return null}else if((ae<0||oe<0||se<0)&&(ae>0||oe>0||se>0))return null;let ce=ae+oe+se;if(ce===0)return null;let le=F*(ae*D+oe*A+se*M);return(ce>0?le<0:le>0)?null:this.at(le/ce,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Sh=class extends gh{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new mm(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Up,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ch=new Np,wh=new xh,Th=new nh,Eh=new Q,Dh=new Q,Oh=new Q,kh=new Q,Ah=new Q,jh=new Q,Mh=new Q,Nh=new Q,Ph=class extends om{constructor(e=new uh,t=new Sh){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){jh.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Ah.fromBufferAttribute(s,e),a?jh.addScaledVector(Ah,r):jh.addScaledVector(Ah.sub(t),r))}t.add(jh)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Th.copy(n.boundingSphere),Th.applyMatrix4(i),wh.copy(e.ray).recast(e.near),!(Th.containsPoint(wh.origin)===!1&&(wh.intersectSphere(Th,Eh)===null||wh.origin.distanceToSquared(Eh)>(e.far-e.near)**2))&&(Ch.copy(i).invert(),wh.copy(e.ray).applyMatrix4(Ch),(n.boundingBox===null||wh.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,wh)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Ih(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Ih(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}}else if(s!==void 0){if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Ih(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Ih(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}}};function Fh(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Nh.copy(s),Nh.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Nh);return l<n.near||l>n.far?null:{distance:l,point:Nh.clone(),object:e}}function Ih(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Dh),e.getVertexPosition(c,Oh),e.getVertexPosition(l,kh);let u=Fh(e,t,n,r,Dh,Oh,kh,Mh);if(u){let e=new Q;Am.getBarycoord(Mh,Dh,Oh,kh,e),i&&(u.uv=Am.getInterpolatedAttribute(i,s,c,l,e,new cp)),a&&(u.uv1=Am.getInterpolatedAttribute(a,s,c,l,e,new cp)),o&&(u.normal=Am.getInterpolatedAttribute(o,s,c,l,e,new Q),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new Q,materialIndex:0};Am.getNormal(Dh,Oh,kh,t.normal),u.face=t,u.barycoord=e}return u}var Lh=class extends Dp{constructor(e=null,t=1,n=1,r,i,a,o,s,c=hd,l=hd,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Rh=new nh,zh=new cp(.5,.5),Bh=new Q,Vh=class{constructor(e=new mh,t=new mh,n=new mh,r=new mh,i=new mh,a=new mh){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Vf,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Rh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Rh.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rh)}intersectsSprite(e){return Rh.center.set(0,0,0),Rh.radius=.7071067811865476+zh.distanceTo(e.center),Rh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rh)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Bh.x=r.normal.x>0?e.max.x:e.min.x,Bh.y=r.normal.y>0?e.max.y:e.min.y,Bh.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Bh)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Hh=class extends gh{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new mm(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Uh=new Np,Wh=new xh,Gh=new nh,Kh=new Q,qh=class extends om{constructor(e=new uh,t=new Hh){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Gh.copy(n.boundingSphere),Gh.applyMatrix4(r),Gh.radius+=i,e.ray.intersectsSphere(Gh)===!1)return;Uh.copy(r).invert(),Wh.copy(e.ray).applyMatrix4(Uh);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Kh.fromBufferAttribute(l,n),Jh(Kh,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Kh.fromBufferAttribute(l,a),Jh(Kh,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Jh(e,t,n,r,i,a,o){let s=Wh.distanceSqToPoint(e);if(s<n){let n=new Q;Wh.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Yh=class extends Dp{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Xh=class extends Dp{constructor(e,t,n=Ed,r,i,a,o=hd,s=hd,c,l=Ld,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Cp(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Zh=class extends Xh{constructor(e,t=Ed,n=301,r,i,a=hd,o=hd,s,c=Ld){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Qh=class extends Dp{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},$h=class e extends uh{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Qm(c,3)),this.setAttribute(`normal`,new Qm(l,3)),this.setAttribute(`uv`,new Qm(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new Q;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},eg=class e extends uh{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new Qm(p,3)),this.setAttribute(`normal`,new Qm(m,3)),this.setAttribute(`uv`,new Qm(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}};function tg(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(rg(i))i.isRenderTargetTexture?(X(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i)){if(rg(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice()}else t[n][r]=i}}return t}function ng(e){let t={};for(let n=0;n<e.length;n++){let r=tg(e[n]);for(let e in r)t[e]=r[e]}return t}function rg(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function ig(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function ag(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:_p.workingColorSpace}var og={clone:tg,merge:ng},sg=`void main() {
|
|
68
68
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|