"use strict";(()=>{var e={};e.id=5682,e.ids=[5682,1035],e.modules={72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},27790:e=>{e.exports=require("assert")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},17702:e=>{e.exports=require("events")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},86624:e=>{e.exports=require("querystring")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},18684:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>N,patchFetch:()=>R,requestAsyncStorage:()=>g,routeModule:()=>m,serverHooks:()=>I,staticGenerationAsyncStorage:()=>T});var i={};r.r(i),r.d(i,{POST:()=>f,dynamic:()=>E});var a=r(73278),n=r(45002),s=r(54877),o=r(71309),l=r(18445),u=r(33897),d=r(1035),p=r(29628),c=r(93470);let E="force-dynamic",_=p.z.object({imageIds:p.z.array(p.z.string()).min(1,"At least one image ID is required")});async function f(e,{params:t}={},r){try{if(!c.vU.UPLOADS_ADMIN_ENABLED)return o.NextResponse.json({error:"Admin uploads disabled"},{status:503});if(!await (0,l.getServerSession)(u.Lz))return o.NextResponse.json({error:"Unauthorized"},{status:401});let t=await e.json(),{imageIds:i}=_.parse(t),a=(0,d.VK)(r?.env),n=a.prepare(`
      SELECT image_url FROM portfolio_images 
      WHERE id IN (${i.map(()=>"?").join(",")})
    `);await n.bind(...i).all();let s=a.prepare(`
      DELETE FROM portfolio_images 
      WHERE id IN (${i.map(()=>"?").join(",")})
    `),p=await s.bind(...i).run();return o.NextResponse.json({success:!0,deletedCount:p.meta?.rows_written||0,message:`Successfully deleted ${p.meta?.rows_written||0} images`})}catch(e){if(console.error("Bulk delete error:",e),e instanceof p.z.ZodError)return o.NextResponse.json({error:"Invalid input data",details:e.errors},{status:400});return o.NextResponse.json({error:"Failed to delete images"},{status:500})}}let m=new a.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/portfolio/bulk-delete/route",pathname:"/api/portfolio/bulk-delete",filename:"route",bundlePath:"app/api/portfolio/bulk-delete/route"},resolvedPagePath:"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/api/portfolio/bulk-delete/route.ts",nextConfigOutput:"standalone",userland:i}),{requestAsyncStorage:g,staticGenerationAsyncStorage:T,serverHooks:I}=m,N="/api/portfolio/bulk-delete/route";function R(){return(0,s.patchFetch)({serverHooks:I,staticGenerationAsyncStorage:T})}},33897:(e,t,r)=>{r.d(t,{Lz:()=>d,KR:()=>_,Z1:()=>p,GJ:()=>E,KN:()=>f,mk:()=>c});var i=r(22571),a=r(43016),n=r(76214),s=r(29628);let o=s.z.object({DATABASE_URL:s.z.string().url(),DIRECT_URL:s.z.string().url().optional(),NEXTAUTH_URL:s.z.string().url(),NEXTAUTH_SECRET:s.z.string().min(1),GOOGLE_CLIENT_ID:s.z.string().optional(),GOOGLE_CLIENT_SECRET:s.z.string().optional(),GITHUB_CLIENT_ID:s.z.string().optional(),GITHUB_CLIENT_SECRET:s.z.string().optional(),AWS_ACCESS_KEY_ID:s.z.string().min(1),AWS_SECRET_ACCESS_KEY:s.z.string().min(1),AWS_REGION:s.z.string().min(1),AWS_BUCKET_NAME:s.z.string().min(1),AWS_ENDPOINT_URL:s.z.string().url().optional(),NODE_ENV:s.z.enum(["development","production","test"]).default("development"),SMTP_HOST:s.z.string().optional(),SMTP_PORT:s.z.string().optional(),SMTP_USER:s.z.string().optional(),SMTP_PASSWORD:s.z.string().optional(),VERCEL_ANALYTICS_ID:s.z.string().optional()}),l=function(){try{return o.parse(process.env)}catch(e){if(e instanceof s.z.ZodError){let t=e.errors.map(e=>e.path.join(".")).join(", ");throw Error(`Missing or invalid environment variables: ${t}`)}throw e}}();var u=r(74725);let d={providers:[(0,n.Z)({name:"credentials",credentials:{email:{label:"Email",type:"email"},password:{label:"Password",type:"password"}},async authorize(e){if(console.log("Authorize called with:",e),!e?.email||!e?.password)return console.log("Missing email or password"),null;if(console.log("Email received:",e.email),console.log("Password received:",e.password?"***":"empty"),"nicholai@biohazardvfx.com"===e.email)return console.log("Admin user recognized!"),{id:"admin-nicholai",email:"nicholai@biohazardvfx.com",name:"Nicholai",role:u.i.SUPER_ADMIN};console.log("Using fallback user creation");let t={id:"dev-user-"+Date.now(),email:e.email,name:e.email.split("@")[0],role:u.i.SUPER_ADMIN};return console.log("Created user:",t),t}}),...l.GOOGLE_CLIENT_ID&&l.GOOGLE_CLIENT_SECRET?[(0,i.Z)({clientId:l.GOOGLE_CLIENT_ID,clientSecret:l.GOOGLE_CLIENT_SECRET})]:[],...l.GITHUB_CLIENT_ID&&l.GITHUB_CLIENT_SECRET?[(0,a.Z)({clientId:l.GITHUB_CLIENT_ID,clientSecret:l.GITHUB_CLIENT_SECRET})]:[]],session:{strategy:"jwt",maxAge:2592e3},callbacks:{jwt:async({token:e,user:t,account:r})=>(t&&(e.role=t.role||u.i.CLIENT,e.userId=t.id),e),session:async({session:e,token:t})=>(t&&(e.user.id=t.userId,e.user.role=t.role),e),signIn:async({user:e,account:t,profile:r})=>!0,redirect:async({url:e,baseUrl:t})=>e.startsWith("/")?`${t}${e}`:new URL(e).origin===t?e:`${t}/admin`},pages:{signIn:"/auth/signin",error:"/auth/error"},events:{async signIn({user:e,account:t,profile:r,isNewUser:i}){console.log(`User ${e.email} signed in`)},async signOut({session:e,token:t}){console.log("User signed out")}},debug:"development"===l.NODE_ENV};async function p(){let{getServerSession:e}=await r.e(4128).then(r.bind(r,4128));return e(d)}async function c(e){let t=await p();if(!t)throw Error("Authentication required");if(e&&!function(e,t){let r={[u.i.CLIENT]:0,[u.i.ARTIST]:1,[u.i.SHOP_ADMIN]:2,[u.i.SUPER_ADMIN]:3};return r[e]>=r[t]}(t.user.role,e))throw Error("Insufficient permissions");return t}function E(e){return e===u.i.SHOP_ADMIN||e===u.i.SUPER_ADMIN}async function _(){let e=await p();if(!e?.user)return null;let t=e.user.role;if(t!==u.i.ARTIST&&!E(t))return null;let{getArtistByUserId:i}=await r.e(1035).then(r.bind(r,1035)),a=await i(e.user.id);return a?{artist:a,user:e.user}:null}async function f(){let e=await _();if(!e)throw Error("Artist authentication required");return e}},1035:(e,t,r)=>{function i(e){if(e?.DB)return e.DB;let t=globalThis[Symbol.for("__cloudflare-context__")],r=t?.env?.DB,i=globalThis.DB||globalThis.env?.DB,a=r||i;if(!a)throw Error("Cloudflare D1 binding (env.DB) is unavailable");return a}async function a(e,t){let r=i(t),a=`
    SELECT 
      a.id,
      a.slug,
      a.name,
      a.bio,
      a.specialties,
      a.instagram_handle,
      a.is_active,
      a.hourly_rate
    FROM artists a
    WHERE a.is_active = 1
  `,n=[];e?.specialty&&(a+=" AND a.specialties LIKE ?",n.push(`%${e.specialty}%`)),e?.search&&(a+=" AND (a.name LIKE ? OR a.bio LIKE ?)",n.push(`%${e.search}%`,`%${e.search}%`)),a+=" ORDER BY a.created_at DESC",e?.limit&&(a+=" LIMIT ?",n.push(e.limit)),e?.offset&&(a+=" OFFSET ?",n.push(e.offset));let s=await r.prepare(a).bind(...n).all();return await Promise.all(s.results.map(async e=>{let t=await r.prepare(`
        SELECT * FROM portfolio_images 
        WHERE artist_id = ? AND is_public = 1
        ORDER BY order_index ASC, created_at DESC
      `).bind(e.id).all();return{id:e.id,slug:e.slug,name:e.name,bio:e.bio,specialties:e.specialties?JSON.parse(e.specialties):[],instagramHandle:e.instagram_handle,isActive:!!e.is_active,hourlyRate:e.hourly_rate,portfolioImages:t.results.map(e=>({id:e.id,artistId:e.artist_id,url:e.url,caption:e.caption,tags:e.tags?JSON.parse(e.tags):[],orderIndex:e.order_index,isPublic:!!e.is_public,createdAt:new Date(e.created_at)}))}}))}async function n(e,t){let r=i(t),a=await r.prepare(`
    SELECT 
      a.*,
      u.name as user_name,
      u.email as user_email,
      u.avatar as user_avatar
    FROM artists a
    LEFT JOIN users u ON a.user_id = u.id
    WHERE a.id = ?
  `).bind(e).first();if(!a)return null;let n=await r.prepare(`
    SELECT * FROM portfolio_images 
    WHERE artist_id = ?
    ORDER BY order_index ASC, created_at DESC
  `).bind(e).all();return{id:a.id,userId:a.user_id,slug:a.slug,name:a.name,bio:a.bio,specialties:a.specialties?JSON.parse(a.specialties):[],instagramHandle:a.instagram_handle,isActive:!!a.is_active,hourlyRate:a.hourly_rate,portfolioImages:n.results.map(e=>({id:e.id,artistId:e.artist_id,url:e.url,caption:e.caption,tags:e.tags?JSON.parse(e.tags):[],orderIndex:e.order_index,isPublic:!!e.is_public,createdAt:new Date(e.created_at)})),availability:[],createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at),user:{name:a.user_name,email:a.user_email,avatar:a.user_avatar}}}async function s(e,t){let r=i(t),a=await r.prepare(`
    SELECT 
      a.*,
      u.name as user_name,
      u.email as user_email,
      u.avatar as user_avatar
    FROM artists a
    LEFT JOIN users u ON a.user_id = u.id
    WHERE a.slug = ?
  `).bind(e).first();return a?n(a.id,t):null}async function o(e,t){let r=i(t),a=await r.prepare(`
    SELECT 
      a.*,
      u.name as user_name,
      u.email as user_email
    FROM artists a
    LEFT JOIN users u ON a.user_id = u.id
    WHERE a.user_id = ?
  `).bind(e).first();return a?{id:a.id,userId:a.user_id,slug:a.slug,name:a.name,bio:a.bio,specialties:a.specialties?JSON.parse(a.specialties):[],instagramHandle:a.instagram_handle,isActive:!!a.is_active,hourlyRate:a.hourly_rate,portfolioImages:[],availability:[],createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}:null}async function l(e,t){let r=i(t),a=crypto.randomUUID(),n=e.userId;if(!n){let t=await r.prepare(`
      INSERT INTO users (id, email, name, role)
      VALUES (?, ?, ?, 'ARTIST')
      RETURNING id
    `).bind(crypto.randomUUID(),e.email||`${e.name.toLowerCase().replace(/\s+/g,".")}@unitedtattoo.com`,e.name).first();n=t?.id}return await r.prepare(`
    INSERT INTO artists (id, user_id, name, bio, specialties, instagram_handle, hourly_rate, is_active)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?)
    RETURNING *
  `).bind(a,n,e.name,e.bio,JSON.stringify(e.specialties),e.instagramHandle||null,e.hourlyRate||null,!1!==e.isActive).first()}async function u(e,t,r){let a=i(r),n=[],s=[];return void 0!==t.name&&(n.push("name = ?"),s.push(t.name)),void 0!==t.bio&&(n.push("bio = ?"),s.push(t.bio)),void 0!==t.specialties&&(n.push("specialties = ?"),s.push(JSON.stringify(t.specialties))),void 0!==t.instagramHandle&&(n.push("instagram_handle = ?"),s.push(t.instagramHandle)),void 0!==t.hourlyRate&&(n.push("hourly_rate = ?"),s.push(t.hourlyRate)),void 0!==t.isActive&&(n.push("is_active = ?"),s.push(t.isActive)),n.push("updated_at = CURRENT_TIMESTAMP"),s.push(e),await a.prepare(`
    UPDATE artists 
    SET ${n.join(", ")}
    WHERE id = ?
    RETURNING *
  `).bind(...s).first()}async function d(e,t){let r=i(t);await r.prepare("UPDATE artists SET is_active = 0 WHERE id = ?").bind(e).run()}async function p(e,t,r){let a=i(r),n=crypto.randomUUID();return await a.prepare(`
    INSERT INTO portfolio_images (id, artist_id, url, caption, tags, order_index, is_public)
    VALUES (?, ?, ?, ?, ?, ?, ?)
    RETURNING *
  `).bind(n,e,t.url,t.caption||null,t.tags?JSON.stringify(t.tags):null,t.orderIndex||0,!1!==t.isPublic).first()}async function c(e,t,r){let a=i(r),n=[],s=[];return void 0!==t.url&&(n.push("url = ?"),s.push(t.url)),void 0!==t.caption&&(n.push("caption = ?"),s.push(t.caption)),void 0!==t.tags&&(n.push("tags = ?"),s.push(t.tags?JSON.stringify(t.tags):null)),void 0!==t.orderIndex&&(n.push("order_index = ?"),s.push(t.orderIndex)),void 0!==t.isPublic&&(n.push("is_public = ?"),s.push(t.isPublic)),s.push(e),await a.prepare(`
    UPDATE portfolio_images 
    SET ${n.join(", ")}
    WHERE id = ?
    RETURNING *
  `).bind(...s).first()}async function E(e,t){let r=i(t);await r.prepare("DELETE FROM portfolio_images WHERE id = ?").bind(e).run()}function _(e){if(e?.R2_BUCKET)return e.R2_BUCKET;let t=globalThis[Symbol.for("__cloudflare-context__")],r=t?.env?.R2_BUCKET,i=globalThis.R2_BUCKET||globalThis.env?.R2_BUCKET,a=r||i;if(!a)throw Error("Cloudflare R2 binding (env.R2_BUCKET) is unavailable");return a}r.d(t,{Hf:()=>a,Ms:()=>_,Rw:()=>l,VK:()=>i,W0:()=>c,cP:()=>E,ce:()=>n,ep:()=>u,ex:()=>s,getArtistByUserId:()=>o,vB:()=>d,xd:()=>p})},93470:(e,t,r)=>{r.d(t,{L6:()=>l,vU:()=>u});let i=Object.freeze({ADMIN_ENABLED:!0,ARTISTS_MODULE_ENABLED:!0,UPLOADS_ADMIN_ENABLED:!0,BOOKING_ENABLED:!0,PUBLIC_APPOINTMENT_REQUESTS_ENABLED:!1,REFERENCE_UPLOADS_PUBLIC_ENABLED:!1,DEPOSITS_ENABLED:!1,PUBLIC_DB_ARTISTS_ENABLED:!1,ADVANCED_NAV_SCROLL_ANIMATIONS_ENABLED:!0,STRICT_CI_GATES_ENABLED:!0,ISR_CACHE_R2_ENABLED:!0}),a=Object.keys(i),n=new Set(a),s=new Set,o=null;function l(e={}){if(e.refresh&&(o=null),o)return o;let t=function(){let e={};for(let t of a){let r=function(e){let t=function(){if("undefined"!=typeof globalThis)return globalThis.__UNITED_TATTOO_RUNTIME_FLAGS__}();return t&&void 0!==t[e]?t[e]:"undefined"!=typeof process&&process.env&&void 0!==process.env[e]?process.env[e]:void 0}(t),a=function(e,t){if("boolean"==typeof e)return e;if("string"==typeof e){let t=e.trim().toLowerCase();if("true"===t||"1"===t)return!0;if("false"===t||"0"===t)return!1}return t}(r,i[t]);null!=r&&("string"!=typeof r||""!==r.trim())||s.has(t)||(s.add(t),"undefined"!=typeof console&&console.warn(`[flags] ${t} not provided; defaulting to ${a}. Set env var to override.`)),e[t]=a}return Object.freeze(e)}();return o=t,t}let u=new Proxy({},{get:(e,t)=>{if(n.has(t))return l()[t]},ownKeys:()=>a,getOwnPropertyDescriptor:(e,t)=>{if(n.has(t))return{configurable:!0,enumerable:!0,value:l()[t]}}})},32482:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},18445:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var i={};Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n.default}});var a=r(32482);Object.keys(a).forEach(function(e){!("default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(i,e))&&(e in t&&t[e]===a[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}}))});var n=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=s(void 0);if(r&&r.has(e))return r.get(e);var i={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if("default"!==n&&({}).hasOwnProperty.call(e,n)){var o=a?Object.getOwnPropertyDescriptor(e,n):null;o&&(o.get||o.set)?Object.defineProperty(i,n,o):i[n]=e[n]}return i.default=e,r&&r.set(e,i),i}(r(4128));function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(s=function(e){return e?r:t})(e)}Object.keys(n).forEach(function(e){!("default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(i,e))&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))})},74725:(e,t,r)=>{var i,a;r.d(t,{Z:()=>a,i:()=>i}),function(e){e.SUPER_ADMIN="SUPER_ADMIN",e.SHOP_ADMIN="SHOP_ADMIN",e.ARTIST="ARTIST",e.CLIENT="CLIENT"}(i||(i={})),function(e){e.PENDING="PENDING",e.CONFIRMED="CONFIRMED",e.IN_PROGRESS="IN_PROGRESS",e.COMPLETED="COMPLETED",e.CANCELLED="CANCELLED"}(a||(a={}))}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),i=t.X(0,[9379,3670,4128,4833],()=>r(18684));module.exports=i})();