1import{j as s}from"./vendor-chartjs-Y7GDAOTp.js";import{a as U,u as Ft}from"./vendor-react-cI7ISg1T.js";import{C as z,u as Dt}from"./index.esm-ULmZNajP.js";import{y as Mt,C as Lt,j as k,A as fe,u as bt,t as _t}from"./index-DBTS4J2E.js";import{s as ye}from"./scriptWriterService-C1wK_dEg.js";import{g as Ze}from"./utils-CFiHALYK.js";import{S as pe}from"./SelectField-D4k6Xldg.js";import{S as Vt}from"./search-3XDKq-6e.js";import{F as Ht}from"./funnel-B1eBX7lk.js";import{L as Jt}from"./loader-circle-CNb8MIbV.js";import{U as qt}from"./upload-DnuPZzec.js";import{g as Yt,i as Wt}from"./ScriptUpload-D3n5heY0.js";import{A as zt}from"./arrow-left-CzaM-uOP.js";import{F as Gt}from"./file-text-c9_x_SA4.js";import{F as Zt}from"./film-qPYvpEDh.js";import{U as Xt}from"./users-COkeS64U.js";import{U as Kt}from"./user-eEfk6gHb.js";import{P as Qt}from"./FallBackImage-pqlgbM6M.js";import{C as er}from"./clock-DK2bxqEm.js";import{C as tr}from"./calendar-days-0b1SZEt1.js";import{P as rr}from"./plus-DnDw_Pk6.js";import"./vendor-pdf-BLIxzv9T.js";import"./vendor-recharts-Xf6PYoWo.js";import"./index-ISs4t0ha.js";import"./scriptAnalysisService-CYirdImT.js";import"./BuyCreditModal-DE8-_NA6.js";import"./DefaultImage-Cbx6poGm.js";import"./MoviePosterPlaceholder-C7zoVRwd.js";/** 2 * @license lucide-react v0.501.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const sr=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],nr=Mt("sliders-horizontal",sr),ir=(()=>{const t=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;return e=>t.call(e)})();function yt(t){return ir(t)==="Uint8Array"}function or(t){return typeof t=="object"&&t!=null&&Symbol.toStringTag in t&&(t[Symbol.toStringTag]==="ArrayBuffer"||t[Symbol.toStringTag]==="SharedArrayBuffer")}function ar(t){return t instanceof RegExp||Object.prototype.toString.call(t)==="[object RegExp]"}function wt(t){return typeof t=="object"&&t!=null&&Symbol.toStringTag in t&&t[Symbol.toStringTag]==="Map"}function lr(t){return t instanceof Date||Object.prototype.toString.call(t)==="[object Date]"}function Q(t,e){return JSON.stringify(t,(r,n)=>typeof n=="bigint"?{$numberLong:`${n}`}:wt(n)?Object.fromEntries(n):n)}function cr(t){if(t!=null&&typeof t=="object"&&"stylize"in t&&typeof t.stylize=="function")return t.stylize}const Xe=6,Nt=Symbol.for("@@mdb.bson.version"),Ke=2147483647,Qe=-2147483648,jt=Math.pow(2,63)-1,St=-Math.pow(2,63),dr=Math.pow(2,53),ur=-Math.pow(2,53),Et=4;class g extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(e,r){super(e,r)}static isBSONError(e){return e!=null&&typeof e=="object"&&"bsonError"in e&&e.bsonError===!0&&"name"in e&&"message"in e&&"stack"in e}}class fr extends g{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${Xe}.x.x`)}}class st extends g{get name(){return"BSONRuntimeError"}constructor(e){super(e)}}class me extends g{get name(){return"BSONOffsetError"}constructor(e,r,n){super(`${e}. offset: ${r}`,n),this.offset=r}}let nt,it;function vt(t,e,r,n){if(n){nt??(nt=new TextDecoder("utf8",{fatal:!0}));try{return nt.decode(t.subarray(e,r))}catch(i){throw new g("Invalid UTF-8 string in BSON document",{cause:i})}}return it??(it=new TextDecoder("utf8",{fatal:!1})),it.decode(t.subarray(e,r))}function It(t,e,r){if(t.length===0)return"";const n=r-e;if(n===0)return"";if(n>20)return null;if(n===1&&t[e]<128)return String.fromCharCode(t[e]);if(n===2&&t[e]<128&&t[e+1]<128)return String.fromCharCode(t[e])+String.fromCharCode(t[e+1]);if(n===3&&t[e]<128&&t[e+1]<128&&t[e+2]<128)return String.fromCharCode(t[e])+String.fromCharCode(t[e+1])+String.fromCharCode(t[e+2]);const i=[];for(let a=e;a<r;a++){const f=t[a];if(f>127)return null;i.push(f)}return String.fromCharCode(...i)}function mr(t,e,r){if(e.length===0)return 0;if(e.length>25||t.length-r<e.length)return null;for(let n=0,i=r;n<e.length;n++,i++){const a=e.charCodeAt(n);if(a>127)return null;t[i]=a}return e.length}function hr(t){return oe.fromNumberArray(Array.from({length:t},()=>Math.floor(Math.random()*256)))}const gr=hr,oe={toLocalBufferType(t){if(Buffer.isBuffer(t))return t;if(ArrayBuffer.isView(t))return Buffer.from(t.buffer,t.byteOffset,t.byteLength);const e=(t==null?void 0:t[Symbol.toStringTag])??Object.prototype.toString.call(t);if(e==="ArrayBuffer"||e==="SharedArrayBuffer"||e==="[object ArrayBuffer]"||e==="[object SharedArrayBuffer]")return Buffer.from(t);throw new g("Cannot create Buffer from the passed potentialBuffer.")},allocate(t){return Buffer.alloc(t)},allocateUnsafe(t){return Buffer.allocUnsafe(t)},equals(t,e){return oe.toLocalBufferType(t).equals(e)},fromNumberArray(t){return Buffer.from(t)},fromBase64(t){return Buffer.from(t,"base64")},toBase64(t){return oe.toLocalBufferType(t).toString("base64")},fromISO88591(t){return Buffer.from(t,"binary")},toISO88591(t){return oe.toLocalBufferType(t).toString("binary")},fromHex(t){return Buffer.from(t,"hex")},toHex(t){return oe.toLocalBufferType(t).toString("hex")},toUTF8(t,e,r,n){const i=r-e<=20?It(t,e,r):null;if(i!=null)return i;const a=oe.toLocalBufferType(t).toString("utf8",e,r);
6if(n){for(let f=0;f<a.length;f++)if(a.charCodeAt(f)===65533){vt(t,e,r,!0);break}}return a},utf8ByteLength(t){return Buffer.byteLength(t,"utf8")},encodeUTF8Into(t,e,r){const n=mr(t,e,r);return n??oe.toLocalBufferType(t).write(e,r,void 0,"utf8")},randomBytes:gr,swap32(t){return oe.toLocalBufferType(t).swap32()}};function xr(){const{navigator:t}=globalThis;return typeof t=="object"&&t.product==="ReactNative"}function pr(t){if(t<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${t}`);return Ce.fromNumberArray(Array.from({length:t},()=>Math.floor(Math.random()*256)))}const br=(()=>{var e;const{crypto:t}=globalThis;if(t!=null&&typeof t.getRandomValues=="function")return r=>t.getRandomValues(Ce.allocate(r));if(xr()){const{console:r}=globalThis;(e=r==null?void 0:r.warn)==null||e.call(r,"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return pr})(),ot=/(\d|[a-f])/i,Ce={toLocalBufferType(t){const e=(t==null?void 0:t[Symbol.toStringTag])??Object.prototype.toString.call(t);if(e==="Uint8Array")return t;if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));if(e==="ArrayBuffer"||e==="SharedArrayBuffer"||e==="[object ArrayBuffer]"||e==="[object SharedArrayBuffer]")return new Uint8Array(t);throw new g("Cannot make a Uint8Array from passed potentialBuffer.")},allocate(t){if(typeof t!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(t)}`);return new Uint8Array(t)},allocateUnsafe(t){return Ce.allocate(t)},equals(t,e){if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},fromNumberArray(t){return Uint8Array.from(t)},fromBase64(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))},toBase64(t){return btoa(Ce.toISO88591(t))},fromISO88591(t){return Uint8Array.from(t,e=>e.charCodeAt(0)&255)},toISO88591(t){return Array.from(Uint16Array.from(t),e=>String.fromCharCode(e)).join("")},fromHex(t){const e=t.length%2===0?t:t.slice(0,t.length-1),r=[];for(let n=0;n<e.length;n+=2){const i=e[n],a=e[n+1];if(!ot.test(i)||!ot.test(a))break;const f=Number.parseInt(`${i}${a}`,16);r.push(f)}return Uint8Array.from(r)},toHex(t){return Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")},toUTF8(t,e,r,n){const i=r-e<=20?It(t,e,r):null;return i??vt(t,e,r,n)},utf8ByteLength(t){return new TextEncoder().encode(t).byteLength},encodeUTF8Into(t,e,r){const n=new TextEncoder().encode(e);return t.set(n,r),n.byteLength},randomBytes:br,swap32(t){if(t.length%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t.length;e+=4){const r=t[e],n=t[e+1],i=t[e+2],a=t[e+3];t[e]=a,t[e+1]=i,t[e+2]=n,t[e+3]=r}return t}};var pt;const yr=typeof Buffer=="function"&&((pt=Buffer.prototype)==null?void 0:pt._isBuffer)!==!0,N=yr?oe:Ce;class te{get[Nt](){return Xe}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return this.inspect(e,r,n)}}const we=new Float64Array(1),C=new Uint8Array(we.buffer,0,8);we[0]=-1;const qe=C[7]===0,xe={isBigEndian:qe,getNonnegativeInt32LE(t,e){if(t[e+3]>127)throw new RangeError(`Size cannot be negative at offset: ${e}`);return t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24},getInt32LE(t,e){return t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24},getUint32LE(t,e){return t[e]+t[e+1]*256+t[e+2]*65536+t[e+3]*16777216},getUint32BE(t,e){return t[e+3]+t[e+2]*256+t[e+1]*65536+t[e]*16777216},getBigInt64LE(t,e){const r=BigInt(t[e+4]+t[e+5]*256+t[e+6]*65536+(t[e+7]<<24)),n=BigInt(t[e]+t[e+1]*256+t[e+2]*65536+t[e+3]*16777216);return(r<<BigInt(32))+n},getFloat64LE:qe?(t,e)=>(C[7]=t[e],C[6]=t[e+1],C[5]=t[e+2],C[4]=t[e+3],C[3]=t[e+4],C[2]=t[e+5],C[1]=t[e+6],C[0]=t[e+7],we[0]):(t,e)=>(C[0]=t[e],C[1]=t[e+1],C[2]=t[e+2],C[3]=t[e+3],C[4]=t[e+4],C[5]=t[e+5],C[6]=t[e+6],C[7]=t[e+7],we[0]),setInt32BE(t,e,r){return t[e+3]=r,r>>>=8,t[e+2]=r,r>>>=8,t[e+1]=r,r>>>=8,t[e]=r,4},setInt32LE(t,e,r){return t[e]=r,r>>>=8,t[e+1]=r,r>>>=8,t[e+2]=r,r>>>=8,t[e+3]=r,4},setBigInt64LE(t,e,r){const n=BigInt(4294967295);let i=Number(r&n);t[e]=i,i>>=8,t[e+1]=i,i>>=8,t[e+2]=i,i>>=8,t[e+3]=i;let a=Number(r>>BigInt(32)&n);return t[e+4]=a,a>>=8,t[e+5]=a,a>>=8,t[e+6]=a,a>>=8,t[e+7]=a,8},setFloat64LE:qe?(t,e,r)=>(we[0]=r,t[e]=C[7],t[e+1]=C[6],t[e+2]=C[5],t[e+3]=C[4],t[e+4]=C[3],t[e+5]=C[2],t[e+6]=C[1],t[e+7]=C[0],8):(t,e,r)=>(we[0]=r,t[e]=C[0],t[e+1]=C[1],t[e+2]=C[2],t[e+3]=C[3],t[e+4]=C[4],t[e+5]=C[5],t[e+6]=C[6],t[e+7]=C[7],8)};class S extends te{get _bsontype(){return"Binary"}constructor(e,r){if(super(),e!=null&&typeof e=="string"&&!ArrayBuffer.isView(e)&&!or(e)&&!Array.isArray(e))throw new g("Binary can only be constructed from Uint8Array or number[]");this.sub_type=r??S.BSON_BINARY_SUBTYPE_DEFAULT,e==null?(this.buffer=N.allocate(S.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(e)?N.fromNumberArray(e):N.toLocalBufferType(e),this.position=this.buffer.byteLength)}put(e){if(typeof e=="string"&&e.length!==1)throw new g("only accepts single character String");if(typeof e!="number"&&e.length!==1)throw new g("only accepts single character Uint8Array or Array");let r;if(typeof e=="string"?r=e.charCodeAt(0):typeof e=="number"?r=e:r=e[0],r<0||r>255)throw new g("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=r;else{const n=N.allocate(S.BUFFER_SIZE+this.buffer.length);n.set(this.buffer,0),this.buffer=n,this.buffer[this.position++]=r}}write(e,r){if(r=typeof r=="number"?r:this.position,this.buffer.byteLength<r+e.length){const n=N.allocate(this.buffer.byteLength+e.length);n.set(this.buffer,0),this.buffer=n}if(ArrayBuffer.isView(e))this.buffer.set(N.toLocalBufferType(e),r),this.position=r+e.byteLength>this.position?r+e.length:this.position;else if(typeof e=="string")throw new g("input cannot be string")}read(e,r){r=r&&r>0?r:this.position;const n=e+r;return this.buffer.subarray(e,n>this.position?this.position:n)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return N.toBase64(this.buffer.subarray(0,this.position))}toString(e){return e==="hex"?N.toHex(this.buffer.subarray(0,this.position)):e==="base64"?N.toBase64(this.buffer.subarray(0,this.position)):e==="utf8"||e==="utf-8"?N.toUTF8(this.buffer,0,this.position,!1):N.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(e){e=e||{},this.sub_type===S.SUBTYPE_VECTOR&&ue(this);const r=N.toBase64(this.buffer),n=Number(this.sub_type).toString(16);return e.legacy?{$binary:r,$type:n.length===1?"0"+n:n}:{$binary:{base64:r,subType:n.length===1?"0"+n:n}}}
6toUUID(){if(this.sub_type===S.SUBTYPE_UUID)return new Z(this.buffer.subarray(0,this.position));throw new g(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${S.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(e,r){return new S(N.fromHex(e),r)}static createFromBase64(e,r){return new S(N.fromBase64(e),r)}static fromExtendedJSON(e,r){r=r||{};let n,i;if("$binary"in e?r.legacy&&typeof e.$binary=="string"&&"$type"in e?(i=e.$type?parseInt(e.$type,16):0,n=N.fromBase64(e.$binary)):typeof e.$binary!="string"&&(i=e.$binary.subType?parseInt(e.$binary.subType,16):0,n=N.fromBase64(e.$binary.base64)):"$uuid"in e&&(i=4,n=Z.bytesFromString(e.$uuid)),!n)throw new g(`Unexpected Binary Extended JSON format ${JSON.stringify(e)}`);return i===Et?new Z(n):new S(n,i)}inspect(e,r,n){n??(n=Q);const i=N.toBase64(this.buffer.subarray(0,this.position)),a=n(i,r),f=n(this.sub_type,r);return`Binary.createFromBase64(${a}, ${f})`}toInt8Array(){if(this.sub_type!==S.SUBTYPE_VECTOR)throw new g("Binary sub_type is not Vector");if(this.buffer[0]!==S.VECTOR_TYPE.Int8)throw new g("Binary datatype field is not Int8");return ue(this),new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toFloat32Array(){if(this.sub_type!==S.SUBTYPE_VECTOR)throw new g("Binary sub_type is not Vector");if(this.buffer[0]!==S.VECTOR_TYPE.Float32)throw new g("Binary datatype field is not Float32");ue(this);const e=new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position));return xe.isBigEndian&&N.swap32(e),new Float32Array(e.buffer)}toPackedBits(){if(this.sub_type!==S.SUBTYPE_VECTOR)throw new g("Binary sub_type is not Vector");if(this.buffer[0]!==S.VECTOR_TYPE.PackedBit)throw new g("Binary datatype field is not packed bit");return ue(this),new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toBits(){if(this.sub_type!==S.SUBTYPE_VECTOR)throw new g("Binary sub_type is not Vector");if(this.buffer[0]!==S.VECTOR_TYPE.PackedBit)throw new g("Binary datatype field is not packed bit");ue(this);const r=(this.length()-2)*8-this.buffer[1],n=new Int8Array(r);for(let i=0;i<n.length;i++){const a=i/8|0,f=this.buffer[a+2],l=7-i%8,m=f>>l&1;n[i]=m}return n}static fromInt8Array(e){const r=N.allocate(e.byteLength+2);r[0]=S.VECTOR_TYPE.Int8,r[1]=0;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);r.set(n,2);const i=new this(r,this.SUBTYPE_VECTOR);return ue(i),i}static fromFloat32Array(e){const r=N.allocate(e.byteLength+2);r[0]=S.VECTOR_TYPE.Float32,r[1]=0;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);r.set(n,2),xe.isBigEndian&&N.swap32(new Uint8Array(r.buffer,2));const i=new this(r,this.SUBTYPE_VECTOR);return ue(i),i}static fromPackedBits(e,r=0){const n=N.allocate(e.byteLength+2);n[0]=S.VECTOR_TYPE.PackedBit,n[1]=r,n.set(e,2);const i=new this(n,this.SUBTYPE_VECTOR);return ue(i),i}static fromBits(e){const r=e.length+7>>>3,n=new Uint8Array(r+2);n[0]=S.VECTOR_TYPE.PackedBit;const i=e.length%8;n[1]=i===0?0:8-i;for(let a=0;a<e.length;a++){const f=a>>>3,l=e[a];if(l!==0&&l!==1)throw new g(`Invalid bit value at ${a}: must be 0 or 1, found ${e[a]}`);if(l===0)continue;const m=7-a%8;n[f+2]|=l<<m}return new this(n,S.SUBTYPE_VECTOR)}}S.BSON_BINARY_SUBTYPE_DEFAULT=0;S.BUFFER_SIZE=256;S.SUBTYPE_DEFAULT=0;S.SUBTYPE_FUNCTION=1;S.SUBTYPE_BYTE_ARRAY=2;S.SUBTYPE_UUID_OLD=3;S.SUBTYPE_UUID=4;S.SUBTYPE_MD5=5;S.SUBTYPE_ENCRYPTED=6;S.SUBTYPE_COLUMN=7;S.SUBTYPE_SENSITIVE=8;S.SUBTYPE_VECTOR=9;S.SUBTYPE_USER_DEFINED=128;S.VECTOR_TYPE=Object.freeze({Int8:3,Float32:39,PackedBit:16});function ue(t){if(t.sub_type!==S.SUBTYPE_VECTOR)return;const e=t.position,r=t.buffer[0],n=t.buffer[1];if((r===S.VECTOR_TYPE.Float32||r===S.VECTOR_TYPE.Int8)&&n!==0)throw new g("Invalid Vector: padding must be zero for int8 and float32 vectors");if(r===S.VECTOR_TYPE.Float32&&e!==0&&e-2!==0&&(e-2)%4!==0)throw new g("Invalid Vector: Float32 vector must contain a multiple of 4 bytes");if(r===S.VECTOR_TYPE.PackedBit&&n!==0&&e===2)throw new g("Invalid Vector: padding must be zero for packed bit vectors that are empty");if(r===S.VECTOR_TYPE.PackedBit&&n>7)throw new g(`Invalid Vector: padding must be a value between 0 and 7. found: ${n}`)}const Ye=16,wr=/^[0-9A-F]{32}$/i,Nr=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class Z extends S{constructor(e){let r;if(e==null)r=Z.generate();else if(e instanceof Z)r=N.toLocalBufferType(new Uint8Array(e.buffer));else if(ArrayBuffer.isView(e)&&e.byteLength===Ye)r=N.toLocalBufferType(e);else if(typeof e=="string")r=Z.bytesFromString(e);else throw new g("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(r,Et)}get id(){return this.buffer}set id(e){this.buffer=e}toHexString(e=!0){return e?[N.toHex(this.buffer.subarray(0,4)),N.toHex(this.buffer.subarray(4,6)),N.toHex(this.buffer.subarray(6,8)),N.toHex(this.buffer.subarray(8,10)),N.toHex(this.buffer.subarray(10,16))].join("-"):N.toHex(this.buffer)}toString(e){return e==="hex"?N.toHex(this.id):e==="base64"?N.toBase64(this.id
6):this.toHexString()}toJSON(){return this.toHexString()}equals(e){if(!e)return!1;if(e instanceof Z)return N.equals(e.id,this.id);try{return N.equals(new Z(e).id,this.id)}catch{return!1}}toBinary(){return new S(this.id,S.SUBTYPE_UUID)}static generate(){const e=N.randomBytes(Ye);return e[6]=e[6]&15|64,e[8]=e[8]&63|128,e}static isValid(e){return e?typeof e=="string"?Z.isValidUUIDString(e):yt(e)?e.byteLength===Ye:e._bsontype==="Binary"&&e.sub_type===this.SUBTYPE_UUID&&e.buffer.byteLength===16:!1}static createFromHexString(e){const r=Z.bytesFromString(e);return new Z(r)}static createFromBase64(e){return new Z(N.fromBase64(e))}static bytesFromString(e){if(!Z.isValidUUIDString(e))throw new g("UUID string representation must be 32 hex digits or canonical hyphenated representation");return N.fromHex(e.replace(/-/g,""))}static isValidUUIDString(e){return wr.test(e)||Nr.test(e)}inspect(e,r,n){return n??(n=Q),`new UUID(${n(this.toHexString(),r)})`}}class Ue extends te{get _bsontype(){return"Code"}constructor(e,r){super(),this.code=e.toString(),this.scope=r??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(e){return new Ue(e.$code,e.$scope)}inspect(e,r,n){n??(n=Q);let i=n(this.code,r);const a=i.includes(` 7`);this.scope!=null&&(i+=`,${a?` 8`:" "}${n(this.scope,r)}`);const f=a&&this.scope===null;return`new Code(${a?` 9`:""}${i}${f?` 10`:""})`}}function jr(t){return t!=null&&typeof t=="object"&&"$id"in t&&t.$id!=null&&"$ref"in t&&typeof t.$ref=="string"&&(!("$db"in t)||"$db"in t&&typeof t.$db=="string")}class je extends te{get _bsontype(){return"DBRef"}constructor(e,r,n,i){super();const a=e.split(".");a.length===2&&(n=a.shift(),e=a.shift()),this.collection=e,this.oid=r,this.db=n,this.fields=i||{}}get namespace(){return this.collection}set namespace(e){this.collection=e}toJSON(){const e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(e.$db=this.db),e}toExtendedJSON(e){e=e||{};let r={$ref:this.collection,$id:this.oid};return e.legacy||(this.db&&(r.$db=this.db),r=Object.assign(r,this.fields)),r}static fromExtendedJSON(e){const r=Object.assign({},e);return delete r.$ref,delete r.$id,delete r.$db,new je(e.$ref,e.$id,e.$db,r)}inspect(e,r,n){n??(n=Q);const i=[n(this.namespace,r),n(this.oid,r),...this.db?[n(this.db,r)]:[],...Object.keys(this.fields).length>0?[n(this.fields,r)]:[]];return i[1]=n===Q?`new ObjectId(${i[1]})`:i[1],`new DBRef(${i.join(", ")})`}}
10function Bt(t){if(t==="")return t;let e=0;const r=t[e]==="-",n=t[e]==="+";(n||r)&&(e+=1);let i=!1;for(;e<t.length&&t[e]==="0";++e)i=!0;return i?`${r?"-":""}${t.length===e?"0":t.slice(e)}`:n?t.slice(1):t}function Sr(t,e){e=e??10;const r="0123456789abcdefghijklmnopqrstuvwxyz".slice(0,e);return new RegExp(`[^-+${r}]`,"i").test(t)?!1:t}let ee;try{ee=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}const at=65536,Er=1<<24,Ne=at*at,Ot=Ne*Ne,vr=Ot/2,lt={},ct={},Ir=20,Br=/^(\+?0|(\+|-)?[1-9][0-9]*)$/;class o extends te{get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(e=0,r,n){super();const i=typeof r=="boolean"?r:!!n,a=typeof r=="number"?r:0,f=typeof e=="string"?o.fromString(e,i):typeof e=="bigint"?o.fromBigInt(e,i):{low:e|0,high:a|0,unsigned:i};this.low=f.low,this.high=f.high,this.unsigned=f.unsigned}static fromBits(e,r,n){return new o(e,r,n)}static fromInt(e,r){let n,i,a;return r?(e>>>=0,(a=0<=e&&e<256)&&(i=ct[e],i)?i:(n=o.fromBits(e,(e|0)<0?-1:0,!0),a&&(ct[e]=n),n)):(e|=0,(a=-128<=e&&e<128)&&(i=lt[e],i)?i:(n=o.fromBits(e,e<0?-1:0,!1),a&&(lt[e]=n),n))}static fromNumber(e,r){if(isNaN(e))return r?o.UZERO:o.ZERO;if(r){if(e<0)return o.UZERO;if(e>=Ot)return o.MAX_UNSIGNED_VALUE}else{if(e<=-9223372036854776e3)return o.MIN_VALUE;if(e+1>=vr)return o.MAX_VALUE}return e<0?o.fromNumber(-e,r).neg():o.fromBits(e%Ne|0,e/Ne|0,r)}static fromBigInt(e,r){const n=BigInt(4294967295),i=BigInt(32);return new o(Number(e&n),Number(e>>i&n),r)}static _fromString(e,r,n){if(e.length===0)throw new g("empty string");if(n<2||36<n)throw new g("radix");let i;if((i=e.indexOf("-"))>0)throw new g("interior hyphen");if(i===0)return o._fromString(e.substring(1),r,n).neg();const a=o.fromNumber(Math.pow(n,8));let f=o.ZERO;for(let l=0;l<e.length;l+=8){const m=Math.min(8,e.length-l),d=parseInt(e.substring(l,l+m),n);if(m<8){const b=o.fromNumber(Math.pow(n,m));f=f.mul(b).add(o.fromNumber(d))}else f=f.mul(a),f=f.add(o.fromNumber(d))}return f.unsigned=r,f}static fromStringStrict(e,r,n){let i=!1;if(typeof r=="number"?(n=r,r=!1):i=!!r,n??(n=10),e.trim()!==e)throw new g(`Input: '${e}' contains leading and/or trailing whitespace`);if(!Sr(e,n))throw new g(`Input: '${e}' contains invalid characters for radix: ${n}`);const a=Bt(e),f=o._fromString(a,i,n);if(f.toString(n).toLowerCase()!==a.toLowerCase())throw new g(`Input: ${e} is not representable as ${f.unsigned?"an unsigned":"a signed"} 64-bit Long ${n!=null?`with radix: ${n}`:""}`);return f}static fromString(e,r,n){let i=!1;return typeof r=="number"?(n=r,r=!1):i=!!r,n??(n=10),e==="NaN"&&n<24||(e==="Infinity"||e==="+Infinity"||e==="-Infinity")&&n<35?o.ZERO:o._fromString(e,i,n)}static fromBytes(e,r,n){return n?o.fromBytesLE(e,r):o.fromBytesBE(e,r)}static fromBytesLE(e,r){return new o(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)}static fromBytesBE(e,r){return new o(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)}static isLong(e){return e!=null&&typeof e=="object"&&"__isLong__"in e&&e.__isLong__===!0}static fromValue(e,r){return typeof e=="number"?o.fromNumber(e,r):typeof e=="string"?o.fromString(e,r):o.fromBits(e.low,e.high,typeof r=="boolean"?r:e.unsigned)}add(e){o.isLong(e)||(e=o.fromValue(e));const r=this.high>>>16,n=this.high&65535,i=this.low>>>16,a=this.low&65535,f=e.high>>>16,l=e.high&65535,m=e.low>>>16,d=e.low&65535;let b=0,h=0,x=0,v=0;return v+=a+d,x+=v>>>16,v&=65535,x+=i+m,h+=x>>>16,x&=65535,h+=n+l,b+=h>>>16,h&=65535,b+=r+f,b&=65535,o.fromBits(x<<16|v,b<<16|h,this.unsigned)}and(e){return o.isLong(e)||(e=o.fromValue(e)),o.fromBits(this.low&e.low,this.high&e.high,this.unsigned)}compare(e){if(o.isLong(e)||(e=o.fromValue(e)),this.eq(e))return 0;const r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1}comp(e){return this.compare(e)}divide(e){if(o.isLong(e)||(e=o.fromValue(e)),e.isZero())throw new g("division by zero");if(ee){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;const a=(this.unsigned?ee.div_u:ee.div_s)(this.low,this.high,e.low,e.high);return o.fromBits(a,ee.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?o.UZERO:o.ZERO;let r,n,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return o.UZERO;if(e.gt(this.shru(1)))return o.UONE;i=o.UZERO}else{if(this.eq(o.MIN_VALUE))return e.eq(o.ONE)||e.eq(o.NEG_ONE)?o.MIN_VALUE:e.eq(o.MIN_VALUE)?o.ONE:(r=this.shr(1).div(e).shl(1),r.eq(o.ZERO)?e.isNegative()?o.ONE:o.NEG_ONE:(n=this.sub(e.mul(r)),i=r.add(n.div(e)),i));if(e.eq(o.MIN_VALUE))return this.unsigned?o.UZERO:o.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=o.ZERO}for(n=this;n.gte(e);){r=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));const a=Math.ceil(Math.log(r)/Math.LN2),f=a<=48?1:Math.pow(2,a-48);let l=o.fromNumber(r),m=l.mul(e);for(;m.isNegative()||m.gt(n);)r-=f,l=o.fromNumber(r,this.unsigned),m=l.mul(e);l.isZero()&&(l=o.ONE),i=i.add(l),n=n.sub(m)}return i}div(e){return this.divide(e)}equals(e){return o.isLong(e)||(e=o.fromValue(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low}eq(e){return this.equals(e)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(o.MIN_VALUE)?64:this.neg().getNumBitsAbs();const e=this.high!==0?this.high:this.low;let r;for(r=31;r>0&&(e&1<<r)===0;r--);return this.high!==0?r+33:r+1}greaterThan(e){return this.comp(e)>0}gt(e){return this.greaterThan(e)}greaterThanOrEqual(e){return this.comp(e)>=0}gte(e){return this.greaterThanOrEqual(e)}ge(e){return this.greaterThanOrEqual(e)}isEven(){return(this.low&1)===0}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return(this.low&1)===1}isPositive(){return this.unsigned||this.high>=0}isZero(){return this.high===0&&this.low===0}lessThan(e){return this.comp(e)<0}
10lt(e){return this.lessThan(e)}lessThanOrEqual(e){return this.comp(e)<=0}lte(e){return this.lessThanOrEqual(e)}modulo(e){if(o.isLong(e)||(e=o.fromValue(e)),ee){const r=(this.unsigned?ee.rem_u:ee.rem_s)(this.low,this.high,e.low,e.high);return o.fromBits(r,ee.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))}mod(e){return this.modulo(e)}rem(e){return this.modulo(e)}multiply(e){if(this.isZero())return o.ZERO;if(o.isLong(e)||(e=o.fromValue(e)),ee){const R=ee.mul(this.low,this.high,e.low,e.high);return o.fromBits(R,ee.get_high(),this.unsigned)}if(e.isZero())return o.ZERO;if(this.eq(o.MIN_VALUE))return e.isOdd()?o.MIN_VALUE:o.ZERO;if(e.eq(o.MIN_VALUE))return this.isOdd()?o.MIN_VALUE:o.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(o.TWO_PWR_24)&&e.lt(o.TWO_PWR_24))return o.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);const r=this.high>>>16,n=this.high&65535,i=this.low>>>16,a=this.low&65535,f=e.high>>>16,l=e.high&65535,m=e.low>>>16,d=e.low&65535;let b=0,h=0,x=0,v=0;return v+=a*d,x+=v>>>16,v&=65535,x+=i*d,h+=x>>>16,x&=65535,x+=a*m,h+=x>>>16,x&=65535,h+=n*d,b+=h>>>16,h&=65535,h+=i*m,b+=h>>>16,h&=65535,h+=a*l,b+=h>>>16,h&=65535,b+=r*d+n*m+i*l+a*f,b&=65535,o.fromBits(x<<16|v,b<<16|h,this.unsigned)}mul(e){return this.multiply(e)}negate(){return!this.unsigned&&this.eq(o.MIN_VALUE)?o.MIN_VALUE:this.not().add(o.ONE)}neg(){return this.negate()}not(){return o.fromBits(~this.low,~this.high,this.unsigned)}notEquals(e){return!this.equals(e)}neq(e){return this.notEquals(e)}ne(e){return this.notEquals(e)}or(e){return o.isLong(e)||(e=o.fromValue(e)),o.fromBits(this.low|e.low,this.high|e.high,this.unsigned)}shiftLeft(e){return o.isLong(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?o.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o.fromBits(0,this.low<<e-32,this.unsigned)}shl(e){return this.shiftLeft(e)}shiftRight(e){return o.isLong(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?o.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)}shr(e){return this.shiftRight(e)}shiftRightUnsigned(e){if(o.isLong(e)&&(e=e.toInt()),e&=63,e===0)return this;{const r=this.high;if(e<32){const n=this.low;return o.fromBits(n>>>e|r<<32-e,r>>>e,this.unsigned)}else return e===32?o.fromBits(r,0,this.unsigned):o.fromBits(r>>>e-32,0,this.unsigned)}}shr_u(e){return this.shiftRightUnsigned(e)}shru(e){return this.shiftRightUnsigned(e)}subtract(e){return o.isLong(e)||(e=o.fromValue(e)),this.add(e.neg())}sub(e){return this.subtract(e)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*Ne+(this.low>>>0):this.high*Ne+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(e){return e?this.toBytesLE():this.toBytesBE()}toBytesLE(){const e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]}toBytesBE(){const e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]}toSigned(){return this.unsigned?o.fromBits(this.low,this.high,!1):this}toString(e){if(e=e||10,e<2||36<e)throw new g("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(o.MIN_VALUE)){const a=o.fromNumber(e),f=this.div(a),l=f.mul(a).sub(this);return f.toString(e)+l.toInt().toString(e)}else return"-"+this.neg().toString(e);const r=o.fromNumber(Math.pow(e,6),this.unsigned);let n=this,i="";for(;;){const a=n.div(r);let l=(n.sub(a.mul(r)).toInt()>>>0).toString(e);if(n=a,n.isZero())return l+i;for(;l.length<6;)l="0"+l;i=""+l+i}}toUnsigned(){return this.unsigned?this:o.fromBits(this.low,this.high,!0)}xor(e){return o.isLong(e)||(e=o.fromValue(e)),o.fromBits(this.low^e.low,this.high^e.high,this.unsigned)}eqz(){return this.isZero()}le(e){return this.lessThanOrEqual(e)}toExtendedJSON(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(e,r){const{useBigInt64:n=!1,relaxed:i=!0}={...r};if(e.$numberLong.length>Ir)throw new g("$numberLong string is too long");if(!Br.test(e.$numberLong))throw new g(`$numberLong string "${e.$numberLong}
10" is in an invalid format`);if(n){const f=BigInt(e.$numberLong);return BigInt.asIntN(64,f)}const a=o.fromString(e.$numberLong);return i?a.toNumber():a}inspect(e,r,n){n??(n=Q);const i=n(this.toString(),r),a=this.unsigned?`, ${n(this.unsigned,r)}`:"";return`new Long(${i}${a})`}}o.TWO_PWR_24=o.fromInt(Er);o.MAX_UNSIGNED_VALUE=o.fromBits(-1,-1,!0);o.ZERO=o.fromInt(0);o.UZERO=o.fromInt(0,!0);o.ONE=o.fromInt(1);o.UONE=o.fromInt(1,!0);o.NEG_ONE=o.fromInt(-1);o.MAX_VALUE=o.fromBits(-1,2147483647,!1);o.MIN_VALUE=o.fromBits(0,-2147483648,!1);const Or=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Tr=/^(\+|-)?(Infinity|inf)$/i,Ar=/^(\+|-)?NaN$/i,be=6111,Ae=-6176,dt=6176,ut=34,We=N.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),ft=N.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),mt=N.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),$r=/^([-+])?(\d+)?$/,Cr=31,ht=16383,Ur=30,Pr=31;function gt(t){return!isNaN(parseInt(t,10))}function kr(t){const e=o.fromNumber(1e9);let r=o.fromNumber(0);if(!t.parts[0]&&!t.parts[1]&&!t.parts[2]&&!t.parts[3])return{quotient:t,rem:r};for(let n=0;n<=3;n++)r=r.shiftLeft(32),r=r.add(new o(t.parts[n],0)),t.parts[n]=r.div(e).low,r=r.modulo(e);return{quotient:t,rem:r}}function Rr(t,e){if(!t&&!e)return{high:o.fromNumber(0),low:o.fromNumber(0)};const r=t.shiftRightUnsigned(32),n=new o(t.getLowBits(),0),i=e.shiftRightUnsigned(32),a=new o(e.getLowBits(),0);let f=r.multiply(i),l=r.multiply(a);const m=n.multiply(i);let d=n.multiply(a);return f=f.add(l.shiftRightUnsigned(32)),l=new o(l.getLowBits(),0).add(m).add(d.shiftRightUnsigned(32)),f=f.add(l.shiftRightUnsigned(32)),d=l.shiftLeft(32).add(new o(d.getLowBits(),0)),{high:f,low:d}}function Fr(t,e){const r=t.high>
10>>0,n=e.high>>>0;if(r<n)return!0;if(r===n){const i=t.low>>>0,a=e.low>>>0;if(i<a)return!0}return!1}function se(t,e){throw new g(`"${t}" is not a valid Decimal128 string - ${e}`)}class K extends te{get _bsontype(){return"Decimal128"}constructor(e){if(super(),typeof e=="string")this.bytes=K.fromString(e).bytes;else if(e instanceof Uint8Array||yt(e)){if(e.byteLength!==16)throw new g("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}else throw new g("Decimal128 must take a Buffer or string")}static fromString(e){return K._fromString(e,{allowRounding:!1})}static fromStringWithRounding(e){return K._fromString(e,{allowRounding:!0})}static _fromString(e,r){let n=!1,i=!1,a=!1,f=!1,l=0,m=0,d=0,b=0,h=0;const x=[0];let v=0,R=0,y=0,I=0,P=new o(0,0),j=new o(0,0),G=0,p=0;if(e.length>=7e3)throw new g(""+e+" not a valid Decimal128 string");const H=e.match(Or),V=e.match(Tr),ne=e.match(Ar);if(!H&&!V&&!ne||e.length===0)throw new g(""+e+" not a valid Decimal128 string");if(H){const A=H[2],W=H[4],E=H[5],T=H[6];W&&T===void 0&&se(e,"missing exponent power"),W&&A===void 0&&se(e,"missing exponent base"),W===void 0&&(E||T)&&se(e,"missing e before exponent")}if((e[p]==="+"||e[p]==="-")&&(i=!0,n=e[p++]==="-"),!gt(e[p])&&e[p]!=="."){if(e[p]==="i"||e[p]==="I")return new K(n?ft:mt);if(e[p]==="N")return new K(We)}for(;gt(e[p])||e[p]===".";){if(e[p]==="."){a&&se(e,"contains multiple periods"),a=!0,p=p+1;continue}v<ut&&(e[p]!=="0"||f)&&(f||(h=m),f=!0,x[R++]=parseInt(e[p],10),v=v+1),f&&(d=d+1),a&&(b=b+1),m=m+1,p=p+1}if(a&&!m)throw new g(""+e+" not a valid Decimal128 string");if(e[p]==="e"||e[p]==="E"){const A=e.substr(++p).match($r);if(!A||!A[2])return new K(We);I=parseInt(A[0],10),p=p+A[0].length}if(e[p])return new K(We);if(!v)x[0]=0,d=1,v=1,l=0;else if(y=v-1,l=d,l!==1)for(;e[h+l-1+Number(i)+Number(a)]==="0";)l=l-1;for(I<=b&&b>I+16384?I=Ae:I=I-b;I>be;){if(y=y+1,y>=ut){if(l===0){I=be;break}se(e,"overflow")}I=I-1}if(r.allowRounding){for(;I<Ae||v<d;){if(y===0&&l<v){I=Ae,l=0;break}if(v<d?d=d-1:y=y-1,I<be)I=I+1;else{if(x.join("").match(/^0+$/)){I=be;break}se(e,"overflow")}}if(y+1<l){let A=m;a&&(h=h+1,A=A+1),i&&(h=h+1,A=A+1);const W=parseInt(e[h+y+1],10);let E=0;if(W>=5&&(E=1,W===5)){E=x[y]%2===1?1:0;for(let T=h+y+2;T<A;T++)if(parseInt(e[T],10)){E=1;break}}if(E){let T=y;for(;T>=0&&++x[T]>9;T--)if(x[T]=0,T===0)if(I<be)I=I+1,x[T]=1;else return new K(n?ft:mt)}}}else{for(;I<Ae||v<d;){if(y===0){if(l===0){I=Ae;break}se(e,"exponent underflow")}v<d?(e[d-1+Number(i)+Number(a)]!=="0"&&l!==0&&se(e,"inexact rounding"),d=d-1):(x[y]!==0&&se(e,"inexact rounding"),y=y-1),I<be?I=I+1:se(e,"overflow")}y+1<l&&(a&&(h=h+1),i&&(h=h+1),parseInt(e[h+y+1],10)!==0&&se(e,"inexact rounding"))}if(P=o.fromNumber(0),j=o.fromNumber(0),l===0)P=o.fromNumber(0),j=o.fromNumber(0);else if(y<17){let A=0;for(j=o.fromNumber(x[A++]),P=new o(0,0);A<=y;A++)j=j.multiply(o.fromNumber(10)),j=j.add(o.fromNumber(x[A]))}else{let A=0;for(P=o.fromNumber(x[A++]);A<=y-17;A++)P=P.multiply(o.fromNumber(10)),P=P.add(o.fromNumber(x[A]));for(j=o.fromNumber(x[A++]);A<=y;A++)j=j.multiply(o.fromNumber(10)),j=j.add(o.fromNumber(x[A]))}const _=Rr(P,o.fromString("100000000000000000"));_.low=_.low.add(j),Fr(_.low,j)&&(_.high=_.high.add(o.fromNumber(1))),G=I+dt;const $={low:o.fromNumber(0),high:o.fromNumber(0)};_.high.shiftRightUnsigned(49).and(o.fromNumber(1)).equals(o.fromNumber(1))?($.high=$.high.or(o.fromNumber(3).shiftLeft(61)),$.high=$.high.or(o.fromNumber(G).and(o.fromNumber(16383).shiftLeft(47))),$.high=$.high.or(_.high.and(o.fromNumber(0x7fffffffffff)))):($.high=$.high.or(o.fromNumber(G&16383).shiftLeft(49)),$.high=$.high.or(_.high.and(o.fromNumber(562949953421311)))),$.low=_.low,n&&($.high=$.high.or(o.fromString("9223372036854775808")));const O=N.allocateUnsafe(16);return p=0,O[p++]=$.low.low&255,O[p++]=$.low.low>>8&255,O[p++]=$.low.low>>16&255,O[p++]=$.low.low>>24&255,O[p++]=$.low.high&255,O[p++]=$.low.high>>8&255,O[p++]=$.low.high>>16&255,O[p++]=$.low.high>>24&255,O[p++]=$.high.low&255,O[p++]=$.high.low>>8&255,O[p++]=$.high.low>>16&255,O[p++]=$.high.low>>24&255,O[p++]=$.high.high&255,O[p++]=$.high.high>>8&255,O[p++]=$.high.high>>16&255,O[p++]=$.high.high>>24&255,new K(O)}toString(){let e,r=0;const n=new Array(36);for(let p=0;p<n.length;p++)n[p]=0;let i=0,a=!1,f,l={parts:[0,0,0,0]},m,d;const b=[];i=0;const h=this.bytes,x=h[i++]|h[i++]<<8|h[i++]<<16|h[i++]<<24,v=h[i++]|h[i++]<<8|h[i++]<<16|h[i++]<<24,R=h[i++]|h[i++]<<8|h[i++]<<16|h[i++]<<24,y=h[i++]|h[i++]<<8|h[i++]<<16|h[i++]<<24;i=0,{low:new o(x,v),high:new o(R,y)}.high.lessThan(o.ZERO)&&b.push("-");const P=y>>26&Cr;if(P>>3===3){if(P===Ur)return b.join("")+"Infinity";if(P===Pr)return"NaN";e=y>>15&ht,f=8+(y>>14&1)}else f=y>>14&7,e=y>>17&ht;const j=e-dt;if(l.parts[0]=(y&16383)+((f&15)<<14),l.parts[1]=R,l.parts[2]=v,l.parts[3]=x,l.parts[0]===0&&l.parts[1]===0&&l.parts[2]===0&&l.parts[3]===0)a=!0;else for(d=3;d>=0;d--){let p=0;const H=kr(l);
10if(l=H.quotient,p=H.rem.low,!!p)for(m=8;m>=0;m--)n[d*9+m]=p%10,p=Math.floor(p/10)}if(a)r=1,n[i]=0;else for(r=36;!n[i];)r=r-1,i=i+1;const G=r-1+j;if(G>=34||G<=-7||j>0){if(r>34)return b.push("0"),j>0?b.push(`E+${j}`):j<0&&b.push(`E${j}`),b.join("");b.push(`${n[i++]}`),r=r-1,r&&b.push(".");for(let p=0;p<r;p++)b.push(`${n[i++]}`);b.push("E"),G>0?b.push(`+${G}`):b.push(`${G}`)}else if(j>=0)for(let p=0;p<r;p++)b.push(`${n[i++]}`);else{let p=r+j;if(p>0)for(let H=0;H<p;H++)b.push(`${n[i++]}`);else b.push("0");for(b.push(".");p++<0;)b.push("0");for(let H=0;H<r-Math.max(p-1,0);H++)b.push(`${n[i++]}`)}return b.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(e){return K.fromString(e.$numberDecimal)}inspect(e,r,n){return n??(n=Q),`new Decimal128(${n(this.toString(),r)})`}}class le extends te{get _bsontype(){return"Double"}constructor(e){super(),e instanceof Number&&(e=e.valueOf()),this.value=+e}static fromString(e){const r=Number(e);if(e==="NaN")return new le(NaN);if(e==="Infinity")return new le(1/0);if(e==="-Infinity")return new le(-1/0);if(!Number.isFinite(r))throw new g(`Input: ${e} is not representable as a Double`);if(e.trim()!==e)throw new g(`Input: '${e}' contains whitespace`);if(e==="")throw new g("Input is an empty string");if(/[^-0-9.+eE]/.test(e))throw new g(`Input: '${e}' is not in decimal or exponential notation`);return new le(r)}valueOf(){return this.value}toJSON(){return this.value}toString(e){return this.value.toString(e)}toExtendedJSON(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-0.0"}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}}static fromExtendedJSON(e,r){const n=parseFloat(e.$numberDouble);return r&&r.relaxed?n:new le(n)}inspect(e,r,n){return n??(n=Q),`new Double(${n(this.value,r)})`}}class Se extends te{get _bsontype(){return"Int32"}constructor(e){super(),e instanceof Number&&(e=e.valueOf()),this.value=+e|0}static fromString(e){const r=Bt(e),n=Number(e);if(Ke<n)throw new g(`Input: '${e}' is larger than the maximum value for Int32`);if(Qe>n)throw new g(`Input: '${e}' is smaller than the minimum value for Int32`);if(Number.isSafeInteger(n)){if(n.toString()!==r)throw new g(`Input: '${e}' is not a valid Int32 string`)}else throw new g(`Input: '${e}' is not a safe integer`);return new Se(n)}valueOf(){return this.value}toString(e){return this.value.toString(e)}toJSON(){return this.value}toExtendedJSON(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(e,r){return r&&r.relaxed?parseInt(e.$numberInt,10):new Se(e.$numberInt)}inspect(e,r,n){return n??(n=Q),`new Int32(${n(this.value,r)})`}}class _e extends te{get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new _e}inspect(){return"new MaxKey()"}}class Ve extends te{get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new Ve}inspect(){return"new MinKey()"}}let ge=null;const $e=new WeakMap;class L extends te{get _bsontype(){return"ObjectId"}constructor(e){super();let r;if(typeof e=="object"&&e&&"id"in e){if(typeof e.id!="string"&&!ArrayBuffer.isView(e.id))throw new g("Argument passed in must have an id that is of type string or Buffer");"toHexString"in e&&typeof e.toHexString=="function"?r=N.fromHex(e.toHexString()):r=e.id}else r=e;if(r==null||typeof r=="number")this.buffer=L.generate(typeof r=="number"?r:void 0);else if(ArrayBuffer.isView(r)&&r.byteLength===12)this.buffer=N.toLocalBufferType(r);else if(typeof r=="string")if(L.validateHexString(r))this.buffer=N.fromHex(r),L.cacheHexString&&$e.set(this,r);else throw new g("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");else throw new g("Argument passed in does not match the accepted types")}get id(){return this.buffer}set id(e){this.buffer=e,L.cacheHexString&&$e.set(this,N.toHex(e))}static validateHexString(e){if((e==null?void 0:e.length)!==24)return!1;for(let r=0;r<24;r++){const n=e.charCodeAt(r);if(!(n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70))return!1}return!0}toHexString(){if(L.cacheHexString){const r=$e.get(this);if(r)return r}const e=N.toHex(this.id);return L.cacheHexString&&$e.set(this,e),e}static getInc(){return L.index=(L.index+1)%16777215}static generate(e){typeof e!="number"&&(e=Math.floor(Date.now()/1e3));const r=L.getInc(),n=N.allocateUnsafe(12);return xe.setInt32BE(n,0,e),ge===null&&(ge=N.randomBytes(5)),n[4]=ge[0],n[5]=ge[1],n[6]=ge[2],n[7]=ge[3],n[8]=ge[4],n[11]=r&255,n[10]=r>>8&255,n[9]=r>>16&255,n}
10toString(e){return e==="base64"?N.toBase64(this.id):e==="hex"?this.toHexString():this.toHexString()}toJSON(){return this.toHexString()}static is(e){return e!=null&&typeof e=="object"&&"_bsontype"in e&&e._bsontype==="ObjectId"}equals(e){if(e==null)return!1;if(L.is(e))return this.buffer[11]===e.buffer[11]&&N.equals(this.buffer,e.buffer);if(typeof e=="string")return e.toLowerCase()===this.toHexString();if(typeof e=="object"&&typeof e.toHexString=="function"){const r=e.toHexString(),n=this.toHexString();return typeof r=="string"&&r.toLowerCase()===n}return!1}getTimestamp(){const e=new Date,r=xe.getUint32BE(this.buffer,0);return e.setTime(Math.floor(r)*1e3),e}static createPk(){return new L}serializeInto(e,r){return e[r]=this.buffer[0],e[r+1]=this.buffer[1],e[r+2]=this.buffer[2],e[r+3]=this.buffer[3],e[r+4]=this.buffer[4],e[r+5]=this.buffer[5],e[r+6]=this.buffer[6],e[r+7]=this.buffer[7],e[r+8]=this.buffer[8],e[r+9]=this.buffer[9],e[r+10]=this.buffer[10],e[r+11]=this.buffer[11],12}static createFromTime(e){const r=N.allocate(12);for(let n=11;n>=4;n--)r[n]=0;return xe.setInt32BE(r,0,e),new L(r)}static createFromHexString(e){if((e==null?void 0:e.length)!==24)throw new g("hex string must be 24 characters");return new L(N.fromHex(e))}static createFromBase64(e){if((e==null?void 0:e.length)!==16)throw new g("base64 string must be 16 characters");return new L(N.fromBase64(e))}static isValid(e){if(e==null)return!1;if(typeof e=="string")return L.validateHexString(e);try{return new L(e),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(e){return new L(e.$oid)}isCached(){return L.cacheHexString&&$e.has(this)}inspect(e,r,n){return n??(n=Q),`new ObjectId(${n(this.toHexString(),r)})`}}L.index=Math.floor(Math.random()*16777215);function Dr(t){return t.split("").sort().join("")}class de extends te{get _bsontype(){return"BSONRegExp"}constructor(e,r){if(super(),this.pattern=e,this.options=Dr(r??""),this.pattern.indexOf("\0")!==-1)throw new g(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(this.options.indexOf("\0")!==-1)throw new g(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let n=0;n<this.options.length;n++)if(!(this.options[n]==="i"||this.options[n]==="m"||this.options[n]==="x"||this.options[n]==="l"||this.options[n]==="s"||this.options[n]==="u"))throw new g(`The regular expression option [${this.options[n]}] is not supported`)}static parseOptions(e){return e?e.split("").sort().join(""):""}toExtendedJSON(e){return e=e||{},e.legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(e){if("$regex"in e)if(typeof e.$regex!="string"){if(e.$regex._bsontype==="BSONRegExp")return e}else return new de(e.$regex,de.parseOptions(e.$options));if("$regularExpression"in e)return new de(e.$regularExpression.pattern,de.parseOptions(e.$regularExpression.options));throw new g(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(e)}`)}inspect(e,r,n){const i=cr(r)??(l=>l);n??(n=Q);const a=i(n(this.pattern),"regexp"),f=i(n(this.options),"regexp");return`new BSONRegExp(${a}, ${f})`}}class He extends te{get _bsontype(){return"BSONSymbol"}constructor(e){super(),this.value=e}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(e){return new He(e.$symbol)}inspect(e,r,n){return n??(n=Q),`new BSONSymbol(${n(this.value,r)})`}}const Mr=o;class ce extends Mr{get _bsontype(){return"Timestamp"}get i(){return this.low>>>0}get t(){return this.high>>>0}constructor(e){if(e==null)super(0,0,!0);else if(typeof e=="bigint")super(e,!0);else if(o.isLong(e))super(e.low,e.high,!0);else if(typeof e=="object"&&"t"in e&&"i"in e){if(typeof e.t!="number"&&(typeof e.t!="object"||e.t._bsontype!=="Int32"))throw new g("Timestamp constructed from { t, i } must provide t as a number");if(typeof e.i!="number"&&(typeof e.i!="object"||e.i._bsontype!=="Int32"))throw new g("Timestamp constructed from { t, i } must provide i as a number");const r=Number(e.t),n=Number(e.i);if(r<0||Number.isNaN(r))throw new g("Timestamp constructed from { t, i } must provide a positive t");if(n<0||Number.isNaN(n))throw new g("Timestamp constructed from { t, i } must provide a positive i");if(r>4294967295)throw new g("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(n>4294967295)throw new g("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(n,r,!0)}else throw new g("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }")}toJSON(){return{$timestamp:this.toString()}}static fromInt(e){return new ce(o.fromInt(e,!0))}static fromNumber(e){return new ce(o.fromNumber(e,!0))}static fromBits(e,r){return new ce({i:e,t:r})}static fromString(e,r){return new ce(o.fromString(e,!0,r))}toExtendedJSON(){return{$timestamp:{t:this.t,i:this.i}}}static fromExtendedJSON(e){const r=o.isLong(e.$timestamp.i)?e.$timestamp.i.getLowBitsUnsigned():e.$timestamp.i,n=o.isLong(e.$timestamp.t)?e.$timestamp.t.getLowBitsUnsigned():e.$timestamp.t;return new ce({t:n,i:r})}inspect(e,r,n){n??(n=Q);const i=n(this.t,r),a=n(this.i,r);return`new Timestamp({ t: ${i}, i: ${a} })`}}ce.MAX_VALUE=o.MAX_UNSIGNED_VALUE;o.fromNumber(dr);o.fromNumber(ur);function Lr(t){return t!=null&&typeof t=="object"&&"_bsontype"in t&&typeof t._bsontype=="string"}
10const _r={$oid:L,$binary:S,$uuid:S,$symbol:He,$numberInt:Se,$numberDecimal:K,$numberDouble:le,$numberLong:o,$minKey:Ve,$maxKey:_e,$regex:de,$regularExpression:de,$timestamp:ce};function Tt(t,e={}){if(typeof t=="number"){const n=t<=Ke&&t>=Qe,i=t<=jt&&t>=St;if(e.relaxed||e.legacy)return t;if(Number.isInteger(t)&&!Object.is(t,-0)){if(n)return new Se(t);if(i)return e.useBigInt64?BigInt(t):o.fromNumber(t)}return new le(t)}if(t==null||typeof t!="object")return t;if(t.$undefined)return null;const r=Object.keys(t).filter(n=>n.startsWith("$")&&t[n]!=null);for(let n=0;n<r.length;n++){const i=_r[r[n]];if(i)return i.fromExtendedJSON(t,e)}if(t.$date!=null){const n=t.$date,i=new Date;if(e.legacy)if(typeof n=="number")i.setTime(n);else if(typeof n=="string")i.setTime(Date.parse(n));else if(typeof n=="bigint")i.setTime(Number(n));else throw new st(`Unrecognized type for EJSON date: ${typeof n}`);else if(typeof n=="string")i.setTime(Date.parse(n));else if(o.isLong(n))i.setTime(n.toNumber());else if(typeof n=="number"&&e.relaxed)i.setTime(n);else if(typeof n=="bigint")i.setTime(Number(n));else throw new st(`Unrecognized type for EJSON date: ${typeof n}`);return i}if(t.$code!=null){const n=Object.assign({},t);return t.$scope&&(n.$scope=Tt(t.$scope)),Ue.fromExtendedJSON(t)}if(jr(t)||t.$dbPointer){const n=t.$ref?t:t.$dbPointer;if(n instanceof je)return n;const i=Object.keys(n).filter(f=>f.startsWith("$"));let a=!0;if(i.forEach(f=>{["$ref","$id","$db"].indexOf(f)===-1&&(a=!1)}),a)return je.fromExtendedJSON(n)}return t}function Vr(t,e){return t.map((r,n)=>{e.seenObjects.push({propertyName:`index ${n}`,obj:null});try{return ae(r,e)}finally{e.seenObjects.pop()}})}function xt(t){const e=t.toISOString();return t.getUTCMilliseconds()!==0?e:e.slice(0,-5)+"Z"}function ae(t,e){if(t instanceof Map||wt(t)){const r=Object.create(null);for(const[n,i]of t){if(typeof n!="string")throw new g("Can only serialize maps with string keys");r[n]=i}return ae(r,e)}if((typeof t=="object"||typeof t=="function")&&t!==null){const r=e.seenObjects.findIndex(n=>n.obj===t);if(r!==-1){const n=e.seenObjects.map(b=>b.propertyName),i=n.slice(0,r).map(b=>`${b} -> `).join(""),a=n[r],f=" -> "+n.slice(r+1,n.length-1).map(b=>`${b} -> `).join(""),l=n[n.length-1],m=" ".repeat(i.length+a.length/2),d="-".repeat(f.length+(a.length+l.length)/2-1);throw new g(`Converting circular structure to EJSON: 11 ${i}${a}${f}${l} 12 ${m}\\${d}/`)}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return Vr(t,e);if(t===void 0)return null;if(t instanceof Date||lr(t)){const r=t.getTime(),n=r>-1&&r<2534023188e5;return e.legacy?e.relaxed&&n?{$date:t.getTime()}:{$date:xt(t)}:e.relaxed&&n?{$date:xt(t)}:{$date:{$numberLong:t.getTime().toString()}}}if(typeof t=="number"&&(!e.relaxed||!isFinite(t))){if(Number.isInteger(t)&&!Object.is(t,-0)){if(t>=Qe&&t<=Ke)return{$numberInt:t.toString()};if(t>=St&&t<=jt)return{$numberLong:t.toString()}}return{$numberDouble:Object.is(t,-0)?"-0.0":t.toString()}}if(typeof t=="bigint")return e.relaxed?Number(BigInt.asIntN(64,t)):{$numberLong:BigInt.asIntN(64,t).toString()};if(t instanceof RegExp||ar(t)){let r=t.flags;if(r===void 0){const i=t.toString().match(/[gimuy]*$/);i&&(r=i[0])}return new de(t.source,r).toExtendedJSON(e)}return t!=null&&typeof t=="object"?Jr(t,e):t}const Hr={Binary:t=>new S(t.value(),t.sub_type),Code:t=>new Ue(t.code,t.scope),DBRef:t=>new je(t.collection||t.namespace,t.oid,t.db,t.fields),Decimal128:t=>new K(t.bytes),Double:t=>new le(t.value),Int32:t=>new Se(t.value),Long:t=>o.fromBits(t.low!=null?t.low:t.low_,t.low!=null?t.high:t.high_,t.low!=null?t.unsigned:t.unsigned_),MaxKey:()=>new _e,MinKey:()=>new Ve,ObjectId:t=>new L(t),BSONRegExp:t=>new de(t.pattern,t.options),BSONSymbol:t=>new He(t.value),Timestamp:t=>ce.fromBits(t.low,t.high)};function Jr(t,e){if(t==null||typeof t!="object")throw new g("not an object instance");const r=t._bsontype;if(typeof r>"u"){const n={};for(const i of Object.keys(t)){e.seenObjects.push({propertyName:i,obj:null});try{const a=ae(t[i],e);i==="__proto__"?Object.defineProperty(n,i,{value:a,writable:!0,enumerable:!0,configurable:!0}):n[i]=a}
12finally{e.seenObjects.pop()}}return n}else{if(t!=null&&typeof t=="object"&&typeof t._bsontype=="string"&&t[Nt]!==Xe)throw new fr;if(Lr(t)){let n=t;if(typeof n.toExtendedJSON!="function"){const i=Hr[t._bsontype];if(!i)throw new g("Unrecognized or invalid _bsontype: "+t._bsontype);n=i(n)}return r==="Code"&&n.scope?n=new Ue(n.code,ae(n.scope,e)):r==="DBRef"&&n.oid&&(n=new je(ae(n.collection,e),ae(n.oid,e),ae(n.db,e),ae(n.fields,e))),n.toExtendedJSON(e)}else throw new g("_bsontype must be a string, but was: "+typeof r)}}function At(t,e){const r={useBigInt64:(e==null?void 0:e.useBigInt64)??!1,relaxed:(e==null?void 0:e.relaxed)??!0,legacy:(e==null?void 0:e.legacy)??!1};return JSON.parse(t,(n,i)=>{if(n.indexOf("\0")!==-1)throw new g(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(n)}`);return Tt(i,r)})}function $t(t,e,r,n){r!=null&&typeof r=="object"&&(n=r,r=0),e!=null&&typeof e=="object"&&!Array.isArray(e)&&(n=e,e=void 0,r=0);const i=Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}),a=ae(t,i);return JSON.stringify(a,e,r)}function qr(t,e){return e=e||{},JSON.parse($t(t,e))}function Yr(t,e){return e=e||{},At(JSON.stringify(t),e)}const Pe=Object.create(null);Pe.parse=At;Pe.stringify=$t;Pe.serialize=qr;Pe.deserialize=Yr;Object.freeze(Pe);const M={double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:255,maxKey:127};function ze(t,e){try{return xe.getNonnegativeInt32LE(t,e)}catch(r){throw new me("BSON size cannot be negative",e,{cause:r})}}function Ge(t,e){let r=e;for(;t[r]!==0;r++);if(r===t.length-1)throw new me("Null terminator not found",e);return r}function Wr(t,e=0){if(e??(e=0),t.length<5)throw new me(`Input must be at least 5 bytes, got ${t.length} bytes`,e);const r=ze(t,e);if(r>t.length-e)throw new me(`Parsed documentSize (${r} bytes) does not match input length (${t.length} bytes)`,e);if(t[e+r-1]!==0)throw new me("BSON documents must end in 0x00",e+r);const n=[];let i=e+4;for(;i<=r+e;){const a=t[i];if(i+=1,a===0){if(i-e!==r)throw new me("Invalid 0x00 type byte",i);break}const f=i,l=Ge(t,i)-f;i+=l+1;let m;if(a===M.double||a===M.long||a===M.date||a===M.timestamp)m=8;else if(a===M.int)m=4;else if(a===M.objectId)m=12;else if(a===M.decimal)m=16;else if(a===M.bool)m=1;else if(a===M.null||a===M.undefined||a===M.maxKey||a===M.minKey)m=0;else if(a===M.regex)m=Ge(t,Ge(t,i)+1)+1-i;else if(a===M.object||a===M.array||a===M.javascriptWithScope)m=ze(t,i);else if(a===M.string||a===M.binData||a===M.dbPointer||a===M.javascript||a===M.symbol)m=ze(t,i)+4,a===M.binData&&(m+=1),a===M.dbPointer&&(m+=12);else throw new me(`Invalid 0x${a.toString(16).padStart(2,"0")} type byte`,i);if(m>r)throw new me("value reports length larger than document",i);n.push([a,f,l,i,m]),i+=m}return n}const Je=Object.create(null);Je.parseToElements=Wr;Je.ByteUtils=N;Je.NumberUtils=xe;Object.freeze(Je);const zr=1024*1024*17;N.allocate(zr);const Gr=({name:t,label:e,placeholder:r="Select",required:n,control:i,options:a,className:f="",rules:l,disabled:m,onCustomValueAdd:d})=>{const[b,h]=U.useState(!1),[x,v]=U.useState("");return s.jsxs("div",{className:`flex flex-col gap-2 ${f}`,children:[e&&s.jsxs("label",{className:"text-sm font-medium text-text-primary",children:[e," ",n&&s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(z,{name:t,control:i,rules:l,render:({field:R,fieldState:y})=>{const I=y.error,P=R.value||"";return s.jsxs(s.Fragment,{children:[b?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:x,onChange:j=>v(j.target.value),placeholder:"Enter custom type",className:`flex-1 rounded-lg bg-white dark:bg-[#121212] border border-card-border px-3 py-2 text-sm text-text-primary placeholder-gray-500 outline-none transition h-9 13 focus:border-[#fbbf24] focus:ring-2 focus:ring-[#fbbf24]/30`,onKeyDown:j=>{j.key==="Enter"?(j.preventDefault(),x.trim()&&(R.onChange(x.trim()),d&&d(x.trim()),h(!1),v(""))):j.key==="Escape"&&(h(!1),v(""))},autoFocus:!0}),s.jsx("button",{type:"button",onClick:()=>{x.trim()&&(R.onChange(x.trim()),d&&d(x.trim()),h(!1),v(""))},className:"rounded-lg bg-[#fbbf24] px-4 py-2 text-sm text-black font-medium hover:bg-[#f59e0b] transition-colors",children:"Add"}),s.jsx("button",{type:"button",onClick:()=>{h(!1),v("")},className:"rounded-lg bg-[#374151] px-4 py-2 text-sm text-text-primary font-medium hover:bg-[#4b5563] transition-colors",children:"Cancel"})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("select",{...R,disabled:m,onChange:j=>{j.target.value==="__custom__"?h(!0):R.onChange(j)},value:P,className:`w-full appearance-none rounded-lg bg-white dark:bg-[#121212] border border-card-border px-3 py-2 text-sm text-text-secondary outline-none transition h-9 14 focus:border-[#fbbf24] focus:ring-2 focus:ring-[#fbbf24]/30 15 disabled:opacity-50 disabled:cursor-not-allowed`,children:[s.jsx("option",{value:"",children:r}),a.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value)),s.jsx("option",{value:"__custom__",children:"+ Add New Option"})]}),s.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-3 flex items-center",children:s.jsx("img",{src:"/scriptwriter/down-arro.svg",alt:"Arrow",className:"h-3 w-3 text-text-tertiary"})})]}),I&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:typeof I.message=="string"?I.message:"Invalid value"})]})}})]})};function Zr({characters:t,selectedCharacter:e,onSelect:r,filter:n,onFilterChange:i,searchQuery:a,onSearchChange:f}){return s.jsxs("div",{className:"bg-bg-secondary border border-card-border rounded-lg p-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-text-primary mb-4",children:"Characters"}),s.jsxs("div",{className:"mb-4 space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Vt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-text-tertiary"}),s.jsx("input",{type:"text",placeholder:"Search characters...",value:a,onChange:l=>f(l.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-secondary border border-card-border text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-button","aria-label":"Search characters"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ht,{className:"w-4 h-4 text-text-tertiary"}),s.jsx("div",{className:"flex gap-2",children:["all","mapped","unmapped"].map(l=>s.jsx("button",{onClick:()=>i(l),className:`px-3 py-1 rounded text-sm font-medium transition-colors ${n===l?"bg-primary-button text-primary-button-text":"bg-bg-secondary text-text-tertiary hover:text-text-primary border border-card-border"}`,"aria-label":`Filter by ${l}`,"aria-pressed":n===l,children:l.charAt(0).toUpperCase()+l.slice(1)},l))})]})]}),s.jsx("div",{className:"max-h-[600px] overflow-y-auto",children:t.length===0?s.jsx("div",{className:"text-center py-8 text-text-tertiary",children:s.jsx("p",{children:"No characters found"})}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:t.map(l=>{var b,h;const m=(e==null?void 0:e.id)===l.id,d=l.mapped?s.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium bg-success-text/20 text-success-text border border-success-text/30",children:"Mapped"}):s.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium bg-error-text/20 text-error-text border border-error-text/30",children:"Unmapped"});return s.jsx("button",{onClick:()=>r(l),className:`text-left p-3 rounded-lg border transition-all ${m?"border-primary-button bg-primary-button/10":"border-card-border bg-bg-secondary hover:border-gray-300 border-border-color"}`,"aria-label":`Select character ${l.name}`,"aria-selected":m,children:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 max-w-[70%]",children:[((b=l==null?void 0:l.mappingObject)==null?void 0:b.photoUrl)&&s.jsx("img",{src:(h=l==null?void 0:l.mappingObject)==null?void 0:h.photoUrl,alt:l==null?void 0:l.name,className:"w-8 h-8 rounded-full object-cover"}),s.jsx("h4",{className:"font-semibold text-text-primary truncate text-sm",children:l.name})]}),d]}),l.description&&s.jsx("p",{className:"text-xs text-text-secondary line-clamp-2",children:l.description}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-tertiary",children:[l.occurrences!==void 0&&s.jsxs("span",{children:[l.occurrences," occurrence",l.occurrences!==1?"s":""]}),l.gender&&s.jsx("span",{className:"capitalize",children:l.gender}),l.ageRange&&s.jsx("span",{children:l.ageRange})]})]})},l.id)})})})]})}const Xr=["Actor","Writer","Director","Producer","Supporting","Cameo","Other"];function Kr({character:t,characters:e=[],mapping:r,onSave:n,onCharacterSelect:i,onDelete:a,projectId:f}){const[l,m]=U.useState(!1),[d,b]=U.useState((r==null?void 0:r.actorName)||""),[h,x]=U.useState((r==null?void 0:r.role)||"Actor"),[v,R]=U.useState((r==null?void 0:r.imdbUrl)||""),[y,I]=U.useState(null),[P,j]=U.useState((r==null?void 0:r.photoUrl)||null),[G,p]=U.useState(!1),[H,V]=U.useState(r==null?void 0:r.photoFileId),ne=U.useRef(null);U.useEffect(()=>{var E,T,he,re,ie;t!=null&&t.mappingObject?(b(((E=t==null?void 0:t.mappingObject)==null?void 0:E.actorName)||""),x(((T=t==null?void 0:t.mappingObject)==null?void 0:T.role)||"Actor"),R(((he=t==null?void 0:t.mappingObject)==null?void 0:he.imdbUrl)||""),j(((re=t==null?void 0:t.mappingObject)==null?void 0:re.photoUrl)||null),V((ie=t==null?void 0:t.mappingObject)==null?void 0:ie.photo
15FileId)):r?(b(r.actorName||""),x(r.role||"Actor"),R(r.imdbUrl||""),j(r.photoUrl||null),V(r.photoFileId)):t&&(b(""),x("Actor"),R(""),j(null),V(void 0),I(null))},[r,t]);const _=E=>E?/^https?:\/\/(www\.)?imdb\.com\/(title|name)\/.+/i.test(E):!0,$=async E=>{var he,re,ie,Ee,ke;const T=(he=E.target.files)==null?void 0:he[0];if(T){if(!["image/jpeg","image/jpg","image/png"].includes(T.type)){k.error("Please upload a JPG or PNG image");return}if(T.size>5*1024*1024){k.error("Image size must be less than 5MB");return}I(T),j(URL.createObjectURL(T));try{p(!0);const X=await fe.scriptWriters.uploadToS3({projectId:f,filename:T.name,contentType:T.type,expiresInSeconds:300,isPoster:!1}),ve=((ie=(re=X==null?void 0:X.data)==null?void 0:re.result)==null?void 0:ie.url)||((ke=(Ee=X==null?void 0:X.data)==null?void 0:Ee.result)==null?void 0:ke.signedUrl);if(!ve)throw new Error("Failed to get upload URL");if(!await fe.scriptWriters.putToSignedUrl(ve,T,T.type))throw new Error("Failed to upload file");const Re=Ze(f,"/cast/",T.name);Re&&j(Re),V(T.name),k.success("Photo uploaded successfully")}catch(X){console.error("Error uploading photo:",X),k.error("Failed to upload photo. Please try again."),I(null),j(null)}finally{p(!1)}}},O=()=>{if(!d.trim()){k.error("Actor name is required");return}if(v&&!_(v)){k.error("Invalid IMDB URL format. Must be https://www.imdb.com/title/... or https://www.imdb.com/name/...");return}const E={actorName:d.trim(),role:h,imdbUrl:v.trim()||void 0,photoFileId:H,photoUrl:P};console.log("Saving mapping:",E),n(E)},A=()=>{r?(b(r.actorName||""),x(r.role||"Actor"),R(r.imdbUrl||""),j(r.photoUrl||null),V(r.photoFileId)):(b(""),x("Actor"),R(""),j(null),V(void 0)),I(null)},W=U.useRef(null);return U.useEffect(()=>{const E=T=>{W.current&&!W.current.contains(T.target)&&m(!1)};return l&&document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E)}},[l]),!t&&e.length===0?s.jsx("div",{className:"bg-bg-secondary border border-card-border rounded-lg p-6 text-center",children:s.jsx("p",{className:"text-text-tertiary",children:"Select a character to map to cast/crew"})}):s.jsxs("div",{className:"bg-bg-secondary border border-card-border rounded-lg p-3 md:p-6",children:[s.jsx("div",{className:"flex items-start justify-between mb-4",children:s.jsx("div",{children:s.jsx("h3",{className:"text-lg font-semibold text-text-primary mb-1",children:"Character mapping"})})}),e.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Select Character"}),s.jsxs("div",{className:"relative",ref:W,children:[s.jsxs("button",{type:"button",onClick:()=>m(!l),className:"w-full flex items-center justify-between rounded-lg bg-bg-secondary border border-card-border text-text-primary px-4 py-3 font-semibold hover:border-gray-300 border-border-color focus:outline-none focus:ring-2 focus:ring-primary-button focus:border-transparent transition-colors",children:[s.jsx("span",{children:t?`${t.name}${t.gender?` | ${t.gender.charAt(0).toUpperCase()+t.gender.slice(1)}`:""}${t.occurrences!==void 0?` | ${t.occurrences}`:""}`:"Select a character"}),s.jsx(Lt,{className:`w-5 h-5 text-text-tertiary transition-transform ${l?"rotate-180":""}`})]}),l&&s.jsx("div",{className:"absolute z-50 w-full mt-2 bg-bg-secondary border border-card-border rounded-lg shadow-lg max-h-60 overflow-y-auto",children:e.map(E=>s.jsxs("button",{type:"button",onClick:()=>{i&&i(E),m(!1)},className:`w-full text-left px-4 py-3 hover:bg-bg-tertiary transition-colors ${(t==null?void 0:t.id)===E.id?"bg-primary-button/10 text-primary-button-text":"text-text-primary"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"font-medium",children:E.name}),E.mapped&&s.jsx("span",{className:"text-xs bg-success-text/20 text-success-text px-2 py-0.5 rounded",children:"Mapped"})]}),s.jsxs("div",{className:"text-xs text-text-tertiary mt-1",children:[E.gender&&s.jsx("span",{className:"capitalize",children:E.gender}),E.ageRange&&s.jsxs("span",{children:[" ⢠",E.ageRange]}),E.occurrences!==void 0&&s.jsxs("span",{children:[" ⢠",E.occurrences," occurrences"]})]})]},E.id))})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-text-primary mb-2",children:["Actor Name ",s.jsx("span",{className:"text-error-text",children:"*"})]}),s.jsx("input",{type:"text",value:d,onChange:E=>b(E.target.value),placeholder:"Enter actor name",className:"w-full rounded-lg bg-bg-secondary border border-card-border p-3 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-button","aria-label":"Actor name",required:!0})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-text-primary mb-2",children:["Role ",s.jsx("span",{className:"text-error-text",children:"*"})]}),s.jsx("select",{value:h,onChange:E=>x(E.target.value),className:"w-full rounded-lg bg-bg-secondary border border-card-border p-3 text-text-primary focus:outline-none focus:ring-2 focus:ring-primary-button","aria-label":"Role",children:Xr.map(E=>s.jsx("option",{value:E,children:E},E))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"IMDB URL"}
15),s.jsx("input",{type:"url",value:v,onChange:E=>R(E.target.value),placeholder:"https://www.imdb.com/title/... or https://www.imdb.com/name/...",className:"w-full rounded-lg bg-bg-secondary border border-card-border p-3 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-button","aria-label":"IMDB URL"}),v&&!_(v)&&s.jsx("p",{className:"text-error-text text-xs mt-1",children:"Invalid IMDB URL format"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Upload Photo"}),s.jsxs("div",{onClick:()=>{var E;return(E=ne.current)==null?void 0:E.click()},className:"w-full h-32 rounded-lg border-2 border-dashed border-card-border bg-bg-secondary flex flex-col items-center justify-center cursor-pointer hover:border-primary-button transition-colors relative overflow-hidden","aria-label":"Upload photo",children:[s.jsx("input",{ref:ne,type:"file",accept:"image/jpeg,image/jpg,image/png",onChange:$,className:"hidden","aria-label":"Photo file input"}),G?s.jsx(Jt,{className:"w-8 h-8 text-accent-text animate-spin mb-2"}):P?s.jsx("img",{src:P,alt:"Preview",className:"w-full h-full object-cover"}):s.jsxs(s.Fragment,{children:[s.jsx(qt,{className:"w-8 h-8 text-text-tertiary mb-2"}),s.jsx("p",{className:"text-xs text-text-tertiary text-center px-4",children:"jpeg, jpg, png ⢠Max 5MB"})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx("button",{onClick:A,className:"flex-1 rounded-lg border border-card-border px-4 py-3 font-semibold text-text-primary hover:bg-gray-200 dark:hover:bg-gray-800 transition-colors","aria-label":"Cancel",children:"Cancel"}),s.jsx("button",{onClick:O,className:"flex-1 rounded-lg bg-primary-button px-4 py-3 font-semibold text-primary-button-text hover:bg-primary-button-hover transition-colors","aria-label":"Save mapping",children:"Save"})]})]})]})}const Qr=({onClose:t})=>{const e=new L().toString(),[r,n]=U.useState(0),[i,a]=U.useState({original:!1,terms:!1,privacy:!1}),[f,l]=U.useState(""),{userId:m}=bt(),{control:d,handleSubmit:b,watch:h,setValue:x,trigger:v,getValues:R,formState:{errors:y,isValid:I}}=Dt({mode:"onChange"}),P=()=>{n(c=>c-1)},[j,G]=U.useState([]),[p,H]=U.useState([{value:"Feature Film",label:"Feature Film"},{value:"Short Film",label:"Short Film"},{value:"Documentary",label:"Documentary"},{value:"Web Series",label:"Web Series"}]),[V,ne]=U.useState(()=>{if(typeof window<"u"){const c=sessionStorage.getItem(`characters_${e}`);return c?JSON.parse(c):[]}return[]}),[_,$]=U.useState(()=>{if(typeof window<"u"){const c=sessionStorage.getItem(`mappings_${e}`);return c?JSON.parse(c):[]}return[]}),[O,A]=U.useState(null),[W,E]=U.useState("all"),[T,he]=U.useState(""),[re,ie]=U.useState(!1),[Ee,ke]=U.useState(!1),X=c=>{typeof window<"u"&&sessionStorage.setItem(`characters_${e}`,JSON.stringify(c))},ve=c=>{typeof window<"u"&&sessionStorage.setItem(`mappings_${e}`,JSON.stringify(c))};U.useEffect(()=>{if(V.length>0&&_.length>0){const c=V.map(w=>{const B=_.find(D=>D.characterId===w.id),F=!!B,q=B==null?void 0:B.id;return w.mapped!==F||w.mappingId!==q?{...w,mapped:F,mappingId:q}:w});c.some((w,B)=>{var F,q;return w.mapped!==((F=V[B])==null?void 0:F.mapped)||w.mappingId!==((q=V[B])==null?void 0:q.mappingId)})&&(ne(c),X(c))}},[]);const et=async()=>{var Ie,Be,Oe,J;if(!await v(["tempName","tempRole","tempImdbUrl"]))return;const u=h("tempName"),w=h("tempRole"),B=h("tempImdbUrl"),F=h("tempPhoto");if(!u||!w){alert("Please fill in Name and Role");return}let q;const D=F==null?void 0:F[0];if(D)try{const Y=await fe.scriptWriters.uploadToS3({projectId:e,filename:D.name,contentType:D.type,expiresInSeconds:300}),Te=((Be=(Ie=Y==null?void 0:Y.data)==null?void 0:Ie.result)==null?void 0:Be.url)??((J=(Oe=Y==null?void 0:Y.data)==null?void 0:Oe.result)==null?void 0:J.signedUrl);if(!Te)throw new Error("Signed URL missing");console.log("uploading file type",D.type);const De=await fe.scriptWriters.putToSignedUrl(Te,D,D.type);console.log("result of uplaod image",De),q=Ze(e,"/cast/",D.name)}catch(Y){k.error("Failed to upload photo"),console.error(Y)}const Fe={name:u,role:w,imdbUrl:B||"",avatar:q};G(Y=>[...Y,Fe]),x("tempName",""),x("tempRole",""),x("tempImdbUrl",""),x("tempPhoto",void 0)},Re=c=>
15{G(u=>u.filter((w,B)=>B!==c))},Ct=async()=>{n(u=>u+1);const c={projectId:f||e,characters:V,characterMappings:_.map(u=>({actorName:u.actorName,role:u.role,imdbUrl:u.imdbUrl,photoFileId:u.photoFileId,photoUrl:u.photoUrl}))};try{const u=await ye.editProject(c);if((u==null?void 0:u.status)==="error"){k.error(u.message||"Failed to add characters and mappings");return}else await ye.getProjects({forceRefresh:!0,userId:m}),k.success("Characters and mappings saved successfully")}catch(u){console.error("API Error:",u),k.error("Failed to save characters and mappings")}},Ut=async()=>{var q,D,Fe,Ie,Be,Oe;if(!await v(["projectName","genre","language","type","logline","synopsis","projectStatus","runTime","audienceType"])){n(1);return}const u=R();let w;const B=(q=u.poster_image)==null?void 0:q[0];if(B)try{const J=await fe.scriptWriters.uploadToS3({projectId:e,filename:B.name,contentType:B.type,expiresInSeconds:300,isPoster:!0});if(w=((Fe=(D=J==null?void 0:J.data)==null?void 0:D.result)==null?void 0:Fe.url)??((Be=(Ie=J==null?void 0:J.data)==null?void 0:Ie.result)==null?void 0:Be.signedUrl),console.log("Poster upload response:",J,"Generated poster URL:",w),!w)throw k.error("Poster URL missing in upload response"),new Error("Poster URL missing in upload response");await fe.scriptWriters.putToSignedUrl(w,B,B.type)||k.error("Failed to upload poster to S3"),w=Ze(e,"/poster/",B.name)}catch(J){k.error("Failed to upload poster image"),console.error(J);return}const F={projectId:e,name:u.projectName,description:u.logline,synopsis:u.synopsis,genre:u.genre,language:u.language,type:u.type,status:u.projectStatus,runTime:Number(u.runTime),audienceType:u.audienceType,primaryPurpose:u.primaryPurpose||void 0,userId:m||void 0,posterUrl:w,castAndCrewInfo:j};console.log(F);try{const J=await ye.createProject(F);if(J.status==="error"){k.error(J.message||"Failed to create project");return}else{l(e),console.log("Create Project Response:",J),k.success("Project created successfully");const Y=(Oe=u.scriptFile)==null?void 0:Oe[0];if(Y)try{k.loading("Uploading script...",{id:"script-upload"});const Te=await new Promise((kt,Rt)=>{const Me=new FileReader;Me.readAsDataURL(Y),Me.onload=()=>kt(Me.result.split(",")[1]),Me.onerror=Rt}),De=1;await fe.scriptWriters.uploadFileForProject({objectName:"input/"+Wt(Y.name,De),objectData:Te,scriptTitle:Yt(Y.name),genre:u.genre||"",contentType:Y.type,releaseDate:"",version:De,projectId:e}),k.success("Script uploaded successfully",{id:"script-upload"})}catch{k.error("Script upload failed â you can upload it later from the project page",{id:"script-upload"})}n(2),_t("marketplace_project_created",{projectId:e,projectTitle:u.projectName,description:u.logline,synopsis:u.synopsis,genre:u.genre,language:u.language,type:u.type,status:u.projectStatus,runTime:Number(u.runTime),audienceType:u.audienceType,userId:m||void 0,posterUrl:w,castAndCrewInfo:j}),await ye.getProjects({forceRefresh:!0,userId:m})}}catch(J){console.error("API Error:",J),k.error("Failed to create project")}},Pt=["Terms & Consent","Project Essentials","Build Your Team"],tt=r===0?33:r===1?67:100,rt=[{label:"Terms & Consent",icon:Gt},{label:"Project Essentials",icon:Zt},{label:"Build Your Team",icon:Xt,optional:!0}];return s.jsxs("div",{className:"min-h-screen bg-bg-primary text-text-primary",children:[s.jsx("div",{className:"pb-3",children:s.jsxs("div",{className:"pb-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:r===0?t:P,className:"rounded-full p-2 hover:bg-gray-200 dark:hover:bg-gray-800 transition-colors","aria-label":"Go Back",children:s.jsx(zt,{className:"w-5 h-5 text-text-primary"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-text-primary",children:"Create Project"}),s.jsx("p",{className:"text-sm text-text-secondary",children:r<=2?Pt[r]:r===3?"Upload Script":"Characters"})]})]}),s.jsxs("span",{className:"text-sm font-semibold text-yellow-400",children:[tt,"%"]})]})}),s.jsx("div",{className:"relative h-1.5 w-full bg-bg-secondary rounded-full overflow-hidden mb-6",children:s.jsx("div",{className:"absolute h-full rounded-full bg-yellow-400 transition-all duration-300",style:{width:`${tt}%`}})}),r<=2&&s.jsx("div",{className:"flex items-center gap-0 mb-8",children:rt.map((c,u)=>{const w=c.icon,B=u<r,F=u===r;return s.jsxs("div",{className:"flex items-center flex-1 last:flex-none",children:[s.jsxs("div",{className:"flex flex-col items-center gap-1.5 min-w-0",children:[s.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center border-2 transition-colors ${B?"bg-yellow-400 border-yellow-400":F?"bg-transparent border-yellow-400":"bg-transparent border-card-border"}`,children:B?s.jsx("svg",{className:"w-5 h-5 text-black",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx(w,{className:`w-4 h-4 ${F?"text-yellow-400":"text-text-secondary"}`})}),s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:`text-xs font-medium ${F?"text-text-primary":"text-text-secondary"}`,children:c.label}),c.optional&&s.jsx("span",{className:"block text-[10px] text-text-secondary border border-card-border rounded px-1 mt-0.5 w-fit mx-auto",children:"Optional"})]})]}),u<rt.length-1&&s.jsx("div",{className:`flex-1 h-px mx-2 mb-5 ${u<r?"bg-yellow-400/60":"bg-card-border"}`})]},u)})}),r===0&&s.jsx("div",{className:"max-w-3xl mx-auto",children:s.jsxs("div",{className:"bg-bg-secondary rounded-xl border border-card-border p-6 md:p-8",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-yellow-400",children:"â "}),s.jsx("h2",{className:"text-xl font-bold text-text-primary",children:"Agreement & Project Creation Consent"})]}),s.jsx("p",{className:"text-text-secondary text-sm mb-6",children:"Please review and accept the following terms to continue"}),s.jsx("ul",{className:"space-y-3 mb-6",children:[s.jsxs(s.Fragment,{children:["Every script you upload on RecoBee is ",s.jsx("strong",{children:"encrypted, NDA-protected"}),", and ",s.jsx("strong",{children:"stored securely"}
15)," in our creative vault."]}),s.jsxs(s.Fragment,{children:["The material you are uploading is ",s.jsx("strong",{children:"your original work"})," and does not infringe upon any third-party rights."]}),s.jsx(s.Fragment,{children:"You grant RecoBee limited permission to securely process and analyze your content for providing creative insights and discovery opportunities."}),s.jsxs(s.Fragment,{children:["All Bee icons are encrypted and protected under RecoBee's ",s.jsx("strong",{children:"NDA-backed security system"}),"."]}),s.jsx(s.Fragment,{children:"You retain full ownership and copyrights to your work at all times."}),s.jsxs(s.Fragment,{children:["Any collaboration, access, or sharing of your script only with ",s.jsx("strong",{children:"your explicit consent"}),"."]})].map((c,u)=>s.jsxs("li",{className:"flex items-start gap-3 text-sm text-text-secondary",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-yellow-400 mt-1.5 flex-shrink-0"}),s.jsx("span",{children:c})]},u))}),s.jsx("p",{className:"text-text-secondary text-sm mb-5",children:"Please review and agree to the following terms before creating your first project:"}),s.jsx("div",{className:"space-y-3 mb-8",children:[{key:"original",label:"I confirm that this work is my original creation"},{key:"terms",label:s.jsxs(s.Fragment,{children:["I agree to RecoBee's ",s.jsx("a",{href:"/terms-and-conditions",target:"_blank",rel:"noreferrer",className:"text-yellow-400 underline",children:"Terms & Conditions"})]})},{key:"privacy",label:s.jsxs(s.Fragment,{children:["I have read and understood the ",s.jsx("a",{href:"/privacy-policy",target:"_blank",rel:"noreferrer",className:"text-yellow-400 underline",children:"Privacy Policy"})]})}].map(({key:c,label:u})=>s.jsxs("label",{className:"flex items-center gap-3 bg-bg-primary rounded-lg px-4 py-3 cursor-pointer hover:bg-bg-tertiary transition-colors",children:[s.jsx("input",{type:"checkbox",className:"w-4 h-4 accent-yellow-400",checked:i[c],onChange:w=>a(B=>({...B,[c]:w.target.checked}))}),s.jsx("span",{className:"text-sm text-text-secondary",children:u})]},c))}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"rounded-lg border border-card-border bg-bg-primary px-6 py-2.5 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",disabled:!i.terms||!i.original||!i.privacy,onClick:()=>n(1),className:"rounded-lg bg-yellow-400 px-6 py-2.5 text-sm font-semibold text-black hover:bg-yellow-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept & Create Project"})]})]})}),r===1&&s.jsxs("form",{className:"w-full mx-auto space-y-6",children:[s.jsxs("div",{className:"bg-bg-secondary border border-card-border rounded-xl p-4 md:p-6",children:[s.jsx("h2",{className:"text-lg font-bold text-text-primary mb-5",children:"Project Details"}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsxs("div",{className:"flex-1 space-y-4 order-2 md:order-1",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-text-primary text-sm mb-2",children:["Project Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(z,{name:"projectName",control:d,rules:{required:"Project Name is required"},render:({field:c})=>s.jsxs(s.Fragment,{children:[s.jsx("input",{...c,type:"text",placeholder:"Enter movie title",className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border px-3 py-3 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent"}),y.projectName&&s.jsx("p",{className:"text-red-500 text-xs mt-1",children:typeof y.projectName.message=="string"?y.projectName.message:String(y.projectName)})]})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 md:gap-4",children:[s.jsx(pe,{name:"genre",label:"Genre",required:!0,control:d,rules:{required:"Genre is required"},options:[{value:"Action",label:"Action"},{value:"Adventure",label:"Adventure"},{value:"Comedy",label:"Comedy"},{value:"Drama",label:"Drama"},{value:"Fantasy",label:"Fantasy"},{value:"Horror",label:"Horror"},{value:"Musical",label:"Musical"},{value:"Mystery",label:"Mystery"},{value:"Romance",label:"Romance"},{value:"Sci-Fi",label:"Sci-Fi"},{value:"Thriller",label:"Thriller"},{value:"Western",label:"Western"}]}),s.jsx(pe,{name:"language",label:"Language",rules:{required:"Language is required"},required:!0,control:d,options:[{value:"English",label:"English"},{value:"Hindi",label:"Hindi"},{value:"Tamil",label:"Tamil"},{value:"Telugu",label:"Telugu"}]}),s.jsx(Gr,{name:"type",label:"Type",rules:{required:"Type is required"},required:!0,control:d,options:p,onCustomValueAdd:c=>{p.find(u=>u.value===c)||H([...p,{value:c,label:c}])}})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-text-primary text-sm mb-2",children:["Logline ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(z,{name:"logline",control:d,rules:{required:"Logline is required"},render:({field:c})=>s.jsxs(s.Fragment,{children:[s.jsx("textarea",{...c,placeholder:"Enter a one-sentence summary of your story that captures the essence, main character, and central conflict...",rows:4,className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border p-3.5 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent resize-none"}),y.logline&&s.jsx("p",{className:"text-red-500 text-xs mt-1",children:typeof y.logline.message=="string"?y.logline.message:String(y.logline)})]})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-text-primary text-sm mb-2",children:"Synopsis"}),s.jsx(z,{name:"synopsis",control:d,render:({field:c})=>s.jsxs(s.Fragment,{children:[s.jsx("textarea",{...c,placeholder:"Enter the synopsis including basic premise, character point of view, and feel of the story...",rows:4,className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border p-3.5 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent resize-none"}),y.synopsis&&s.jsx("p",{className:"text-red-500 text-xs mt-1",children:typeof y.synopsis.message=="string"?y.synopsis.message:String(y.synopsis)})]})})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 md:gap-4",children:[s.jsx(pe,{name:"projectStatus",label:"Project Status",rules:{required:"Project Status is required"},required:!0,control:d,options:[{value:"In Progress",label:"In Progress"},{value:"Completed",label:"Completed"},{value:"Pre-Production",label:"Pre-Production"},{value:"Post-Production",label:"Post-Production"}]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-text-primary text-sm mb-2",children:"Run Time (min)"}),s.jsx(z,{name:"runTime",control:d,rules:{validate:c=>{const u=String(c??"").trim();return u===""?!0:/^\d+$/.test(u)||"Only numbers allowed"}},render:({field:c})=>s.jsxs(s.Fragment,{children:[s.jsx("input",{...c,type:"text",placeholder:"175",className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border p-3 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent"}),y.runTime&&s.jsx("p",{className:"text-red-500 text-xs mt-1",children:typeof y.runTime.message=="string"?y.runTime.message:String(y.runTime)})]})})]}),s.jsx(pe,{name:"audienceType",label:"Audience Type",control:d,options:[{value:"General",label:"General"},{value:"Kids",label:"Kids"},{value:"Teens",label:"Teens"},{value:"Adults",label:"Adults"}]}),s.jsx(pe,{name:"primaryPurpose",label:"Primary Purpose",control:d,options:[{value:"For Distribution",label:"For Distribution"},{value:"For Financing",label:"For Financing"},{value:"For Script Reviewing",label:"For Script Reviewing"},{value:"For Connect with Producers",label:"For Connect with Producers"},{value:"For Exhibition",label:"For Exhibition"},{value:"For Co-Production",label:"For Co-Production"},{value:"For Talent Discovery",label:"For Talent Discovery"}]})]})]}),s.jsxs("div",{className:"lg:w-auto flex-shrink-0 order-1 md:order-2",children:[s.jsx("label",{className:"block text-text-primary text-sm mb-2",children:"Upload Poster"}
15),s.jsx(z,{name:"poster_image",control:d,render:({field:{onChange:c,value:u,...w}})=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{onClick:()=>{var B;return(B=document.getElementById("poster-upload"))==null?void 0:B.click()},className:"border-2 border-dashed border-card-border rounded-lg w-[150px] h-[225px] flex flex-col items-center justify-center bg-[#0d1117] cursor-pointer hover:border-gray-300 border-border-color transition-colors relative overflow-hidden",children:[u&&u[0]?s.jsx("img",{src:URL.createObjectURL(u[0]),alt:"Poster preview",className:"w-full h-full object-cover"}):s.jsxs("div",{className:"text-center p-2",children:[s.jsx("div",{className:"mb-2",children:s.jsx("svg",{className:"w-12 h-12 mx-auto text-text-tertiary",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V5a2 2 0 00-2-2H4zm12 12H4l4-8 3 6 2-4 3 6z",clipRule:"evenodd"})})}),s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Click to upload Poster"}),s.jsx("p",{className:"text-text-tertiary text-[10px]",children:"jpeg,jpg,png"}),s.jsx("p",{className:"text-text-tertiary text-[10px]",children:"Image Size: 1200*800"})]}),s.jsx("input",{...w,id:"poster-upload",type:"file",accept:"image/jpeg,image/jpg,image/png",onChange:B=>{c(B.target.files)},className:"hidden"})]}),y.poster_image&&s.jsx("p",{className:"text-red-500 text-xs mt-1",children:typeof y.poster_image.message=="string"?y.poster_image.message:String(y.poster_image)})]})})]})]})]}),s.jsxs("div",{className:"bg-bg-secondary border border-card-border rounded-xl p-4 md:p-6",children:[s.jsx("h2",{className:"text-lg font-bold text-text-primary mb-1",children:"Upload Script"}),s.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Upload your script file to enable AI-powered analysis and character extraction"}),s.jsx(z,{name:"scriptFile",control:d,render:({field:{onChange:c,value:u}})=>s.jsxs("div",{onClick:()=>{var w;return(w=document.getElementById("script-upload-input"))==null?void 0:w.click()},className:"flex flex-col items-center justify-center min-h-[160px] rounded-lg border border-dashed border-card-border bg-bg-primary cursor-pointer hover:border-yellow-400/50 transition-colors p-6",children:[s.jsx("input",{id:"script-upload-input",type:"file",accept:".pdf,.txt,.doc,.docx",className:"hidden",onChange:w=>c(w.target.files)}),s.jsx("div",{className:"w-10 h-10 rounded-lg bg-bg-secondary flex items-center justify-center mb-3",children:s.jsx("svg",{className:"w-5 h-5 text-text-secondary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})})}),u&&u[0]?s.jsx("p",{className:"text-sm font-medium text-yellow-400",children:u[0].name}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm font-medium text-text-secondary",children:"Click to upload your script or drag and drop"}),s.jsx("p",{className:"text-xs text-text-secondary mt-1",children:".PDF, .TXT, .DOC, .DOCX files only. Please ensure script is properly formatted."})]})]})}),s.jsxs("div",{className:"mt-3 flex items-start gap-2 p-3 bg-yellow-400/5 border border-yellow-400/20 rounded-lg",children:[s.jsx("span",{className:"text-yellow-400 text-sm mt-0.5",children:"â¹"}),s.jsx("p",{className:"text-xs text-text-secondary",children:"Uploading a script enables automatic character extraction and AI-powered analysis. You can also skip this step and upload later from the project details page."})]})]}),s.jsxs("div",{className:"flex justify-end gap-4 pb-8",children:[s.jsx("button",{type:"button",onClick:P,className:"rounded-lg border border-card-border bg-bg-secondary py-2.5 px-8 text-text-primary hover:bg-bg-tertiary transition-colors font-medium",children:"Back"}),s.jsx("button",{type:"button",onClick:Ut,disabled:!I,className:`rounded-lg py-2.5 px-8 font-medium transition-colors ${I?"bg-yellow-400 text-black hover:bg-yellow-500":"bg-gray-600 text-text-tertiary cursor-not-allowed"}`,children:"Next"})]})]}),r===2&&s.jsxs("div",{className:"max-w-7xl mx-auto",children:[s.jsx("div",{className:"mb-6 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:s.jsxs("p",{className:"text-text-secondary text-sm leading-relaxed",children:[s.jsx("span",{className:"font-semibold text-accent-light",children:"ð¡ Tip:"})," Add the crew or team members behind your project. Include producers, directors, writers, actors, and other key personnel with their roles, IMDb profiles, and photos to showcase the talent involved in your project."]})}),s.jsx("div",{className:"mb-4 flex justify-end",children:s.jsx("button",{type:"button",onClick:()=>ke(c=>!c),className:"px-4 py-2 rounded-lg bg-yellow-500 text-black font-semibold hover:bg-yellow-600 transition-colors",children:Ee?"Cancel":"+ Add Cast"})}),Ee&&s.jsx("div",{className:"bg-[#1a1a1a] border border-card-border rounded-lg p-6 mb-6 ",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_1fr_1fr_1fr_auto] gap-3 md:gap-4 items-end",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-text-primary text-sm mb-2",children:["Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(z,{name:"tempName",control:d,render:({field:c})=>s.jsx("input",{...c,type:"text",placeholder:"Name",className:"w-full rounded-lg bg-[#0d0d0d] border border-card-border p-3 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent"})})]}),s.jsx(pe,{name:"tempRole",label:"Role",required:!0,control:d,options:[{value:"Producer",label:"Producer"},{value:"Writer",label:"Writer"},{value:"Director",label:"Director"},{value:"Actor",label:"Actor"},{value:"Cinematographer",label:"Cinematographer"}]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-text-primary text-sm mb-2",children:"IMDB URL"}),s.jsx(z,{name:"tempImdbUrl",control:d,rules:{validate:c=>{if(!c||c.trim()==="")return!0;const u=c.trim();let w=u;!u.startsWith("http://")&&!u.startsWith("https://")&&(w=`https://${u}`);try{const F=new URL(w).hostname.toLowerCase();return F==="imdb.com"||F==="www.imdb.com"||F.endsWith(".imdb.com")?!0:"Please enter a valid IMDb URL (e.g., https://www.imdb.com/name/nm1234567)"}catch{return"Please enter a valid IMDb URL (e.g., https://www.imdb.com/name/nm1234567)"}}},render:({field:c})=>s.jsxs(s.Fragment,{children:[s.jsx("input",{...c,type:"text",placeholder:"",className:"w-full rounded-lg bg-[#0d0d0d] border border-card-border p-3 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent"}),(y==null?void 0:y.tempImdbUrl)&&s.jsx("p",{className:"text-red-500 text-xs mt-1",children:typeof y.tempImdbUrl.message=="string"?y.tempImdbUrl.message:"Invalid IMDb URL"})]})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-text-primary text-sm mb-2",children:"Upload Photo"}
15),s.jsx(z,{name:"tempPhoto",control:d,render:({field:{onChange:c,value:u}})=>{var w;return s.jsxs("div",{className:"relative w-full",children:[s.jsx("input",{id:"temp-photo-input",type:"file",accept:"image/jpeg,image/jpg,image/png",className:"hidden",onChange:B=>c(B.target.files)}),s.jsxs("div",{className:"flex rounded-lg bg-[#0d0d0d] border border-card-border h-12 items-center cursor-pointer p-0.5",onClick:()=>{var B;return(B=document.getElementById("temp-photo-input"))==null?void 0:B.click()},children:[s.jsx("button",{type:"button",className:"bg-[#444] text-text-primary px-6 h-full rounded-l-lg text-base font-medium",style:{minWidth:90},children:"Select"}),s.jsx("span",{className:"ml-3 truncate text-xs text-text-tertiary",children:((w=u==null?void 0:u[0])==null?void 0:w.name)??""})]})]})}})]}),s.jsx("button",{type:"button",onClick:et,className:"rounded-lg bg-[#fbbf24] px-8 text-black font-medium hover:bg-[#f59e0b] transition-colors h-[46px]",children:"Add"})]})}),j.length>0&&s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mb-6",children:j.map((c,u)=>s.jsxs("div",{className:"bg-[#1a1a1a] border border-card-border rounded-lg p-4 relative",children:[s.jsx("button",{type:"button",onClick:()=>Re(u),className:"absolute top-2 right-2 text-red-500 hover:text-red-400 transition-colors",children:s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-full overflow-hidden bg-[#222] flex items-center justify-center flex-shrink-0",children:c.avatar?s.jsx("img",{src:c.avatar,alt:c.name,className:"w-full h-full object-cover"}):s.jsx(Kt,{className:"w-6 h-6 text-text-tertiary"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-text-primary font-medium text-sm truncate",title:c.name,children:c.name}),s.jsx("p",{className:"text-text-tertiary text-xs truncate",children:c.role}),c.imdbUrl&&s.jsx("a",{href:c.imdbUrl,target:"_blank",rel:"noopener noreferrer",className:"text-accent-text text-xs hover:underline truncate block mt-1",children:"IMDb Profile"})]})]})]},u))}),s.jsxs("div",{className:"flex justify-end gap-4 mt-8",children:[s.jsx("button",{type:"button",onClick:P,className:"rounded-lg border border-card-border bg-bg-secondary py-2.5 px-8 text-text-primary hover:bg-bg-tertiary transition-colors font-medium",children:"Back"}),s.jsx("button",{type:"button",onClick:async()=>{if(j.length>0&&f)try{await ye.editProject({projectId:f,castAndCrewInfo:j}),k.success("Team saved successfully")}catch{k.error("Failed to save team")}t()},className:"rounded-lg bg-yellow-400 py-2.5 px-8 text-black hover:bg-yellow-500 transition-colors font-medium",children:"Finish"})]})]}),r===4&&s.jsx("div",{className:"max-w-7xl mx-auto",children:s.jsxs("div",{className:"bg-[#18181b] rounded-xl p-6",children:[s.jsxs("div",{className:"mb-6 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Characters"}),s.jsx("p",{className:"text-sm text-text-tertiary",children:"Add characters and map them to cast members"})]}),s.jsx("button",{type:"button",onClick:()=>ie(!re),className:"px-4 py-2 rounded-lg bg-yellow-500 text-black font-semibold hover:bg-yellow-600 transition-colors",children:re?"Cancel":"+ Add Character"})]}),!re&&s.jsx("div",{className:"mb-6 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:s.jsxs("p",{className:"text-text-secondary text-sm leading-relaxed",children:[s.jsx("span",{className:"font-semibold text-accent-light",children:"ð¡ Tip:"}),' You can also generate characters from script analysis. After uploading your script, go to the project details page and use the "Characters" tab to extract characters automatically from your script.']})}),re&&s.jsxs("div",{className:"mb-6 bg-[#1a1a1a] border border-card-border rounded-lg p-6",children:[s.jsx("h3",{className:"text-lg font-semibold text-text-primary mb-4",children:"Add New Character"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-text-primary text-sm mb-2",children:["Character Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(z,{name:"characterName",control:d,rules:{required:"Character name is required"},render:({field:c})=>s.jsx("input",{...c,type:"text",placeholder:"Name of character",className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border px-3 py-2 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent h-9"})})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-text-primary text-sm mb-2",children:["Gender ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(z,{name:"characterGender",control:d,rules:{required:"Gender is required"},render:({field:c})=>s.jsxs("select",{...c,className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border px-3 py-2 text-text-primary focus:outline-none focus:ring-2 focus:ring-yellow-500 h-9",children:[s.jsx("option",{value:"",children:"Select"}),s.jsx("option",{value:"male",children:"Male"}),s.jsx("option",{value:"female",children:"Female"}),s.jsx("option",{value:"unknown",children:"Unknown"})]})})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-text-primary text-sm mb-2",children:["Age ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(z,{name:"characterAge",control:d,rules:{required:"Age is required"},render:({field:c})=>s.jsxs("select",{...c,className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border px-3 py-2 text-text-primary focus:outline-none focus:ring-2 focus:ring-yellow-500 h-9",children:[s.jsx("option",{value:"",children:"Select"}),s.jsx("option",{value:"child",children:"Child"}),s.jsx("option",{value:"teen",children:"Teen"}),s.jsx("option",{value:"20s",children:"20s"}),s.jsx("option",{value:"30s",children:"30s"}),s.jsx("option",{value:"40s",children:"40s"}),s.jsx("option",{value:"50+",children:"50+"})]})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-text-primary text-sm mb-2",children:"Occurrence"}),s.jsx(z,{name:"characterOccurrence",control:d,render:({field:c})=>s.jsx("input",{...c,type:"number",placeholder:"Number of occurrences",className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border px-3 py-2 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent h-9"})})]}),s.jsxs("div",{className:"md:col-span-2",children:[s.jsx("label",{className:"block text-text-primary text-sm mb-2",children:"About / Description"}),s.jsx(z,{name:"characterAbout",control:d,render:({field:c})=>s.jsx("textarea",{...c,rows:3,placeholder:"Character description, background, etc.",className:"w-full rounded-lg bg-white dark:bg-[#121212] border border-card-border p-3.5 text-text-primary placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent resize-none"})})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-4",children:[s.jsx("button",{type:"button",onClick:()=>{ie(!1),x("characterName",""),x("characterGender",""),x("characterAge",""),x("characterOccurrence",""),x("characterAbout","")},className:"px-4 py-2 rounded-lg border border-card-border text-text-primary hover:bg-gray-200 dark:hover:bg-gray-800 transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:async()=>{const c=h("characterName"),u=h("characterGender"),w=h("characterAge"),B=h("characterOccurrence"),F=h("characterAbout");if(!c||!u||!w){k.error("Please fill in all required fields (Name, Gender, Age)");return}const q={id:`char_${Date.now()}`,name:c,gender:u,ageRange:w,description:F||void 0,occurrences:B?Number(B):void 0,extracted:!1},D=[...V,q];ne(D),X(D),x("characterName",""),x("characterGender",""),x("characterAge",""),x("characterOccurrence",""),x("characterAbout",""),ie(!1),k.success("Character added successfully")},className:"px-4 py-2 rounded-lg bg-yellow-500 text-black font-semibold hover:bg-yellow-600 transition-colors",children:"Add Character"})]})]}),V.length>0&&!re?s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsx("div",{children:s.jsx(Zr,{characters:V.filter(c=>{var w;const u=c.name.toLowerCase().includes(T.toLowerCase())||((w=c.aliases)==null?void 0:w.some(B=>B.toLowerCase().includes(T.toLowerCase())));return W==="mapped"?u&&c.mapped:W==="unmapped"?u&&!c.mapped:u}),selectedCharacter:O,onSelect:A,filter:W,onFilterChange:E,searchQuery:T,onSearchChange:he})}),s.jsx("div",{children:s.jsx(Kr,{character:O,characters:V.filter(c=>{var w;const u=c.name.toLowerCase().includes(T.toLowerCase())||((w=c.aliases)==null?void 0:w.some(B=>B.toLowerCase().includes(T.toLowerCase())));return W==="mapped"?u&&c.mapped:W==="unmapped"?u&&!c.mapped:u}),mapping:O?_.find(c=>c.characterId===O.id||c.id===O.mappingId):void 0,onCharacterSelect:A,onSave:async c=>{if(!O){k.error("Please select a character first");return}const u=O.mappingId||`map_${Date.now()}`,w={id:u,projectId:f||e,actorName:c.actorName,role:c.role,imdbUrl:c.imdbUrl},B=_.findIndex(D=>D.id===u);let F;B>=0?F=_.map(D=>D.id===u?w:D):F=[..._,w],$(F),ve(F);const q=V.map(D=>D.id===O.id?{...D,mapped:!0,mappingId:u,mappingObject:{actorName:c.actorName,role:c.role,imdbUrl:c.imdbUrl,photoUrl:c.photoUrl??""}}:D);ne(q),X(q),A({...O,mapped:!0,mappingId:u,mappingObject:{actorName:c.actorName,role:c.role}}),k.success(`Mapping saved: ${O.name} â ${c.actorName}`)},onDelete:O!=null&&O.mappingId?async()=>
15{if(O!=null&&O.mappingId)try{if(f)try{await fe.scriptWriters.deleteMapping(f,O.mappingId)}catch(w){console.warn("API delete failed, removing from sessionStorage only:",w)}const c=_.filter(w=>w.id!==O.mappingId);$(c),ve(c);const u=V.map(w=>w.id===O.id?{...w,mapped:!1,mappingId:void 0}:w);ne(u),X(u),A({...O,mapped:!1,mappingId:void 0}),k.success("Mapping deleted successfully")}catch{k.error("Failed to delete mapping")}}:void 0,projectId:f||e})})]}):null,s.jsxs("div",{className:"flex justify-end gap-4 mt-8",children:[s.jsx("button",{type:"button",onClick:P,className:"rounded-lg bg-[#374151] py-2.5 px-8 text-text-primary hover:bg-[#4b5563] transition-colors font-medium",children:"Back"}),s.jsx("button",{type:"button",onClick:()=>{Ct(),k.success("Project setup completed!"),t()},className:"rounded-lg bg-[#fbbf24] py-2.5 px-8 text-black hover:bg-[#f59e0b] transition-colors font-medium",children:"Finish"})]})]})})]})};function es({data:t,loading:e}){const r=U.useMemo(()=>{const n=t.filter(l=>(l.projectStatus||"").toLowerCase()==="draft"||!l.projectStatus).length,i=t.filter(l=>{const m=(l.status||"").toLowerCase();return m==="in progress"||m==="pre-production"||m==="post-production"}).length,a=t.filter(l=>(l.projectStatus||"").toLowerCase()==="published").length,f=t.reduce((l,m)=>{var d;return l+(Array.isArray(m==null?void 0:m.castAndCrewInfo)?(d=m==null?void 0:m.castAndCrewInfo)==null?void 0:d.length:0)},0);return[{icon:"/scriptwriter/dashboard/Overlay.svg",label:"Draft Projects",value:n},{icon:"/scriptwriter/dashboard/Overlay1.svg",label:"In Production",value:i},{icon:"/scriptwriter/dashboard/Overlay2.svg",label:"Published",value:a},{icon:"/scriptwriter/dashboard/Overlay2.svg",label:"Total Cast",value:f}]},[t]);return e?s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 my-6 w-full",children:[...Array(4)].map((n,i)=>s.jsxs("div",{className:"bg-bg-secondary rounded-xl p-5 border border-card-border animate-pulse",children:[s.jsx("div",{className:"h-8 w-12 bg-[#333] rounded mb-2"}),s.jsx("div",{className:"h-4 w-24 bg-[#333] rounded"})]},i))}):!t||(t==null?void 0:t.length)===0?null:s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-8 w-full",children:r.map((n,i)=>s.jsxs("div",{className:"bg-bg-secondary rounded-xl p-5 flex items-center justify-between border border-card-border",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-4xl font-bold text-text-primary",children:n.value}),s.jsx("div",{className:"text-text-secondary text-sm mt-1",children:n.label})]}),s.jsx("div",{className:"w-12 h-12 rounded-lg bg-bg-tertiary flex items-center justify-center flex-shrink-0",children:s.jsx("img",{src:n.icon,alt:n.label,className:"h-7 w-7 object-contain opacity-80"})})]},i))})}const ts={Comedy:"text-yellow-400","Sci-Fi":"text-blue-400",Romance:"text-purple-400",Drama:"text-yellow-300",Horror:"text-red-400",Adventure:"text-green-400",Action:"text-orange-400",Thriller:"text-pink-400",Fantasy:"text-indigo-400",Mystery:"text-cyan-400",Musical:"text-rose-400",Western:"text-amber-400"},rs="text-yellow-400",ss={draft:"draft",under_review:"Under Review",expert_review:"Evaluation",approved:"Approved",published:"published"};function ns(t){return ss[t]||t}function is(t){return t==="published"?"bg-green-500/90 text-white":"bg-[#1a1a1a]/80 text-yellow-400 border border-yellow-400/30"}function os({data:t,loading:e,onOpenCreate:r}){const n=Ft(),[i,a]=U.useState("All");if(e)return s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mt-6",children:[...Array(6)].map((d,b)=>s.jsxs("div",{className:"rounded-2xl border border-card-border bg-bg-secondary overflow-hidden animate-pulse",children:[s.jsx("div",{className:"aspect-[16/9] w-full bg-[#222]"}),s.jsxs("div",{className:"p-4 space-y-2",children:[s.jsx("div",{className:"h-5 w-3/4 bg-[#333] rounded"}),s.jsx("div",{className:"h-4 w-1/2 bg-[#2a2a2a] rounded"})]})]},b))});if(!t||t.length===0)return s.jsx("div",{className:"flex justify-center my-8 w-full",children:s.jsx("p",{className:"text-text-secondary",children:"No projects available"})});const l=["All","Draft","Published",...Array.from(new Set(t.map(d=>
15d.genre).filter(Boolean)))],m=t.filter(d=>i==="All"?!0:i==="Draft"?(d.projectStatus||"").toLowerCase()==="draft"||!d.projectStatus:i==="Published"?(d.projectStatus||"").toLowerCase()==="published":(d.genre||"").toLowerCase()===i.toLowerCase());return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("div",{children:s.jsx("h2",{className:"text-xl font-bold text-text-primary",children:"All Projects"})}),s.jsxs("span",{className:"text-sm text-text-secondary",children:[t.length," projects"]})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-6 overflow-x-auto pb-1 scrollbar-hide",children:[s.jsx("span",{className:"text-xs text-text-secondary font-medium mr-1 shrink-0",children:"FILTER"}),l.map(d=>s.jsx("button",{onClick:()=>a(d),className:`shrink-0 rounded-full px-4 py-1.5 text-sm font-medium transition-colors ${i===d?"bg-yellow-400 text-black":"bg-bg-secondary text-text-secondary border border-card-border hover:border-yellow-400/40"}`,children:d},d))]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 md:gap-5",children:[m.map(d=>{const b=d._id,h=d.name??"Untitled",x=d.description??"",v=d.runTime?`${d.runTime} min`:null,R=d.createdAt?new Date(d.createdAt).toLocaleDateString("en-IN",{day:"2-digit",month:"short",year:"numeric"}):null,y=ns(d.projectStatus||"draft"),I=ts[d.genre??""]??rs;return s.jsxs("div",{role:"button",tabIndex:0,className:"group cursor-pointer overflow-hidden rounded-2xl border border-card-border bg-bg-secondary transition-all duration-200 hover:border-amber-400/40 hover:shadow-[0_8px_24px_rgba(0,0,0,0.4)]",onClick:()=>n(`/sw/project/${b}`),onKeyDown:P=>{P.key==="Enter"&&n(`/sw/project/${b}`)},children:[s.jsxs("div",{className:"relative aspect-[16/9] w-full overflow-hidden",children:[s.jsx(Qt,{src:d==null?void 0:d.posterUrl,alt:h,className:"absolute inset-0 h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]"}),s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent"}),s.jsx("span",{className:`absolute top-3 right-3 rounded-md px-2.5 py-0.5 text-xs font-semibold ${is(d.projectStatus||"draft")}`,children:y}),s.jsx("div",{className:"absolute bottom-3 left-3 w-7 h-7 rounded bg-black/50 flex items-center justify-center",children:s.jsx("img",{src:"/scriptwriter/dashboard/Overlay.svg",alt:"",className:"w-4 h-4 opacity-70"})})]}),s.jsxs("div",{className:"p-4 space-y-1.5",children:[s.jsx("h3",{className:`text-base font-bold line-clamp-1 ${I}`,children:h}),x&&s.jsx("p",{className:"text-xs text-text-secondary line-clamp-1",children:x}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-secondary pt-0.5",children:[v&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(er,{size:11}),v]}),R&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(tr,{size:11}),R]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap text-xs pt-0.5",children:[d.genre&&s.jsx("span",{className:`font-semibold ${I}`,children:d.genre}),d.type&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-secondary",children:"â¢"}),s.jsx("span",{className:"text-text-secondary",children:d.type})]}),d.status&&s.jsx(s.Fragment,{children:s.jsx("span",{className:"text-text-secondary ml-auto",children:d.status})})]})]})]},b)}),r&&s.jsxs("div",{role:"button",tabIndex:0,onClick:r,onKeyDown:d=>{d.key==="Enter"&&r()},className:"cursor-pointer rounded-2xl border border-dashed border-card-border bg-bg-secondary/50 flex flex-col items-center justify-center min-h-[220px] gap-3 hover:border-yellow-400/50 hover:bg-bg-secondary transition-all duration-200 group",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-yellow-400/10 group-hover:bg-yellow-400/20 flex items-center justify-center transition-colors",children:s.jsx(rr,{size:20,className:"text-yellow-400"})}),s.jsx("span",{className:"text-sm font-medium text-text-secondary group-hover:text-text-primary transition-colors",children:"New Project"})]})]})]})}const Le=({imgSrc:t,title:e,desc:r,hasBorder:n=!0})=>
15s.jsxs("div",{className:`flex items-start gap-4 rounded-xl bg-transparent border dark:border-none dark:bg-[#0E0E0E] ${n?"border border-[#22252b]":""} p-4 shadow-sm hover:shadow transition`,children:[s.jsx("img",{src:t,alt:e,className:"h-16 w-16 object-contain"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold text-black dark:text-[#BDBDBD]",children:e}),s.jsx("div",{className:"mt-1 text-xs text-black dark:text-white leading-5",children:r})]})]});function as({onOpenCreate:t,username:e}){const r="/scriptwriter/dashboard";return s.jsx("div",{className:"w-full flex items-center justify-center",children:s.jsxs("div",{className:"w-full max-w-5xl px-6 py-12 text-center",children:[s.jsxs("h1",{className:"text-3xl md:text-[40px] font-extrabold text-text-primary",children:["Welcome ",e]}),s.jsx("p",{className:"mt-4 text-sm md:text-base text-text-secondary dark:text-neutral-300 leading-7",children:"Your ideas deserve the spotlight. RecoBee helps you secure, analyze, and showcase your script to verified studios."}),s.jsxs("div",{className:"mt-8 grid grid-cols-1 sm:grid-cols-2 gap-5",children:[s.jsx(Le,{imgSrc:`${r}/upload-script.svg`,title:"Upload Your Scripts/Trailers",desc:"Start with your original story â fully encrypted and NDAâprotected.",hasBorder:!1}),s.jsx(Le,{imgSrc:`${r}/get-projects.svg`,title:"Get Projects Insights",hasBorder:!1,desc:"RecoBeeâs AI analyses your story for structure, tone, and audience sentiment."}),s.jsx(Le,{imgSrc:`${r}/get-discover.svg`,title:"Get Discovered",hasBorder:!1,desc:"Want professional validation before you pitch?"}),s.jsx(Le,{imgSrc:`${r}/focus-review.svg`,title:"Focus Review (Expert Panel)",hasBorder:!1,desc:"Showcase your project to verified producers and studios."})]}),s.jsxs("div",{className:"mt-10 text-xs text-text-primary",children:["Your first project setup takes less than 2 minutes.",s.jsx("br",{}),"Youâll stay in control every step of the way."]}),s.jsx("button",{type:"button",onClick:t,className:"mt-5 inline-flex items-center justify-center rounded-lg bg-[#fbbf24] px-6 py-3 text-base font-bold text-black hover:bg-[#f59e0b] transition",children:"Create First Project"}),s.jsxs("div",{className:"mt-8 flex flex-wrap items-center justify-center gap-6 text-[12px] text-text-primary",children:[s.jsx("span",{className:"inline-flex items-center gap-2",children:"ð NDA Protected"}),s.jsx("span",{className:"w-1 h-1 bg-white text-text-primary rounded-full bg-current inline-block","aria-hidden":"true"}),s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx("span",{className:"",children:"ð"}),"256âbit Encryption"]}),s.jsx("span",{className:"w-1 h-1 bg-white text-text-primary rounded-full bg-current inline-block","aria-hidden":"true"}),s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx("span",{className:"",children:"ð¬"}),"Verified Studios"]}),s.jsx("span",{className:"w-1 h-1 bg-white text-text-primary rounded-full bg-current inline-block","aria-hidden":"true"}),s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx("span",{children:"âï¸"}),"Fair Use Commitment"]})]})]})})}function Rs(){var x,v,R,y,I,P;const{userId:t,userName:e}=bt(),[r,n]=U.useState(!1),i=()=>{n(!1)},[a,f]=U.useState(null),[l,m]=U.useState(!1),d=async j=>{m(!0),await ye.getProjects({setLoading:m,setProjects:f,userId:j})};U.useEffect(()=>{t&&d(t)},[t,r]);const b=(((v=(x=a==null?void 0:a.result)==null?void 0:x.projects)==null?void 0:v.length)??0)===0,h=((y=(R=a==null?void 0:a.result)==null?void 0:R.projects)==null?void 0:y.length)??0;return l||a===null?s.jsx("div",{className:"flex items-center justify-center min-h-screen",children:s.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-b-2 border-gray-900"})}):s.jsxs("div",{children:[r&&s.jsx(Qr,{onClose:i}),!l&&b&&!r?s.jsx(as,{username:e||t||"User",onOpenCreate:()=>n(!0)}):s.jsx(s.Fragment,{children:!r&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-yellow-400 inline-block"}),s.jsxs("span",{className:"text-sm text-text-secondary font-medium",children:[h," Active Projects"]})]}),s.jsx("h1",{className:"text-4xl font-extrabold text-text-primary mb-2",children:"Your Script Portfolio"}),s.jsx("p",{className:"text-text-secondary text-base",children:"Manage, track, and showcase your creative projects"})]}),s.jsxs("button",{className:"flex items-center gap-2 rounded-lg border border-card-border bg-bg-secondary px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:[s.jsx(nr,{size:15}),"Filter"]})]}),s.jsx(es,{data:(I=a==null?void 0:a.result)==null?void 0:I.projects,loading:l}),s.jsx(os,{data:(P=a==null?void 0:a.result)==null?void 0:P.projects,loading:l,onOpenCreate:()=>n(!0)})]})})]})}export{Rs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.