opus-submitter/polylan_submitter/static_source/vite/assets/opus_magnum-DPEOQ6aI.js

6 lines
73 KiB
JavaScript

import{e as Ft,r as j,m as Ut,t as Bt,c as ne,i as ve,a as nt,b as us,d as ds,h as fs,f as hs,g as Vt,o as Gt,w as $e,n as Se,j as vs,k as me,l as h,p as f,q as re,s as e,u as A,v as x,F as Q,x as ee,y as I,z as Xe,A as q,B as ms,C as ce,D as Wt,E as ze,G as xe,H as gs,I as ot,J as dt,K as Ht,L as ps,M as ke,N as bs,O as ys}from"./style-D1Ozo1PL.js";/*!
* pinia v3.0.3
* (c) 2025 Eduardo San Martin Morote
* @license MIT
*/let Jt;const Ce=n=>Jt=n,Kt=Symbol();function et(n){return n&&typeof n=="object"&&Object.prototype.toString.call(n)==="[object Object]"&&typeof n.toJSON!="function"}var _e;(function(n){n.direct="direct",n.patchObject="patch object",n.patchFunction="patch function"})(_e||(_e={}));function _s(){const n=Ft(!0),a=n.run(()=>j({}));let t=[],s=[];const o=Ut({install(r){Ce(o),o._a=r,r.provide(Kt,o),r.config.globalProperties.$pinia=o,s.forEach(c=>t.push(c)),s=[]},use(r){return this._a?t.push(r):s.push(r),this},_p:t,_a:null,_e:n,_s:new Map,state:a});return o}const Yt=()=>{};function ft(n,a,t,s=Yt){n.push(a);const o=()=>{const r=n.indexOf(a);r>-1&&(n.splice(r,1),s())};return!t&&Vt()&&Gt(o),o}function he(n,...a){n.slice().forEach(t=>{t(...a)})}const ws=n=>n(),ht=Symbol(),Re=Symbol();function tt(n,a){n instanceof Map&&a instanceof Map?a.forEach((t,s)=>n.set(s,t)):n instanceof Set&&a instanceof Set&&a.forEach(n.add,n);for(const t in a){if(!a.hasOwnProperty(t))continue;const s=a[t],o=n[t];et(o)&&et(s)&&n.hasOwnProperty(t)&&!ve(s)&&!nt(s)?n[t]=tt(o,s):n[t]=s}return n}const zs=Symbol();function xs(n){return!et(n)||!Object.prototype.hasOwnProperty.call(n,zs)}const{assign:de}=Object;function ks(n){return!!(ve(n)&&n.effect)}function Ss(n,a,t,s){const{state:o,actions:r,getters:c}=a,d=t.state.value[n];let g;function y(){d||(t.state.value[n]=o?o():{});const _=vs(t.state.value[n]);return de(_,r,Object.keys(c||{}).reduce((P,$)=>(P[$]=Ut(ne(()=>{Ce(t);const u=t._s.get(n);return c[$].call(u,u)})),P),{}))}return g=Zt(n,y,a,t,s,!0),g}function Zt(n,a,t={},s,o,r){let c;const d=de({actions:{}},t),g={deep:!0};let y,_,P=[],$=[],u;const z=s.state.value[n];!r&&!z&&(s.state.value[n]={}),j({});let w;function p(N){let O;y=_=!1,typeof N=="function"?(N(s.state.value[n]),O={type:_e.patchFunction,storeId:n,events:u}):(tt(s.state.value[n],N),O={type:_e.patchObject,payload:N,storeId:n,events:u});const F=w=Symbol();Se().then(()=>{w===F&&(y=!0)}),_=!0,he(P,O,s.state.value[n])}const l=r?function(){const{state:O}=t,F=O?O():{};this.$patch(H=>{de(H,F)})}:Yt;function i(){c.stop(),P=[],$=[],s._s.delete(n)}const v=(N,O="")=>{if(ht in N)return N[Re]=O,N;const F=function(){Ce(s);const H=Array.from(arguments),oe=[],ue=[];function ge(U){oe.push(U)}function X(U){ue.push(U)}he($,{args:H,name:F[Re],store:S,after:ge,onError:X});let se;try{se=N.apply(this&&this.$id===n?this:S,H)}catch(U){throw he(ue,U),U}return se instanceof Promise?se.then(U=>(he(oe,U),U)).catch(U=>(he(ue,U),Promise.reject(U))):(he(oe,se),se)};return F[ht]=!0,F[Re]=O,F},C={_p:s,$id:n,$onAction:ft.bind(null,$),$patch:p,$reset:l,$subscribe(N,O={}){const F=ft(P,N,O.detached,()=>H()),H=c.run(()=>$e(()=>s.state.value[n],oe=>{(O.flush==="sync"?_:y)&&N({storeId:n,type:_e.direct,events:u},oe)},de({},g,O)));return F},$dispose:i},S=hs(C);s._s.set(n,S);const te=(s._a&&s._a.runWithContext||ws)(()=>s._e.run(()=>(c=Ft()).run(()=>a({action:v}))));for(const N in te){const O=te[N];if(ve(O)&&!ks(O)||nt(O))r||(z&&xs(O)&&(ve(O)?O.value=z[N]:tt(O,z[N])),s.state.value[n][N]=O);else if(typeof O=="function"){const F=v(O,N);te[N]=F,d.actions[N]=O}}return de(S,te),de(Bt(S),te),Object.defineProperty(S,"$state",{get:()=>s.state.value[n],set:N=>{p(O=>{de(O,N)})}}),s._p.forEach(N=>{de(S,c.run(()=>N({store:S,app:s._a,pinia:s,options:d})))}),z&&r&&t.hydrate&&t.hydrate(S.$state,z),y=!0,_=!0,S}/*! #__NO_SIDE_EFFECTS__ */function at(n,a,t){let s;const o=typeof a=="function";s=o?t:a;function r(c,d){const g=fs();return c=c||(g?ds(Kt,null):null),c&&Ce(c),c=Jt,c._s.has(n)||(o?Zt(n,a,s,c):Ss(n,s,c)),c._s.get(n)}return r.$id=n,r}function rt(n){const a=Bt(n),t={};for(const s in a){const o=a[s];o.effect?t[s]=ne({get:()=>n[s],set(r){n[s]=r}}):(ve(o)||nt(o))&&(t[s]=us(n,s))}return t}const vt="/api";class $s{async request(a,t={}){try{const s=await fetch(`${vt}${a}`,{headers:{"Content-Type":"application/json",...t.headers},...t}),o=await s.json();return s.ok?{data:o,status:s.status}:{error:o.detail||`HTTP ${s.status}`,status:s.status}}catch(s){return{error:s instanceof Error?s.message:"Network error",status:0}}}async uploadRequest(a,t){try{const s=await fetch(`${vt}${a}`,{method:"POST",body:t}),o=await s.json();return s.ok?{data:o,status:s.status}:{error:o.detail||`HTTP ${s.status}`,status:s.status}}catch(s){return{error:s instanceof Error?s.message:"Network error",status:0}}}async getPuzzles(){return this.request("/submissions/puzzles")}async getSubmissions(a=20,t=0){return this.request(`/submissions/submissions?limit=${a}&offset=${t}`)}async getSubmission(a){return this.request(`/submissions/submissions/${a}`)}async createSubmission(a,t){const s=new FormData;return s.append("data",JSON.stringify(a)),t.forEach(o=>{s.append("files",o)}),this.uploadRequest("/submissions/submissions",s)}async validateResponse(a,t){return this.request(`/submissions/responses/${a}/validate`,{method:"PUT",body:JSON.stringify(t)})}async autoValidateResponses(a){return this.request(`/submissions/responses/${a}/validate/auto`,{method:"PUT"})}async getResponsesNeedingValidation(){return this.request("/submissions/responses/needs-validation")}async validateSubmission(a){return this.request(`/submissions/submissions/${a}/validate`,{method:"POST"})}async deleteSubmission(a){return this.request(`/submissions/submissions/${a}`,{method:"DELETE"})}async getStats(){return this.request("/submissions/stats")}async healthCheck(){return this.request("/health")}async getUserInfo(){return this.request("/user")}}const ae=new $s,Cs={async loadPuzzles(){const n=await ae.getPuzzles();return n.error?(console.error("Failed to load puzzles:",n.error),[]):n.data||[]},findPuzzleByName(n,a){if(!a)return null;let t=n.find(s=>s.title.toLowerCase()===a.toLowerCase());return t||(t=n.find(s=>s.title.toLowerCase().includes(a.toLowerCase())||a.toLowerCase().includes(s.title.toLowerCase()))),t||null}},mt={async createFromFiles(n,a,t,s){const o=n.map(c=>{const d=Cs.findPuzzleByName(a,c.ocrData?.puzzle||"");if(d)return{puzzle_id:d.id,puzzle_name:c.ocrData?.puzzle||"",cost:c.ocrData?.cost,cycles:c.ocrData?.cycles,area:c.ocrData?.area,needs_manual_validation:(c.ocrData?.confidence.overall??0)<=.8,ocr_confidence_cost:c.ocrData?.confidence?.cost||0,ocr_confidence_cycles:c.ocrData?.confidence?.cycles||0,ocr_confidence_area:c.ocrData?.confidence?.area||0}}).filter(c=>c!==void 0),r=n.map(c=>c.file);return ae.createSubmission({notes:t,manual_validation_requested:s,responses:o},r)},async loadSubmissions(n=20,a=0){const t=await ae.getSubmissions(n,a);return t.error?(console.error("Failed to load submissions:",t.error),[]):t.data?.items||[]}},Qt={getErrorMessage(n){return typeof n=="string"?n:n instanceof Error?n.message:typeof n=="object"&&n!==null&&"detail"in n?String(n.detail):"An unknown error occurred"},isNetworkError(n){return typeof n=="string"&&n.includes("Network")},isValidationError(n){return n===400},isAuthError(n){return n===401||n===403}},Pe=at("puzzles",()=>{const n=j([]),a=j(!1),t=j(""),s=ne(()=>n.value.map(d=>d.title)),o=ne(()=>d=>{if(!d)return null;const g=n.value.find(_=>_.title.toLowerCase()===d.toLowerCase());return g||n.value.find(_=>_.title.toLowerCase().includes(d.toLowerCase())||d.toLowerCase().includes(_.title.toLowerCase()))||null}),r=async()=>{if(!(n.value.length>0))try{a.value=!0,t.value="";const d=await ae.getPuzzles();if(d.error){t.value=d.error,console.error("Failed to load puzzles:",d.error);return}d.data&&(n.value=d.data)}catch(d){t.value="Failed to load puzzles",console.error("Error loading puzzles:",d)}finally{a.value=!1}};return{puzzles:n,isLoading:a,error:t,puzzleNames:s,findPuzzleByName:o,loadPuzzles:r,refreshPuzzles:async()=>{n.value=[],await r()}}}),lt=at("submissions",()=>{const n=j([]),a=j(!1),t=j(""),s=j(!1),o=Pe(),{puzzles:r}=rt(o),c=async($=20,u=0)=>{try{a.value=!0,t.value="";const z=await mt.loadSubmissions($,u);u===0?n.value=z:n.value.push(...z)}catch(z){t.value="Failed to load submissions",console.error("Error loading submissions:",z)}finally{a.value=!1}},d=async($,u,z)=>{try{a.value=!0,t.value="";const w=await mt.createFromFiles($,r.value,u,z);if(w.error)throw t.value=w.error,new Error(w.error);return w.data?(n.value.unshift(w.data),w.data):void 0}catch(w){throw t.value=w instanceof Error?w.message:"Failed to create submission",w}finally{a.value=!1}},g=()=>{s.value=!0},y=()=>{s.value=!1};return{submissions:n,isLoading:a,error:t,isSubmissionModalOpen:s,loadSubmissions:c,createSubmission:d,openSubmissionModal:g,closeSubmissionModal:y,refreshSubmissions:async()=>{n.value=[],await c()},handleSubmission:async $=>{try{a.value=!0,t.value="";const u=await d($.files,$.notes,$.manualValidationRequested);if(u){const z=u.responses.map(w=>w.puzzle_name).join(", ");alert(`Solutions submitted successfully for puzzles: ${z}`)}else alert("Submission created successfully!");y()}catch(u){const z=Qt.getErrorMessage(u);t.value=z,alert(`Submission failed: ${z}`),console.error("Submission error:",u)}finally{a.value=!1}}}}),Ps={class:"card-body"},Ls={class:"flex items-start justify-between"},Rs={class:"flex-1"},Es={class:"card-title text-lg font-bold"},Os={class:"text-sm text-base-content/70 mb-2"},Ms={class:"flex items-center gap-2 mb-3"},Ns={class:"badge badge-primary badge-sm"},As={class:"badge badge-ghost badge-sm"},Ds={key:0,class:"text-sm text-base-content/80 mb-4"},js={key:1,class:"flex flex-wrap gap-1 mb-4"},Is={key:0,class:"badge badge-outline badge-xs"},Ts={class:"flex flex-col items-end gap-2"},qs={class:"tooltip","data-tip":"View on Steam Workshop"},Fs=["href"],Us={key:0,class:"mt-6"},Bs={class:"divider"},Vs={class:"text-sm font-medium"},Gs={class:"table table-xs"},Ws={key:0,class:"badge badge-success badge-xs"},Hs={key:1,class:"text-base-content/50"},Js={key:0,class:"badge badge-info badge-xs"},Ks={key:1,class:"text-base-content/50"},Ys={key:0,class:"badge badge-warning badge-xs"},Zs={key:1,class:"text-base-content/50"},Qs={class:"flex items-center gap-1"},Xs={class:"badge badge-ghost badge-xs"},en=["data-tip"],tn={key:1,class:"tooltip","data-tip":"Needs manual validation"},sn=me({__name:"PuzzleCard",props:{puzzle:{},responses:{}},setup(n){const{openSubmissionModal:a}=lt();return(t,s)=>(f(),h("div",{class:re(["card bg-base-100 shadow-lg hover:shadow-2xl transition-shadow duration-300",n.responses?.length==0?"shadow-red-900":"shadow-primary-300"])},[e("div",Ps,[e("div",Ls,[e("div",Rs,[e("h3",Es,x(n.puzzle.title),1),e("p",Os," by "+x(n.puzzle.author_name),1),e("div",Ms,[e("div",Ns,x(n.puzzle.steam_item_id),1),e("div",As,"ID: "+x(n.puzzle.id),1)]),n.puzzle.description?(f(),h("p",Ds,x(n.puzzle.description),1)):A("",!0),n.puzzle.tags&&n.puzzle.tags.length>0?(f(),h("div",js,[(f(!0),h(Q,null,ee(n.puzzle.tags.slice(0,3),o=>(f(),h("span",{key:o,class:"badge badge-outline badge-xs"},x(o),1))),128)),n.puzzle.tags.length>3?(f(),h("span",Is," +"+x(n.puzzle.tags.length-3)+" more ",1)):A("",!0)])):A("",!0)]),e("div",Ts,[e("div",qs,[e("a",{href:`https://steamcommunity.com/workshop/filedetails/?id=${n.puzzle.steam_item_id}`,target:"_blank",class:"btn btn-ghost btn-sm btn-square"},[...s[1]||(s[1]=[e("i",{class:"mdi mdi-steam text-lg"},null,-1)])],8,Fs)])])]),n.responses&&n.responses.length>0?(f(),h("div",Us,[e("div",Bs,[e("span",Vs,"Solutions ("+x(n.responses.length)+")",1)]),e("div",null,[e("table",Gs,[s[4]||(s[4]=e("thead",null,[e("tr",null,[e("th",null,"Cost"),e("th",null,"Cycles"),e("th",null,"Area"),e("th",null,"Files")])],-1)),e("tbody",null,[(f(!0),h(Q,null,ee(n.responses,o=>(f(),h("tr",{key:o.id,class:"hover"},[e("td",null,[o.final_cost||o.cost?(f(),h("span",Ws,x(o.final_cost||o.cost),1)):(f(),h("span",Hs,"-"))]),e("td",null,[o.final_cycles||o.cycles?(f(),h("span",Js,x(o.final_cycles||o.cycles),1)):(f(),h("span",Ks,"-"))]),e("td",null,[o.final_area||o.area?(f(),h("span",Ys,x(o.final_area||o.area),1)):(f(),h("span",Zs,"-"))]),e("td",null,[e("div",Qs,[e("span",Xs,x(o.files?.length||0),1),o.files?.length?(f(),h("div",{key:0,class:"tooltip","data-tip":o.files.map(r=>r.original_filename||r.file?.name).join(", ")},[...s[2]||(s[2]=[e("i",{class:"mdi mdi-information-outline text-xs"},null,-1)])],8,en)):A("",!0),o.needs_manual_validation?(f(),h("div",tn,[...s[3]||(s[3]=[e("i",{class:"mdi mdi-alert-circle text-xs text-warning"},null,-1)])])):A("",!0)])])]))),128))])])])])):(f(),h("div",{key:1,class:"mt-6 text-center py-4 border-2 border-dashed border-base-300 rounded-lg hover:border-primary transition-colors duration-300 cursor-pointer",onClick:s[0]||(s[0]=(...o)=>I(a)&&I(a)(...o))},[...s[5]||(s[5]=[e("i",{class:"mdi mdi-upload text-2xl text-base-content/40"},null,-1),e("p",{class:"text-sm text-base-content/60 mt-2"},"No solutions yet",-1),e("p",{class:"text-xs text-base-content/40"}," Upload solutions using the submit button ",-1)])]))])],2))}});var Ee={exports:{}},gt;function nn(){return gt||(gt=1,(function(n){var a=(function(t){var s=Object.prototype,o=s.hasOwnProperty,r=Object.defineProperty||function(b,m,k){b[m]=k.value},c,d=typeof Symbol=="function"?Symbol:{},g=d.iterator||"@@iterator",y=d.asyncIterator||"@@asyncIterator",_=d.toStringTag||"@@toStringTag";function P(b,m,k){return Object.defineProperty(b,m,{value:k,enumerable:!0,configurable:!0,writable:!0}),b[m]}try{P({},"")}catch{P=function(m,k,R){return m[k]=R}}function $(b,m,k,R){var L=m&&m.prototype instanceof v?m:v,D=Object.create(L.prototype),W=new se(R||[]);return r(D,"_invoke",{value:oe(b,k,W)}),D}t.wrap=$;function u(b,m,k){try{return{type:"normal",arg:b.call(m,k)}}catch(R){return{type:"throw",arg:R}}}var z="suspendedStart",w="suspendedYield",p="executing",l="completed",i={};function v(){}function C(){}function S(){}var T={};P(T,g,function(){return this});var te=Object.getPrototypeOf,N=te&&te(te(U([])));N&&N!==s&&o.call(N,g)&&(T=N);var O=S.prototype=v.prototype=Object.create(T);C.prototype=S,r(O,"constructor",{value:S,configurable:!0}),r(S,"constructor",{value:C,configurable:!0}),C.displayName=P(S,_,"GeneratorFunction");function F(b){["next","throw","return"].forEach(function(m){P(b,m,function(k){return this._invoke(m,k)})})}t.isGeneratorFunction=function(b){var m=typeof b=="function"&&b.constructor;return m?m===C||(m.displayName||m.name)==="GeneratorFunction":!1},t.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,S):(b.__proto__=S,P(b,_,"GeneratorFunction")),b.prototype=Object.create(O),b},t.awrap=function(b){return{__await:b}};function H(b,m){function k(D,W,V,Y){var B=u(b[D],b,W);if(B.type==="throw")Y(B.arg);else{var pe=B.arg,fe=pe.value;return fe&&typeof fe=="object"&&o.call(fe,"__await")?m.resolve(fe.__await).then(function(le){k("next",le,V,Y)},function(le){k("throw",le,V,Y)}):m.resolve(fe).then(function(le){pe.value=le,V(pe)},function(le){return k("throw",le,V,Y)})}}var R;function L(D,W){function V(){return new m(function(Y,B){k(D,W,Y,B)})}return R=R?R.then(V,V):V()}r(this,"_invoke",{value:L})}F(H.prototype),P(H.prototype,y,function(){return this}),t.AsyncIterator=H,t.async=function(b,m,k,R,L){L===void 0&&(L=Promise);var D=new H($(b,m,k,R),L);return t.isGeneratorFunction(m)?D:D.next().then(function(W){return W.done?W.value:D.next()})};function oe(b,m,k){var R=z;return function(D,W){if(R===p)throw new Error("Generator is already running");if(R===l){if(D==="throw")throw W;return K()}for(k.method=D,k.arg=W;;){var V=k.delegate;if(V){var Y=ue(V,k);if(Y){if(Y===i)continue;return Y}}if(k.method==="next")k.sent=k._sent=k.arg;else if(k.method==="throw"){if(R===z)throw R=l,k.arg;k.dispatchException(k.arg)}else k.method==="return"&&k.abrupt("return",k.arg);R=p;var B=u(b,m,k);if(B.type==="normal"){if(R=k.done?l:w,B.arg===i)continue;return{value:B.arg,done:k.done}}else B.type==="throw"&&(R=l,k.method="throw",k.arg=B.arg)}}}function ue(b,m){var k=m.method,R=b.iterator[k];if(R===c)return m.delegate=null,k==="throw"&&b.iterator.return&&(m.method="return",m.arg=c,ue(b,m),m.method==="throw")||k!=="return"&&(m.method="throw",m.arg=new TypeError("The iterator does not provide a '"+k+"' method")),i;var L=u(R,b.iterator,m.arg);if(L.type==="throw")return m.method="throw",m.arg=L.arg,m.delegate=null,i;var D=L.arg;if(!D)return m.method="throw",m.arg=new TypeError("iterator result is not an object"),m.delegate=null,i;if(D.done)m[b.resultName]=D.value,m.next=b.nextLoc,m.method!=="return"&&(m.method="next",m.arg=c);else return D;return m.delegate=null,i}F(O),P(O,_,"Generator"),P(O,g,function(){return this}),P(O,"toString",function(){return"[object Generator]"});function ge(b){var m={tryLoc:b[0]};1 in b&&(m.catchLoc=b[1]),2 in b&&(m.finallyLoc=b[2],m.afterLoc=b[3]),this.tryEntries.push(m)}function X(b){var m=b.completion||{};m.type="normal",delete m.arg,b.completion=m}function se(b){this.tryEntries=[{tryLoc:"root"}],b.forEach(ge,this),this.reset(!0)}t.keys=function(b){var m=Object(b),k=[];for(var R in m)k.push(R);return k.reverse(),function L(){for(;k.length;){var D=k.pop();if(D in m)return L.value=D,L.done=!1,L}return L.done=!0,L}};function U(b){if(b){var m=b[g];if(m)return m.call(b);if(typeof b.next=="function")return b;if(!isNaN(b.length)){var k=-1,R=function L(){for(;++k<b.length;)if(o.call(b,k))return L.value=b[k],L.done=!1,L;return L.value=c,L.done=!0,L};return R.next=R}}return{next:K}}t.values=U;function K(){return{value:c,done:!0}}return se.prototype={constructor:se,reset:function(b){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method="next",this.arg=c,this.tryEntries.forEach(X),!b)for(var m in this)m.charAt(0)==="t"&&o.call(this,m)&&!isNaN(+m.slice(1))&&(this[m]=c)},stop:function(){this.done=!0;var b=this.tryEntries[0],m=b.completion;if(m.type==="throw")throw m.arg;return this.rval},dispatchException:function(b){if(this.done)throw b;var m=this;function k(Y,B){return D.type="throw",D.arg=b,m.next=Y,B&&(m.method="next",m.arg=c),!!B}for(var R=this.tryEntries.length-1;R>=0;--R){var L=this.tryEntries[R],D=L.completion;if(L.tryLoc==="root")return k("end");if(L.tryLoc<=this.prev){var W=o.call(L,"catchLoc"),V=o.call(L,"finallyLoc");if(W&&V){if(this.prev<L.catchLoc)return k(L.catchLoc,!0);if(this.prev<L.finallyLoc)return k(L.finallyLoc)}else if(W){if(this.prev<L.catchLoc)return k(L.catchLoc,!0)}else if(V){if(this.prev<L.finallyLoc)return k(L.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(b,m){for(var k=this.tryEntries.length-1;k>=0;--k){var R=this.tryEntries[k];if(R.tryLoc<=this.prev&&o.call(R,"finallyLoc")&&this.prev<R.finallyLoc){var L=R;break}}L&&(b==="break"||b==="continue")&&L.tryLoc<=m&&m<=L.finallyLoc&&(L=null);var D=L?L.completion:{};return D.type=b,D.arg=m,L?(this.method="next",this.next=L.finallyLoc,i):this.complete(D)},complete:function(b,m){if(b.type==="throw")throw b.arg;return b.type==="break"||b.type==="continue"?this.next=b.arg:b.type==="return"?(this.rval=this.arg=b.arg,this.method="return",this.next="end"):b.type==="normal"&&m&&(this.next=m),i},finish:function(b){for(var m=this.tryEntries.length-1;m>=0;--m){var k=this.tryEntries[m];if(k.finallyLoc===b)return this.complete(k.completion,k.afterLoc),X(k),i}},catch:function(b){for(var m=this.tryEntries.length-1;m>=0;--m){var k=this.tryEntries[m];if(k.tryLoc===b){var R=k.completion;if(R.type==="throw"){var L=R.arg;X(k)}return L}}throw new Error("illegal catch attempt")},delegateYield:function(b,m,k){return this.delegate={iterator:U(b),resultName:m,nextLoc:k},this.method==="next"&&(this.arg=c),i}},t})(n.exports);try{regeneratorRuntime=a}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=a:Function("r","regeneratorRuntime = r")(a)}})(Ee)),Ee.exports}var Oe,pt;function it(){return pt||(pt=1,Oe=(n,a)=>`${n}-${a}-${Math.random().toString(16).slice(3,8)}`),Oe}var Me,bt;function Xt(){if(bt)return Me;bt=1;const n=it();let a=0;return Me=({id:t,action:s,payload:o={}})=>{let r=t;return typeof r>"u"&&(r=n("Job",a),a+=1),{id:r,action:s,payload:o}},Me}var be={},yt;function ct(){if(yt)return be;yt=1;let n=!1;return be.logging=n,be.setLogging=a=>{n=a},be.log=(...a)=>n?console.log.apply(this,a):null,be}var Ne,_t;function on(){if(_t)return Ne;_t=1;const n=Xt(),{log:a}=ct(),t=it();let s=0;return Ne=()=>{const o=t("Scheduler",s),r={},c={};let d=[];s+=1;const g=()=>d.length,y=()=>Object.keys(r).length,_=()=>{if(d.length!==0){const w=Object.keys(r);for(let p=0;p<w.length;p+=1)if(typeof c[w[p]]>"u"){d[0](r[w[p]]);break}}},P=(w,p)=>new Promise((l,i)=>{const v=n({action:w,payload:p});d.push(async C=>{d.shift(),c[C.id]=v;try{l(await C[w].apply(this,[...p,v.id]))}catch(S){i(S)}finally{delete c[C.id],_()}}),a(`[${o}]: Add ${v.id} to JobQueue`),a(`[${o}]: JobQueue length=${d.length}`),_()});return{addWorker:w=>(r[w.id]=w,a(`[${o}]: Add ${w.id}`),a(`[${o}]: Number of workers=${y()}`),_(),w.id),addJob:async(w,...p)=>{if(y()===0)throw Error(`[${o}]: You need to have at least one worker before adding jobs`);return P(w,p)},terminate:async()=>{Object.keys(r).forEach(async w=>{await r[w].terminate()}),d=[]},getQueueLen:g,getNumWorkers:y}},Ne}function an(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ae,wt;function rn(){if(wt)return Ae;wt=1;function n(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}return Ae=n,Ae}var De,zt;function ln(){if(zt)return De;zt=1;const n=rn();return De=a=>{const t={};return typeof WorkerGlobalScope<"u"?t.type="webworker":n()?t.type="electron":typeof document=="object"?t.type="browser":typeof process=="object"&&typeof an=="function"&&(t.type="node"),typeof a>"u"?t:t[a]},De}var je,xt;function cn(){if(xt)return je;xt=1;const a=ln()("type")==="browser"?t=>new URL(t,window.location.href).href:t=>t;return je=t=>{const s={...t};return["corePath","workerPath","langPath"].forEach(o=>{t[o]&&(s[o]=a(s[o]))}),s},je}var Ie,kt;function un(){return kt||(kt=1,Ie=n=>{const a=[],t=[],s=[],o=[],r=[];return n.blocks&&n.blocks.forEach(c=>{c.paragraphs.forEach(d=>{d.lines.forEach(g=>{g.words.forEach(y=>{y.symbols.forEach(_=>{r.push({..._,page:n,block:c,paragraph:d,line:g,word:y})}),o.push({...y,page:n,block:c,paragraph:d,line:g})}),s.push({...g,page:n,block:c,paragraph:d})}),t.push({...d,page:n,block:c})}),a.push({...c,page:n})}),{...n,blocks:a,paragraphs:t,lines:s,words:o,symbols:r}}),Ie}var Te,St;function es(){return St||(St=1,Te={TESSERACT_ONLY:0,LSTM_ONLY:1,TESSERACT_LSTM_COMBINED:2,DEFAULT:3}),Te}const dn="5.1.1",fn={version:dn};var qe,$t;function hn(){return $t||($t=1,qe={workerBlobURL:!0,logger:()=>{}}),qe}var Fe,Ct;function vn(){if(Ct)return Fe;Ct=1;const n=fn.version;return Fe={...hn(),workerPath:`https://cdn.jsdelivr.net/npm/tesseract.js@v${n}/dist/worker.min.js`},Fe}var Ue,Pt;function mn(){return Pt||(Pt=1,Ue=({workerPath:n,workerBlobURL:a})=>{let t;if(Blob&&URL&&a){const s=new Blob([`importScripts("${n}");`],{type:"application/javascript"});t=new Worker(URL.createObjectURL(s))}else t=new Worker(n);return t}),Ue}var Be,Lt;function gn(){return Lt||(Lt=1,Be=n=>{n.terminate()}),Be}var Ve,Rt;function pn(){return Rt||(Rt=1,Ve=(n,a)=>{n.onmessage=({data:t})=>{a(t)}}),Ve}var Ge,Et;function bn(){return Et||(Et=1,Ge=async(n,a)=>{n.postMessage(a)}),Ge}var We,Ot;function yn(){if(Ot)return We;Ot=1;const n=t=>new Promise((s,o)=>{const r=new FileReader;r.onload=()=>{s(r.result)},r.onerror=({target:{error:{code:c}}})=>{o(Error(`File could not be read! Code=${c}`))},r.readAsArrayBuffer(t)}),a=async t=>{let s=t;if(typeof t>"u")return"undefined";if(typeof t=="string")/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(t)?s=atob(t.split(",")[1]).split("").map(o=>o.charCodeAt(0)):s=await(await fetch(t)).arrayBuffer();else if(typeof HTMLElement<"u"&&t instanceof HTMLElement)t.tagName==="IMG"&&(s=await a(t.src)),t.tagName==="VIDEO"&&(s=await a(t.poster)),t.tagName==="CANVAS"&&await new Promise(o=>{t.toBlob(async r=>{s=await n(r),o()})});else if(typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas){const o=await t.convertToBlob();s=await n(o)}else(t instanceof File||t instanceof Blob)&&(s=await n(t));return new Uint8Array(s)};return We=a,We}var He,Mt;function _n(){if(Mt)return He;Mt=1;const n=vn(),a=mn(),t=gn(),s=pn(),o=bn(),r=yn();return He={defaultOptions:n,spawnWorker:a,terminateWorker:t,onMessage:s,send:o,loadImage:r},He}var Je,Nt;function ts(){if(Nt)return Je;Nt=1;const n=cn(),a=un(),t=Xt(),{log:s}=ct(),o=it(),r=es(),{defaultOptions:c,spawnWorker:d,terminateWorker:g,onMessage:y,loadImage:_,send:P}=_n();let $=0;return Je=async(u="eng",z=r.LSTM_ONLY,w={},p={})=>{const l=o("Worker",$),{logger:i,errorHandler:v,...C}=n({...c,...w}),S={},T={},te=typeof u=="string"?u.split("+"):u;let N=z,O=p;const F=[r.DEFAULT,r.LSTM_ONLY].includes(z)&&!C.legacyCore;let H,oe;const ue=new Promise((E,M)=>{oe=E,H=M}),ge=E=>{H(E.message)};let X=d(C);X.onerror=ge,$+=1;const se=(E,M)=>{S[E]=M},U=(E,M)=>{T[E]=M},K=({id:E,action:M,payload:G})=>new Promise((Z,J)=>{s(`[${l}]: Start ${E}, action=${M}`);const ie=`${M}-${E}`;se(ie,Z),U(ie,J),P(X,{workerId:l,jobId:E,action:M,payload:G})}),b=()=>console.warn("`load` is depreciated and should be removed from code (workers now come pre-loaded)"),m=E=>K(t({id:E,action:"load",payload:{options:{lstmOnly:F,corePath:C.corePath,logging:C.logging}}})),k=(E,M,G)=>K(t({id:G,action:"FS",payload:{method:"writeFile",args:[E,M]}})),R=(E,M)=>K(t({id:M,action:"FS",payload:{method:"readFile",args:[E,{encoding:"utf8"}]}})),L=(E,M)=>K(t({id:M,action:"FS",payload:{method:"unlink",args:[E]}})),D=(E,M,G)=>K(t({id:G,action:"FS",payload:{method:E,args:M}})),W=()=>console.warn("`loadLanguage` is depreciated and should be removed from code (workers now come with language pre-loaded)"),V=(E,M)=>K(t({id:M,action:"loadLanguage",payload:{langs:E,options:{langPath:C.langPath,dataPath:C.dataPath,cachePath:C.cachePath,cacheMethod:C.cacheMethod,gzip:C.gzip,lstmOnly:[r.DEFAULT,r.LSTM_ONLY].includes(N)&&!C.legacyLang}}})),Y=()=>console.warn("`initialize` is depreciated and should be removed from code (workers now come pre-initialized)"),B=(E,M,G,Z)=>K(t({id:Z,action:"initialize",payload:{langs:E,oem:M,config:G}})),pe=(E="eng",M,G,Z)=>{if(F&&[r.TESSERACT_ONLY,r.TESSERACT_LSTM_COMBINED].includes(M))throw Error("Legacy model requested but code missing.");const J=M||N;N=J;const ie=G||O;O=ie;const Le=(typeof E=="string"?E.split("+"):E).filter(cs=>!te.includes(cs));return te.push(...Le),Le.length>0?V(Le,Z).then(()=>B(E,J,ie,Z)):B(E,J,ie,Z)},fe=(E={},M)=>K(t({id:M,action:"setParameters",payload:{params:E}})),le=async(E,M={},G={blocks:!0,text:!0,hocr:!0,tsv:!0},Z)=>K(t({id:Z,action:"recognize",payload:{image:await _(E),options:M,output:G}})),as=(E="Tesseract OCR Result",M=!1,G)=>(console.log("`getPDF` function is depreciated. `recognize` option `savePDF` should be used instead."),K(t({id:G,action:"getPDF",payload:{title:E,textonly:M}}))),rs=async(E,M)=>{if(F)throw Error("`worker.detect` requires Legacy model, which was not loaded.");return K(t({id:M,action:"detect",payload:{image:await _(E)}}))},ls=async()=>(X!==null&&(g(X),X=null),Promise.resolve());y(X,({workerId:E,jobId:M,status:G,action:Z,data:J})=>{const ie=`${Z}-${M}`;if(G==="resolve"){s(`[${E}]: Complete ${M}`);let we=J;Z==="recognize"?we=a(J):Z==="getPDF"&&(we=Array.from({...J,length:Object.keys(J).length})),S[ie]({jobId:M,data:we})}else if(G==="reject")if(T[ie](J),Z==="load"&&H(J),v)v(J);else throw Error(J);else G==="progress"&&i({...J,userJobId:M})});const is={id:l,worker:X,setResolve:se,setReject:U,load:b,writeText:k,readText:R,removeFile:L,FS:D,loadLanguage:W,initialize:Y,reinitialize:pe,setParameters:fe,recognize:le,getPDF:as,detect:rs,terminate:ls};return m().then(()=>V(u)).then(()=>B(u,z,p)).then(()=>oe(is)).catch(()=>{}),ue},Je}var Ke,At;function wn(){if(At)return Ke;At=1;const n=ts();return Ke={recognize:async(s,o,r)=>{const c=await n(o,1,r);return c.recognize(s).finally(async()=>{await c.terminate()})},detect:async(s,o)=>{const r=await n("osd",0,o);return r.detect(s).finally(async()=>{await r.terminate()})}},Ke}var Ye,Dt;function zn(){return Dt||(Dt=1,Ye={AFR:"afr",AMH:"amh",ARA:"ara",ASM:"asm",AZE:"aze",AZE_CYRL:"aze_cyrl",BEL:"bel",BEN:"ben",BOD:"bod",BOS:"bos",BUL:"bul",CAT:"cat",CEB:"ceb",CES:"ces",CHI_SIM:"chi_sim",CHI_TRA:"chi_tra",CHR:"chr",CYM:"cym",DAN:"dan",DEU:"deu",DZO:"dzo",ELL:"ell",ENG:"eng",ENM:"enm",EPO:"epo",EST:"est",EUS:"eus",FAS:"fas",FIN:"fin",FRA:"fra",FRK:"frk",FRM:"frm",GLE:"gle",GLG:"glg",GRC:"grc",GUJ:"guj",HAT:"hat",HEB:"heb",HIN:"hin",HRV:"hrv",HUN:"hun",IKU:"iku",IND:"ind",ISL:"isl",ITA:"ita",ITA_OLD:"ita_old",JAV:"jav",JPN:"jpn",KAN:"kan",KAT:"kat",KAT_OLD:"kat_old",KAZ:"kaz",KHM:"khm",KIR:"kir",KOR:"kor",KUR:"kur",LAO:"lao",LAT:"lat",LAV:"lav",LIT:"lit",MAL:"mal",MAR:"mar",MKD:"mkd",MLT:"mlt",MSA:"msa",MYA:"mya",NEP:"nep",NLD:"nld",NOR:"nor",ORI:"ori",PAN:"pan",POL:"pol",POR:"por",PUS:"pus",RON:"ron",RUS:"rus",SAN:"san",SIN:"sin",SLK:"slk",SLV:"slv",SPA:"spa",SPA_OLD:"spa_old",SQI:"sqi",SRP:"srp",SRP_LATN:"srp_latn",SWA:"swa",SWE:"swe",SYR:"syr",TAM:"tam",TEL:"tel",TGK:"tgk",TGL:"tgl",THA:"tha",TIR:"tir",TUR:"tur",UIG:"uig",UKR:"ukr",URD:"urd",UZB:"uzb",UZB_CYRL:"uzb_cyrl",VIE:"vie",YID:"yid"}),Ye}var Ze,jt;function xn(){return jt||(jt=1,Ze={OSD_ONLY:"0",AUTO_OSD:"1",AUTO_ONLY:"2",AUTO:"3",SINGLE_COLUMN:"4",SINGLE_BLOCK_VERT_TEXT:"5",SINGLE_BLOCK:"6",SINGLE_LINE:"7",SINGLE_WORD:"8",CIRCLE_WORD:"9",SINGLE_CHAR:"10",SPARSE_TEXT:"11",SPARSE_TEXT_OSD:"12",RAW_LINE:"13"}),Ze}var Qe,It;function kn(){if(It)return Qe;It=1,nn();const n=on(),a=ts(),t=wn(),s=zn(),o=es(),r=xn(),{setLogging:c}=ct();return Qe={languages:s,OEM:o,PSM:r,createScheduler:n,createWorker:a,setLogging:c,...t},Qe}var Sn=kn();class ut{worker=null;availablePuzzleNames=[];regions={puzzle:{x:15,y:600,width:330,height:28},cost:{x:412,y:603,width:65,height:22},cycles:{x:577,y:603,width:65,height:22},area:{x:739,y:603,width:65,height:22}};async initialize(){this.worker||(this.worker=await Sn.createWorker("eng"),await this.worker.setParameters({tessedit_ocr_engine_mode:"3",tessedit_pageseg_mode:7}))}setAvailablePuzzleNames(a){this.availablePuzzleNames=a,console.log("OCR service updated with puzzle names:",a)}async configurePuzzleOCR(){this.worker&&(await this.worker.setParameters({load_system_dawg:"0",load_freq_dawg:"0",load_punc_dawg:"0",load_number_dawg:"0",load_unambig_dawg:"0",load_bigram_dawg:"0",load_fixed_length_dawgs:"0",tessedit_char_whitelist:this.getPuzzleCharacterSet(),tessedit_pageseg_mode:8,segment_penalty_dict_nonword:"2.0",segment_penalty_dict_frequent_word:"0.001",segment_penalty_dict_case_ok:"0.001",segment_penalty_dict_case_bad:"0.1",classify_enable_learning:"0",classify_enable_adaptive_matcher:"1",preserve_interword_spaces:"1"}),console.log("OCR configured for puzzle names with character set:",this.getPuzzleCharacterSet()))}getPuzzleCharacterSet(){if(this.availablePuzzleNames.length===0)return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -";const a=new Set;return this.availablePuzzleNames.forEach(t=>{for(const s of t)a.add(s)}),Array.from(a).join("")}async extractOpusMagnumData(a){this.worker||await this.initialize();const t=URL.createObjectURL(a),s=new Image;return new Promise((o,r)=>{s.onload=async()=>{try{const c=document.createElement("canvas"),d=c.getContext("2d");c.width=s.width,c.height=s.height,d.drawImage(s,0,0);const g={},y={};for(const[$,u]of Object.entries(this.regions)){const z=document.createElement("canvas"),w=z.getContext("2d");z.width=u.width,z.height=u.height,w.drawImage(c,u.x,u.y,u.width,u.height,0,0,u.width,u.height);const p=w.getImageData(0,0,u.width,u.height);this.preprocessImage(p),w.putImageData(p,0,0),$==="cost"?await this.worker.setParameters({tessedit_char_whitelist:"0123456789G"}):$==="cycles"||$==="area"?await this.worker.setParameters({tessedit_char_whitelist:"0123456789"}):$==="puzzle"?await this.configurePuzzleOCR():await this.worker.setParameters({tessedit_char_whitelist:""});const{data:{text:l,confidence:i}}=await this.worker.recognize(z);let v=l.trim();if(y[$]=i/100,$==="cost"){if(v.endsWith("6")&&v.length>1){const C=v.slice(0,-1);/^\d+$/.test(C)&&(v=C)}v=v.replace(/G+$/g,""),v=v.replace(/[^0-9]/g,"")}else if($==="cycles"||$==="area")v=v.replace(/[^0-9]/g,"");else if($==="puzzle"&&(v=this.findBestPuzzleMatch(v),this.availablePuzzleNames.length>0&&!this.availablePuzzleNames.includes(v))){const C=this.findBestPuzzleMatchForced(v);C&&(v=C,console.log(`Forced OCR match: "${l.trim()}" -> "${v}"`))}g[$]=v}URL.revokeObjectURL(t);const _=Object.values(y),P=_.length>0?_.reduce(($,u)=>$+u,0)/_.length:0;o({puzzle:g.puzzle||"",cost:parseInt(g.cost||""),cycles:parseInt(g.cycles||""),area:parseInt(g.area||""),confidence:{puzzle:y.puzzle||0,cost:y.cost||0,cycles:y.cycles||0,area:y.area||0,overall:P}})}catch(c){URL.revokeObjectURL(t),r(c)}},s.onerror=()=>{URL.revokeObjectURL(t),r(new Error("Failed to load image"))},s.src=t})}preprocessImage(a){const t=a.data;for(let s=0;s<t.length;s+=4){const r=255-Math.round(.299*t[s]+.587*t[s+1]+.114*t[s+2]);t[s]=r,t[s+1]=r,t[s+2]=r}}levenshteinDistance(a,t){const s=Array(t.length+1).fill(null).map(()=>Array(a.length+1).fill(null));for(let o=0;o<=a.length;o++)s[0][o]=o;for(let o=0;o<=t.length;o++)s[o][0]=o;for(let o=1;o<=t.length;o++)for(let r=1;r<=a.length;r++){const c=a[r-1]===t[o-1]?0:1;s[o][r]=Math.min(s[o][r-1]+1,s[o-1][r]+1,s[o-1][r-1]+c)}return s[t.length][a.length]}findBestPuzzleMatch(a){if(!this.availablePuzzleNames.length)return a.trim();const t=a.trim();if(!t)return"";const s=this.availablePuzzleNames.find(d=>d.toLowerCase()===t.toLowerCase());if(s)return s;const o=this.availablePuzzleNames.find(d=>d.toLowerCase().includes(t.toLowerCase())||t.toLowerCase().includes(d.toLowerCase()));if(o)return o;let r=t,c=0;for(const d of this.availablePuzzleNames){const g=[this.calculateLevenshteinSimilarity(t,d),this.calculateJaroWinklerSimilarity(t,d),this.calculateNGramSimilarity(t,d,2)],y=Math.max(...g);y>c&&y>.4&&(c=y,r=d)}if(c<.6){const d=this.findBestCharacterMatch(t);d&&(r=d)}return r}calculateLevenshteinSimilarity(a,t){const s=this.levenshteinDistance(a.toLowerCase(),t.toLowerCase()),o=Math.max(a.length,t.length);return o===0?1:1-s/o}calculateJaroWinklerSimilarity(a,t){const s=a.toLowerCase(),o=t.toLowerCase();if(s===o)return 1;const r=Math.floor(Math.max(s.length,o.length)/2)-1;if(r<0)return 0;const c=new Array(s.length).fill(!1),d=new Array(o.length).fill(!1);let g=0,y=0;for(let u=0;u<s.length;u++){const z=Math.max(0,u-r),w=Math.min(u+r+1,o.length);for(let p=z;p<w;p++)if(!(d[p]||s[u]!==o[p])){c[u]=!0,d[p]=!0,g++;break}}if(g===0)return 0;let _=0;for(let u=0;u<s.length;u++)if(c[u]){for(;!d[_];)_++;s[u]!==o[_]&&y++,_++}const P=(g/s.length+g/o.length+(g-y/2)/g)/3;let $=0;for(let u=0;u<Math.min(s.length,o.length,4)&&s[u]===o[u];u++)$++;return P+.1*$*(1-P)}calculateNGramSimilarity(a,t,s){const o=a.toLowerCase(),r=t.toLowerCase();if(o===r)return 1;if(o.length<s||r.length<s)return 0;const c=new Set,d=new Set;for(let _=0;_<=o.length-s;_++)c.add(o.substr(_,s));for(let _=0;_<=r.length-s;_++)d.add(r.substr(_,s));const g=new Set([...c].filter(_=>d.has(_))),y=new Set([...c,...d]);return g.size/y.size}findBestCharacterMatch(a){let t=null,s=0;for(const o of this.availablePuzzleNames){const r=this.calculateCharacterFrequencyScore(a.toLowerCase(),o.toLowerCase());r>s&&r>.3&&(s=r,t=o)}return t}calculateCharacterFrequencyScore(a,t){const s=new Map,o=new Map;for(const g of a)s.set(g,(s.get(g)||0)+1);for(const g of t)o.set(g,(o.get(g)||0)+1);const r=new Set([...s.keys(),...o.keys()]);let c=0,d=0;for(const g of r){const y=s.get(g)||0,_=o.get(g)||0;c+=Math.min(y,_),d+=Math.max(y,_)}return d===0?0:c/d}findBestPuzzleMatchForced(a){if(!this.availablePuzzleNames.length||!a.trim())return null;const t=a.trim().toLowerCase();let s=this.availablePuzzleNames[0],o=0;for(const r of this.availablePuzzleNames){const c=[this.calculateLevenshteinSimilarity(t,r),this.calculateJaroWinklerSimilarity(t,r),this.calculateNGramSimilarity(t,r,2),this.calculateCharacterFrequencyScore(t,r.toLowerCase()),this.calculateLengthSimilarity(t,r.toLowerCase())],d=c[0]*.25+c[1]*.25+c[2]*.2+c[3]*.2+c[4]*.1;d>o&&(o=d,s=r)}return console.log(`Forced match for "${a}": "${s}" (score: ${o.toFixed(3)})`),s}calculateLengthSimilarity(a,t){const s=a.length,o=t.length,r=Math.max(s,o),c=Math.min(s,o);return r===0?1:c/r}async terminate(){this.worker&&(await this.worker.terminate(),this.worker=null)}static isValidOpusMagnumImage(a){return["image/jpeg","image/jpg","image/png","image/gif"].includes(a.type)}static drawDebugRegions(a){return new Promise((t,s)=>{const o=URL.createObjectURL(a),r=new Image;r.onload=()=>{const c=document.createElement("canvas"),d=c.getContext("2d");c.width=r.width,c.height=r.height,d.drawImage(r,0,0),d.strokeStyle="#00ff00",d.lineWidth=2;const g=new ut;Object.values(g.regions).forEach(y=>{d.strokeRect(y.x,y.y,y.width,y.height)}),URL.revokeObjectURL(o),t(c.toDataURL())},r.onerror=()=>{URL.revokeObjectURL(o),s(new Error("Failed to load image for debug"))},r.src=o})}}const st=new ut,ye=.8,ss=at("uploads",()=>{const n=j([]),a=ne(()=>n.value.some(g=>g.ocrProcessing)),t=ne(()=>n.value.some(g=>o(g))),s=ne(()=>n.value.filter(g=>g.needsManualPuzzleSelection)),o=g=>g.ocrData?.confidence?g.ocrData.confidence.cost<ye||g.ocrData.confidence.cycles<ye||g.ocrData.confidence.area<ye:!1,r=async g=>{for(;a.value;){const _=Math.floor(Math.random()*400)+100;console.log(`OCR is already processing, waiting ${_}ms...`),await new Promise(P=>setTimeout(P,_))}const y=n.value.indexOf(g);n.value[y].ocrProcessing=!0,n.value[y].ocrError=void 0,n.value[y].ocrData=void 0;try{console.log("Starting OCR processing for:",g.file.name),await st.initialize();const _=await st.extractOpusMagnumData(g.file);console.log("OCR completed:",_),await Se(),n.value[y].ocrData=_,_.confidence.puzzle<ye?(n.value[y].needsManualPuzzleSelection=!0,console.log(`Low puzzle confidence (${Math.round(_.confidence.puzzle*100)}%) for ${g.file.name}, requiring manual selection`)):n.value[y].needsManualPuzzleSelection=!1,await Se()}catch(_){console.error("OCR processing failed:",_),n.value[y].ocrError="Failed to extract puzzle data"}finally{n.value[y].ocrProcessing=!1}};return{submissionFiles:n,submissionFilesNeedingManualSelection:s,processOCR:r,processLowConfidenceOCRFiles:async()=>{const g=n.value.filter(y=>o(y));for(const y of g)r(y)},clearFiles:()=>{n.value=[]},isProcessingOCR:a,hasLowConfidence:t,CONFIDENCE_VALUE:ye}}),$n={class:"form-control w-full"},Cn={key:0,class:"space-y-4"},Pn={key:1,class:"space-y-4"},Ln={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 gap-4"},Rn={class:"aspect-square rounded-lg overflow-hidden bg-base-200"},En=["src","alt"],On={class:"absolute inset-0 bg-black/80 opacity-0 group-hover:opacity-100 transition-opacity duration-200 rounded-lg flex items-center justify-center"},Mn=["onClick"],Nn={class:"mt-2"},An={class:"text-xs font-medium truncate"},Dn={class:"text-xs text-base-content/60"},jn={key:0,class:"mt-1 flex items-center gap-1"},In={key:1,class:"mt-1"},Tn={class:"text-xs text-error"},qn={key:2,class:"mt-1 space-y-1"},Fn={class:"text-xs flex items-center justify-between"},Un={class:"flex items-center gap-2"},Bn=["title"],Vn=["onClick"],Gn={class:"text-xs space-y-1 bg-base-200 p-2 rounded"},Wn={key:0},Hn=["title"],Jn={key:1},Kn=["title"],Yn={key:2},Zn=["title"],Qn={key:3},Xn=["title"],eo={key:3,class:"mt-2"},to={class:"mt-2"},so=["onUpdate:modelValue","onChange"],no=["value"],oo={key:4,class:"mt-1"},ao=["onClick"],ro={class:"flex justify-center"},lo={key:0,class:"label"},io={class:"label-text-alt text-error"},co=me({__name:"FileUpload",setup(n){const a=Pe(),{submissionFiles:t,processOCR:s}=ss(),o=j(),r=j(!1),c=j("");$e(()=>a.puzzles,l=>{l&&l.length>0&&st.setAvailablePuzzleNames(a.puzzleNames)},{immediate:!0});const d=l=>{const i=l.target;i.files&&y(Array.from(i.files))},g=l=>{l.preventDefault(),r.value=!1,l.dataTransfer?.files&&y(Array.from(l.dataTransfer.files))},y=async l=>{c.value="";for(const i of l)if(_(i))try{const v=await P(i),C=i.type.startsWith("image/gif")?"gif":"image",S={file:i,file_url:"",preview:v,type:C,ocrProcessing:!1,ocrError:void 0,ocrData:void 0};t.push(S),z(i)&&Se(()=>{s(S)})}catch{c.value=`Failed to process ${i.name}`}},_=l=>l.type.startsWith("image/")?l.size>256*1024*1024?(c.value=`${l.name} is too large (max 256MB)`,!1):!0:(c.value=`${l.name} is not a valid image file`,!1),P=l=>new Promise((i,v)=>{const C=new FileReader;C.onload=S=>i(S.target?.result),C.onerror=v,C.readAsDataURL(l)}),$=l=>{t.splice(l,1)},u=l=>{if(l===0)return"0 Bytes";const i=1024,v=["Bytes","KB","MB","GB"],C=Math.floor(Math.log(l)/Math.log(i));return parseFloat((l/Math.pow(i,C)).toFixed(2))+" "+v[C]},z=l=>l.type.startsWith("image/")&&l.size>5e4,w=l=>l>=.8?"badge-success":l>=.6?"badge-warning":"badge-error",p=l=>{const i=t.findIndex(v=>v.file===l.file);i!==-1&&t[i].manualPuzzleSelection&&(t[i].needsManualPuzzleSelection=!1,console.log(`Manual puzzle selection: ${l.file.name} -> ${t[i].manualPuzzleSelection}`))};return(l,i)=>(f(),h("div",$n,[i[19]||(i[19]=e("label",{class:"label"},[e("span",{class:"label-text font-medium"},"Upload Solution Files"),e("span",{class:"label-text-alt text-xs"},"Images or GIFs only")],-1)),e("div",{class:re(["border-2 border-dashed border-base-300 rounded-lg p-6 text-center hover:border-primary transition-colors duration-300",{"border-primary bg-primary/5":r.value}]),onDrop:g,onDragover:i[2]||(i[2]=Xe(v=>r.value=!0,["prevent"])),onDragleave:i[3]||(i[3]=v=>r.value=!1),onDragenter:i[4]||(i[4]=Xe(()=>{},["prevent"]))},[e("input",{ref_key:"fileInput",ref:o,type:"file",multiple:"",accept:"image/*,.gif",class:"hidden",onChange:d},null,544),I(t).length===0?(f(),h("div",Cn,[i[6]||(i[6]=e("div",{class:"mx-auto w-12 h-12 text-base-content/40 flex items-center justify-center"},[e("i",{class:"mdi mdi-cloud-upload text-5xl"})],-1)),e("div",null,[i[5]||(i[5]=e("p",{class:"text-base-content/70 mb-2"},"Drop your files here or",-1)),e("button",{type:"button",onClick:i[0]||(i[0]=v=>o.value?.click()),class:"btn btn-primary btn-sm"}," Choose Files ")]),i[7]||(i[7]=e("p",{class:"text-xs text-base-content/50"}," Supported formats: JPG, PNG, GIF (max 256MB each) ",-1))])):(f(),h("div",Pn,[e("div",Ln,[(f(!0),h(Q,null,ee(I(t),(v,C)=>(f(),h("div",{key:C,class:"relative group"},[e("div",Rn,[e("img",{src:v.preview,alt:v.file.name,class:"w-full h-full object-cover"},null,8,En)]),e("div",On,[e("button",{onClick:S=>$(C),class:"btn btn-error btn-lg btn-circle"},[...i[8]||(i[8]=[e("i",{class:"mdi mdi-close"},null,-1)])],8,Mn)]),e("div",Nn,[e("p",An,x(v.file.name),1),e("p",Dn,x(u(v.file.size))+" "+x(v.type.toUpperCase()),1),v.ocrProcessing?(f(),h("div",jn,[...i[9]||(i[9]=[e("span",{class:"loading loading-spinner loading-xs"},null,-1),e("span",{class:"text-xs text-info"},"Extracting puzzle data...",-1)])])):v.ocrError?(f(),h("div",In,[e("p",Tn,x(v.ocrError),1)])):v.ocrData?(f(),h("div",qn,[e("div",Fn,[e("div",Un,[i[10]||(i[10]=e("span",{class:"font-medium text-success"}," OCR Complete",-1)),v.ocrData.confidence?(f(),h("span",{key:0,class:re(["badge badge-xs",w(v.ocrData.confidence.overall)]),title:`Overall confidence: ${Math.round(v.ocrData.confidence.overall*100)}%`},x(Math.round(v.ocrData.confidence.overall*100))+"% ",11,Bn)):A("",!0)]),e("button",{onClick:S=>I(s)(v),class:"btn btn-xs btn-ghost",title:"Retry OCR"},[...i[11]||(i[11]=[e("i",{class:"mdi mdi-refresh"},null,-1)])],8,Vn)]),e("div",Gn,[v.ocrData.puzzle?(f(),h("div",Wn,[i[12]||(i[12]=e("strong",null,"Puzzle:",-1)),q(" "+x(v.ocrData.puzzle)+" ",1),v.ocrData.confidence?.puzzle?(f(),h("span",{key:0,class:"ml-2 opacity-60",title:`Puzzle confidence: ${Math.round(v.ocrData.confidence.puzzle*100)}%`}," ("+x(Math.round(v.ocrData.confidence.puzzle*100))+"%) ",9,Hn)):A("",!0)])):A("",!0),v.ocrData.cost?(f(),h("div",Jn,[i[13]||(i[13]=e("strong",null,"Cost:",-1)),q(" "+x(v.ocrData.cost)+" ",1),v.ocrData.confidence?.cost?(f(),h("span",{key:0,class:"ml-2 opacity-60",title:`Cost confidence: ${Math.round(v.ocrData.confidence.cost*100)}%`}," ("+x(Math.round(v.ocrData.confidence.cost*100))+"%) ",9,Kn)):A("",!0)])):A("",!0),v.ocrData.cycles?(f(),h("div",Yn,[i[14]||(i[14]=e("strong",null,"Cycles:",-1)),q(" "+x(v.ocrData.cycles)+" ",1),v.ocrData.confidence?.cycles?(f(),h("span",{key:0,class:"ml-2 opacity-60",title:`Cycles confidence: ${Math.round(v.ocrData.confidence.cycles*100)}%`}," ("+x(Math.round(v.ocrData.confidence.cycles*100))+"%) ",9,Zn)):A("",!0)])):A("",!0),v.ocrData.area?(f(),h("div",Qn,[i[15]||(i[15]=e("strong",null,"Area:",-1)),q(" "+x(v.ocrData.area)+" ",1),v.ocrData.confidence?.area?(f(),h("span",{key:0,class:"ml-2 opacity-60",title:`Area confidence: ${Math.round(v.ocrData.confidence.area*100)}%`}," ("+x(Math.round(v.ocrData.confidence.area*100))+"%) ",9,Xn)):A("",!0)])):A("",!0)])])):A("",!0),v.needsManualPuzzleSelection?(f(),h("div",eo,[i[17]||(i[17]=ms('<div class="alert alert-warning alert-sm"><i class="mdi mdi-alert-circle text-lg"></i><div class="flex-1"><div class="font-medium">Low OCR Confidence</div><div class="text-xs"> Please select the correct puzzle manually </div></div></div>',1)),e("div",to,[ce(e("select",{"onUpdate:modelValue":S=>v.manualPuzzleSelection=S,class:"select select-bordered select-sm w-full",onChange:S=>p(v)},[i[16]||(i[16]=e("option",{value:""},"Select puzzle...",-1)),(f(!0),h(Q,null,ee(I(a).puzzles,S=>(f(),h("option",{key:S.id,value:S.title},x(S.title),9,no))),128))],40,so),[[Wt,v.manualPuzzleSelection]])])])):!v.ocrProcessing&&!v.ocrError&&!v.ocrData?(f(),h("div",oo,[e("button",{onClick:S=>I(s)(v),class:"btn btn-xs btn-outline"},[...i[18]||(i[18]=[e("i",{class:"mdi mdi-text-recognition"},null,-1),q(" Extract Puzzle Data ",-1)])],8,ao)])):A("",!0)])]))),128))]),e("div",ro,[e("button",{type:"button",onClick:i[1]||(i[1]=v=>o.value?.click()),class:"btn btn-outline btn-sm"}," Add More Files ")])]))],34),c.value?(f(),h("div",lo,[e("span",io,x(c.value),1)])):A("",!0)]))}}),uo={class:"card bg-base-100 shadow-xl"},fo={class:"card-body"},ho={key:0,class:"alert alert-info"},vo={class:"flex-1"},mo={class:"font-bold"},go={class:"text-sm space-y-1 mt-1"},po={class:"badge badge-ghost badge-sm ml-2"},bo={key:1,class:"alert alert-warning"},yo={class:"flex-1"},_o={class:"text-sm"},wo={class:"form-control"},zo={class:"flex-1"},xo={class:"flex label"},ko={class:"label-text-alt"},So={class:"form-control"},$o={class:"label cursor-pointer justify-start gap-3"},Co=["disabled"],Po={class:"card-actions justify-end"},Lo=["disabled"],Ro={key:0,class:"loading loading-spinner loading-sm"},Eo={key:1},Oo={key:2},Mo={key:3},No=me({__name:"SubmissionForm",props:{puzzles:{},findPuzzleByName:{type:Function}},setup(n){const a=n,t=ss(),{submissionFiles:s,hasLowConfidence:o,submissionFilesNeedingManualSelection:r}=rt(t),{clearFiles:c,processLowConfidenceOCRFiles:d}=t,{handleSubmission:g}=lt(),y=j(""),_=j(!1),P=j(!1),$=ne(()=>y.value.length),u=ne(()=>{const p=s.value.length>0,l=!s.value.some(i=>i.needsManualPuzzleSelection);return p&&!P.value&&l});$e(o,p=>{p&&(_.value=!0)});const z=ne(()=>{const p={};return s.value.forEach(l=>{const i=l.manualPuzzleSelection||l.ocrData?.puzzle;i&&(p[i]||(p[i]={puzzle:a.findPuzzleByName(i),files:[]}),p[i].files.push(l))}),p}),w=async()=>{if(u.value){P.value=!0;try{g({files:s.value,notes:y.value.trim()||void 0,manualValidationRequested:o.value||_.value}),c(),y.value="",_.value=!1}catch(p){console.error("Submission error:",p)}finally{P.value=!1}}};return(p,l)=>(f(),h("div",uo,[e("div",fo,[l[9]||(l[9]=e("h2",{class:"card-title text-xl mb-6"},[e("i",{class:"mdi mdi-check-circle text-2xl text-primary"}),q(" Submit Solution ")],-1)),e("form",{onSubmit:Xe(w,["prevent"]),class:"space-y-6"},[Object.keys(z.value).length>0?(f(),h("div",ho,[l[3]||(l[3]=e("i",{class:"mdi mdi-information-outline text-xl"},null,-1)),e("div",vo,[e("h4",mo," Detected Puzzles ("+x(Object.keys(z.value).length)+") ",1),e("div",go,[(f(!0),h(Q,null,ee(z.value,(i,v)=>(f(),h("div",{key:v,class:"flex justify-between"},[e("span",null,x(v),1),e("span",po,x(i.files.length)+" file(s)",1)]))),128))])])])):A("",!0),ze(co),I(r).length>0?(f(),h("div",bo,[l[6]||(l[6]=e("i",{class:"mdi mdi-alert-circle text-xl"},null,-1)),e("div",yo,[l[5]||(l[5]=e("div",{class:"font-bold"},"Manual Puzzle Selection Required",-1)),e("div",_o,x(I(r).length)+" file(s) have low OCR confidence for puzzle names. Please select the correct puzzle for each file before submitting. ",1),e("button",{class:"btn mt-3 w-full",onClick:l[0]||(l[0]=(...i)=>I(d)&&I(d)(...i))},[...l[4]||(l[4]=[e("span",{class:"mdi mdi-reload text-2xl"},null,-1),q(" Retry OCR on low confidence puzzle ",-1)])])])])):A("",!0),e("div",wo,[e("div",zo,[e("label",xo,[l[7]||(l[7]=e("span",{class:"label-text font-medium"},"Notes (Optional)",-1)),e("span",ko,x($.value)+"/500",1)]),ce(e("textarea",{"onUpdate:modelValue":l[1]||(l[1]=i=>y.value=i),class:"flex textarea textarea-bordered h-24 w-full resize-none",placeholder:"Add any notes about your solution, approach, or interesting findings...",maxlength:"500"},null,512),[[xe,y.value]])])]),e("div",So,[e("label",$o,[ce(e("input",{type:"checkbox","onUpdate:modelValue":l[2]||(l[2]=i=>_.value=i),class:"checkbox checkbox-primary",disabled:I(o)},null,8,Co),[[gs,_.value]]),l[8]||(l[8]=e("div",{class:"flex-1"},[e("span",{class:"label-text font-medium"},"Request manual validation"),e("div",{class:"label-text-alt text-xs opacity-70 mt-1"},[q(" Check this if you want an admin to manually review your submission, even if OCR confidence is high. "),e("br"),e("em",null,"Note: This will be automatically checked if any OCR confidence is below 80%.")])],-1))])]),e("div",Po,[e("button",{type:"submit",class:"btn btn-primary",disabled:!u.value},[P.value?(f(),h("span",Ro)):A("",!0),P.value?(f(),h("span",Eo,"Submitting...")):I(r).length>0?(f(),h("span",Oo," Select Puzzles ("+x(I(r).length)+" remaining) ",1)):(f(),h("span",Mo,"Submit Solution"))],8,Lo)])],32)])]))}}),Ao={class:"card bg-base-100 shadow-xl"},Do={class:"card-body"},jo={class:"stats stats-vertical lg:stats-horizontal shadow mb-6"},Io={class:"stat"},To={class:"stat-value text-primary"},qo={class:"stat"},Fo={class:"stat-value text-secondary"},Uo={class:"stat"},Bo={class:"stat-value text-warning"},Vo={class:"stat"},Go={class:"stat-value text-success"},Wo={key:0},Ho={class:"overflow-x-auto"},Jo={class:"table table-zebra"},Ko={class:"font-bold"},Yo={class:"text-sm opacity-50"},Zo={class:"text-sm space-y-1"},Qo={class:"flex justify-between items-center"},Xo={class:"flex justify-between items-center"},ea={class:"flex justify-between items-center"},ta={class:"badge badge-warning badge-sm"},sa=["onClick"],na=["onClick"],oa={key:1,class:"text-center py-8"},aa={key:0,class:"modal modal-open"},ra={class:"modal-box w-11/12 max-w-5xl"},la=["src"],ia={key:0,class:"space-y-4"},ca={class:"alert alert-info"},ua={class:"font-bold"},da={class:"grid grid-cols-4 gap-4"},fa={class:"form-control"},ha=["value"],va={class:"form-control"},ma=["placeholder"],ga={class:"form-control"},pa=["placeholder"],ba={class:"form-control"},ya=["placeholder"],_a={class:"modal-action"},wa=["disabled"],za={key:0,class:"loading loading-spinner loading-sm"},xa={class:"mockup-code w-full"},ka=me({__name:"AdminPanel",setup(n,{expose:a}){const t=Pe(),s=j({total_submissions:0,total_responses:0,needs_validation:0,validated_submissions:0,validation_rate:0}),o=j([]),r=j(!1),c=j(!1),d=j({show:!1,response:null,data:{puzzle:-1,validated_cost:0,validated_cycles:0,validated_area:0}}),g=async()=>{try{r.value=!0;try{const l=await ae.getStats();l.data&&(s.value=l.data)}catch(l){console.warn("Stats endpoint not available:",l),s.value={total_submissions:0,total_responses:0,needs_validation:0,validated_submissions:0,validation_rate:0}}const p=await ae.getResponsesNeedingValidation();p.data&&(o.value=p.data)}catch(p){console.error("Failed to load admin data:",p)}finally{r.value=!1}},y=async()=>{for(const p of Array.from(o.value)){if(!p.id)continue;const{data:l,error:i}=await ae.autoValidateResponses(p.id);if(l&&!l.needs_manual_validation)o.value=o.value.filter(v=>v.id!==p.id),s.value.needs_validation-=1;else if(i)break}},_=p=>{d.value.response=p,d.value.data={puzzle:p.puzzle_id||-1,validated_cost:p.cost||0,validated_cycles:p.cycles||0,validated_area:p.area||0},d.value.show=!0},P=()=>{d.value.show=!1,d.value.response=null,d.value.data={puzzle:-1,validated_cost:0,validated_cycles:0,validated_area:0}},$=async p=>{const{data:l}=await ae.autoValidateResponses(p);console.log(l),l&&!l.needs_manual_validation&&(o.value=o.value.filter(i=>i.id!==p),console.log(s.value),s.value.needs_validation-=1,console.log(s.value))},u=async()=>{if(d.value.response?.id)try{c.value=!0;const p=await ae.validateResponse(d.value.response.id,d.value.data);if(p.error){alert(`Validation failed: ${p.error}`);return}o.value=o.value.filter(l=>l.id!==d.value.response?.id),s.value.needs_validation=Math.max(0,s.value.needs_validation-1),P()}catch(p){console.error("Validation error:",p),alert("Validation failed")}finally{c.value=!1}};ot(()=>{g()});const z=p=>p>=.8?"badge-success":p>=.6?"badge-warning":"badge-error",w=p=>{const l=[p.ocr_confidence_cost,p.ocr_confidence_cycles,p.ocr_confidence_area].filter(v=>v!=null);if(l.length===0)return 0;const i=l.reduce((v,C)=>v+C,0)/l.length;return Math.round(i*100)};return a({refresh:g}),(p,l)=>(f(),h(Q,null,[e("div",Ao,[e("div",Do,[l[14]||(l[14]=e("h2",{class:"card-title"},[e("i",{class:"mdi mdi-shield-account text-2xl text-warning"}),q(" Admin Panel ")],-1)),e("div",jo,[e("div",Io,[l[4]||(l[4]=e("div",{class:"stat-title"},"Total Submissions",-1)),e("div",To,x(s.value.total_submissions),1)]),e("div",qo,[l[5]||(l[5]=e("div",{class:"stat-title"},"Total Responses",-1)),e("div",Fo,x(s.value.total_responses),1)]),e("div",Uo,[l[6]||(l[6]=e("div",{class:"stat-title"},"Need Validation",-1)),e("div",Bo,x(s.value.needs_validation),1)]),e("div",Vo,[l[7]||(l[7]=e("div",{class:"stat-title"},"Validation Rate",-1)),e("div",Go,x(Math.round(s.value.validation_rate*100))+"% ",1)])]),e("button",{class:"btn btn-sm btn-primary",onClick:y},[...l[8]||(l[8]=[e("i",{class:"mdi mdi-check-circle mr-1"},null,-1),q(" Auto validation for all responses ",-1)])]),o.value.length>0?(f(),h("div",Wo,[l[12]||(l[12]=e("h3",{class:"text-lg font-bold mb-4"},"Responses Needing Validation",-1)),e("div",Ho,[e("table",Jo,[l[11]||(l[11]=e("thead",null,[e("tr",null,[e("th",null,"Puzzle"),e("th",null,"OCR Data"),e("th",null,"Confidence"),e("th",null,"Actions")])],-1)),e("tbody",null,[(f(!0),h(Q,null,ee(o.value,i=>(f(),h("tr",{key:i.id},[e("td",null,[e("div",Ko,x(i.puzzle_name),1),e("div",Yo,"ID: "+x(i.id),1)]),e("td",null,[e("div",Zo,[e("div",Qo,[e("span",null,"Cost: "+x(i.cost||"-"),1),i.ocr_confidence_cost?(f(),h("span",{key:0,class:re(["badge badge-xs",z(i.ocr_confidence_cost)])},x(Math.round(i.ocr_confidence_cost*100))+"% ",3)):A("",!0)]),e("div",Xo,[e("span",null,"Cycles: "+x(i.cycles||"-"),1),i.ocr_confidence_cycles?(f(),h("span",{key:0,class:re(["badge badge-xs",z(i.ocr_confidence_cycles)])},x(Math.round(i.ocr_confidence_cycles*100))+"% ",3)):A("",!0)]),e("div",ea,[e("span",null,"Area: "+x(i.area||"-"),1),i.ocr_confidence_area?(f(),h("span",{key:0,class:re(["badge badge-xs",z(i.ocr_confidence_area)])},x(Math.round(i.ocr_confidence_area*100))+"% ",3)):A("",!0)])])]),e("td",null,[e("div",ta,x(w(i))+"% ",1)]),e("td",null,[e("button",{onClick:v=>_(i),class:"btn btn-sm btn-primary mr-2"},[...l[9]||(l[9]=[e("i",{class:"mdi mdi-check-circle mr-1"},null,-1),q(" Validate ",-1)])],8,sa),i.id?(f(),h("button",{key:0,onClick:v=>$(i.id),class:"btn btn-sm btn-warning"},[...l[10]||(l[10]=[e("i",{class:"mdi mdi-check-circle mr-1"},null,-1),q(" Auto Validation ",-1)])],8,na)):A("",!0)])]))),128))])])])])):(f(),h("div",oa,[...l[13]||(l[13]=[e("i",{class:"mdi mdi-check-all text-6xl text-success opacity-50"},null,-1),e("p",{class:"text-lg font-medium mt-2"},"All responses validated!",-1),e("p",{class:"text-sm opacity-70"}," No responses currently need manual validation. ",-1)])]))])]),d.value.show?(f(),h("div",aa,[e("div",ra,[l[22]||(l[22]=e("h3",{class:"font-bold text-lg mb-4"},"Validate Response",-1)),(f(!0),h(Q,null,ee(d.value.response?.files??[],i=>(f(),h("div",null,[e("img",{src:i.file_url},null,8,la)]))),256)),d.value.response?(f(),h("div",ia,[e("div",ca,[l[16]||(l[16]=e("i",{class:"mdi mdi-information-outline"},null,-1)),e("div",null,[e("div",ua,x(d.value.response.puzzle_name),1),l[15]||(l[15]=e("div",{class:"text-sm"},"Review and correct the OCR data below",-1))])]),e("div",da,[e("div",fa,[l[18]||(l[18]=e("label",{class:"label"},[e("span",{class:"label-text"},"Puzzle")],-1)),ce(e("select",{"onUpdate:modelValue":l[0]||(l[0]=i=>d.value.data.puzzle=i),class:"select select-bordered select-sm w-full"},[l[17]||(l[17]=e("option",{value:""},"Select puzzle...",-1)),(f(!0),h(Q,null,ee(I(t).puzzles,i=>(f(),h("option",{key:i.id,value:i.id},x(i.title),9,ha))),128))],512),[[Wt,d.value.data.puzzle]])]),e("div",va,[l[19]||(l[19]=e("label",{class:"label"},[e("span",{class:"label-text"},"Cost")],-1)),ce(e("input",{"onUpdate:modelValue":l[1]||(l[1]=i=>d.value.data.validated_cost=i),type:"text",class:"input input-bordered input-sm",placeholder:d.value.response.cost?.toString()||"Enter cost"},null,8,ma),[[xe,d.value.data.validated_cost]])]),e("div",ga,[l[20]||(l[20]=e("label",{class:"label"},[e("span",{class:"label-text"},"Cycles")],-1)),ce(e("input",{"onUpdate:modelValue":l[2]||(l[2]=i=>d.value.data.validated_cycles=i),type:"text",class:"input input-bordered input-sm",placeholder:d.value.response.cycles?.toString()||"Enter cycles"},null,8,pa),[[xe,d.value.data.validated_cycles]])]),e("div",ba,[l[21]||(l[21]=e("label",{class:"label"},[e("span",{class:"label-text"},"Area")],-1)),ce(e("input",{"onUpdate:modelValue":l[3]||(l[3]=i=>d.value.data.validated_area=i),type:"text",class:"input input-bordered input-sm",placeholder:d.value.response.area?.toString()||"Enter area"},null,8,ya),[[xe,d.value.data.validated_area]])])]),e("div",_a,[e("button",{onClick:P,class:"btn btn-ghost"}," Cancel "),e("button",{onClick:u,class:"btn btn-primary",disabled:c.value},[c.value?(f(),h("span",za)):A("",!0),q(" "+x(c.value?"Validating...":"Validate"),1)],8,wa)]),e("div",xa,[e("pre",null,[e("code",null,x(d.value),1)])])])):A("",!0)]),e("div",{class:"modal-backdrop",onClick:P})])):A("",!0)],64))}}),Sa={class:"mb-8"},$a={class:"grid grid-cols-1 lg:grid-cols-3 gap-8"},Ca={class:"lg:col-span-1"},Pa={class:"card bg-base-100 shadow-lg sticky top-8"},La={class:"card-body"},Ra={class:"text-center mb-6"},Ea={class:"text-3xl font-bold"},Oa={key:0,class:"flex justify-center py-8"},Ma={key:1,class:"space-y-4"},Na={class:"text-center"},Aa={key:0,class:"text-4xl font-bold text-primary"},Da={key:1,class:"text-2xl text-base-content/50"},ja={class:"text-center"},Ia={class:"text-2xl font-bold"},Ta={class:"text-center"},qa={class:"text-2xl font-bold"},Fa={class:"lg:col-span-2"},Ua={class:"card bg-base-100 shadow-lg"},Ba={class:"card-body"},Va={key:0,class:"flex justify-center py-8"},Ga={key:1,class:"text-center py-8"},Wa={key:2,class:"space-y-6"},Ha={class:"tabs tabs-boxed"},Ja={class:"space-y-4"},Ka={key:0,class:"text-center py-8"},Ya={key:1,class:"overflow-x-auto"},Za={class:"table table-zebra w-full"},Qa={class:"font-bold"},Xa={key:0,class:"badge badge-warning badge-lg"},er={key:1,class:"badge badge-lg"},tr={key:2,class:"badge badge-lg"},sr={key:3},nr={class:"font-medium"},or={class:"text-right"},ar={class:"text-right font-bold"},rr={class:"space-y-6"},lr=["onClick"],ir={class:"ml-auto badge badge-sm"},cr={key:0,class:"card-body"},ur={key:0,class:"text-center py-8"},dr={key:1,class:"space-y-6"},fr={class:"grid grid-cols-1 md:grid-cols-3 gap-4"},hr={class:"card-body p-4"},vr={class:"text-xs text-base-content/70 font-bold"},mr={class:"font-bold text-lg"},gr={class:"space-y-2 text-sm"},pr={class:"flex justify-between"},br={class:"badge badge-sm"},yr={class:"flex justify-between"},_r={class:"badge badge-sm"},wr={class:"flex justify-between"},zr={class:"badge badge-sm"},xr={class:"flex justify-between pt-2 border-t"},kr={class:"badge badge-sm"},Sr={class:"flex justify-between pt-2 border-t"},$r={class:"badge badge-primary"},Cr={class:"overflow-x-auto"},Pr={class:"table table-zebra w-full table-sm"},Lr={class:"font-bold"},Rr={key:0,class:"badge badge-warning"},Er={key:1,class:"badge"},Or={key:2,class:"badge"},Mr={key:3},Nr={class:"font-medium"},Ar={class:"text-center"},Dr={key:0,class:"badge badge-sm"},jr={key:1,class:"text-base-content/40"},Ir={class:"text-center"},Tr={key:0,class:"badge badge-sm"},qr={key:1,class:"text-base-content/40"},Fr={class:"text-center"},Ur={key:0,class:"badge badge-sm"},Br={key:1,class:"text-base-content/40"},Vr={class:"text-center"},Gr={key:0,class:"badge badge-sm"},Wr={key:1,class:"text-base-content/40"},Hr={class:"text-right font-bold text-primary text-lg"},Jr=me({__name:"Results",setup(n){const a=j(!0),t=j(null),s=j("overall"),o=j(null),r=j({username:"Player",rank:null,totalPoints:0,puzzlesSolved:0,isStaff:!1}),c=async()=>{a.value=!0;try{const $=await fetch("/api/results/results");if(!$.ok)throw new Error("Failed to fetch results");t.value=await $.json()}catch($){console.error("Error fetching results:",$)}finally{a.value=!1}},d=()=>t.value?t.value.users.map(u=>{const z=t.value.responses_by_userid[u.id]||[],w=z.reduce((l,i)=>l+(i.rank_points||0),0),p=z.length;return{username:u.username,totalPoints:w,puzzlesSolved:p}}).sort((u,z)=>z.totalPoints-u.totalPoints):[],g=$=>t.value?(t.value.ranking_by_puzzle[$]||[]).map(z=>(console.log(z),{username:t.value.users.find(p=>p.id===z.user_id)?.username||"Unknown",cost:z.final_cost,cycles:z.final_cycles,area:z.final_area,points:z.points,rank_points:z.rank_points||0})):[],y=$=>{o.value=o.value===$?null:$},_=async()=>{try{const $=await fetch("/api/cache/clear",{method:"POST"});if($.ok)alert("Cache cleared successfully!"),await c();else{const u=await $.json();alert(`Error clearing cache: ${u.detail||"Unknown error"}`)}}catch($){console.error("Error clearing cache:",$),alert("Error clearing cache. Please try again.")}},P=async()=>{try{const $=await fetch("/api/user");if($.ok){const u=await $.json();if(u.is_authenticated){r.value.username=u.username,r.value.isStaff=u.is_staff||!1,await c();const z=d(),w=z.findIndex(p=>p.username===u.username);w!==-1&&(r.value.rank=w+1,r.value.totalPoints=z[w].totalPoints,r.value.puzzlesSolved=z[w].puzzlesSolved)}}}catch($){console.error("Error loading user data:",$),await c()}};return ot(()=>{P()}),($,u)=>(f(),h("div",Sa,[e("div",$a,[e("div",Ca,[e("div",Pa,[u[9]||(u[9]=e("div",{class:"bg-gradient-to-br from-blue-600 to-blue-400 p-6 text-white rounded-t-2xl"},[e("i",{class:"mdi mdi-trophy text-4xl"}),e("h3",{class:"text-2xl font-bold mt-2"},"Your Ranking")],-1)),e("div",La,[e("div",Ra,[u[2]||(u[2]=e("p",{class:"text-sm text-base-content/70"},"Player",-1)),e("p",Ea,x(r.value.username),1)]),u[8]||(u[8]=e("div",{class:"divider"},null,-1)),a.value?(f(),h("div",Oa,[...u[3]||(u[3]=[e("span",{class:"loading loading-spinner loading-lg"},null,-1)])])):(f(),h("div",Ma,[e("div",Na,[u[4]||(u[4]=e("p",{class:"text-sm text-base-content/70 mb-1"},"Current Rank",-1)),r.value.rank!==null?(f(),h("p",Aa," #"+x(r.value.rank),1)):(f(),h("p",Da,"No rank yet"))]),e("div",ja,[u[5]||(u[5]=e("p",{class:"text-sm text-base-content/70 mb-1"},"Total Points",-1)),e("p",Ia,x(r.value.totalPoints.toLocaleString()),1)]),e("div",Ta,[u[6]||(u[6]=e("p",{class:"text-sm text-base-content/70 mb-1"},"Puzzles Solved",-1)),e("p",qa,x(r.value.puzzlesSolved),1)]),r.value.isStaff?(f(),h("button",{key:0,onClick:_,class:"btn btn-error btn-sm w-full mt-6"},[...u[7]||(u[7]=[e("i",{class:"mdi mdi-cache-clear mr-1"},null,-1),q(" Clear Cache ",-1)])])):A("",!0)]))])])]),e("div",Fa,[e("div",Ua,[e("div",Ba,[u[24]||(u[24]=e("h2",{class:"card-title text-2xl mb-6"},[e("i",{class:"mdi mdi-trophy text-yellow-500 mr-2"}),q(" General Results ")],-1)),a.value?(f(),h("div",Va,[...u[10]||(u[10]=[e("span",{class:"loading loading-spinner loading-lg"},null,-1)])])):t.value?(f(),h("div",Wa,[e("div",Ha,[e("button",{onClick:u[0]||(u[0]=z=>s.value="overall"),class:re(["tab",s.value==="overall"?"tab-active":""])},[...u[12]||(u[12]=[e("i",{class:"mdi mdi-chart-line mr-2"},null,-1),q(" Overall Ranking ",-1)])],2),e("button",{onClick:u[1]||(u[1]=z=>s.value="byPuzzle"),class:re(["tab",s.value==="byPuzzle"?"tab-active":""])},[...u[13]||(u[13]=[e("i",{class:"mdi mdi-puzzle mr-2"},null,-1),q(" By Puzzle ",-1)])],2)]),ce(e("div",Ja,[d().length===0?(f(),h("div",Ka,[...u[14]||(u[14]=[e("p",{class:"text-base-content/70"},"No submissions yet",-1)])])):(f(),h("div",Ya,[e("table",Za,[u[15]||(u[15]=e("thead",null,[e("tr",null,[e("th",null,"Rank"),e("th",null,"Player"),e("th",{class:"text-right"},"Puzzles Solved"),e("th",{class:"text-right"},"Total Points")])],-1)),e("tbody",null,[(f(!0),h(Q,null,ee(d(),(z,w)=>(f(),h("tr",{key:z.username},[e("td",Qa,[w===0?(f(),h("span",Xa," 🏆 #1 ")):w===1?(f(),h("span",er," 🥈 #2 ")):w===2?(f(),h("span",tr," 🥉 #3 ")):(f(),h("span",sr,"#"+x(w+1),1))]),e("td",nr,x(z.username),1),e("td",or,x(z.puzzlesSolved),1),e("td",ar,x(z.totalPoints),1)]))),128))])])]))],512),[[dt,s.value==="overall"]]),ce(e("div",rr,[(f(!0),h(Q,null,ee(t.value.puzzles,z=>(f(),h("div",{key:z.id,class:"card bg-base-100 border border-base-300"},[e("button",{onClick:w=>y(z.id),class:"btn btn-ghost btn-lg w-full justify-start text-lg font-bold hover:bg-primary/20 rounded-b-none"},[e("i",{class:re(["mdi mr-2",o.value===z.id?"mdi-chevron-down":"mdi-chevron-right"])},null,2),q(" "+x(z.title)+" ",1),e("span",ir,x(g(z.id).length)+" submissions ",1)],8,lr),o.value===z.id?(f(),h("div",cr,[g(z.id).length===0?(f(),h("div",ur,[...u[16]||(u[16]=[e("p",{class:"text-base-content/70 text-lg"},"No submissions yet",-1)])])):(f(),h("div",dr,[e("div",fr,[(f(!0),h(Q,null,ee(g(z.id).slice(0,3),(w,p)=>(f(),h("div",{key:p,class:"card bg-base-200"},[e("div",hr,[e("div",vr,x(p===0?"🏆 1st Place":p===1?"🥈 2nd Place":"🥉 3rd Place"),1),e("h4",mr,x(w.username),1),u[22]||(u[22]=e("div",{class:"divider my-2"},null,-1)),e("div",gr,[e("div",pr,[u[17]||(u[17]=e("span",null,"Cost",-1)),e("span",br,x(w.cost||"N/A"),1)]),e("div",yr,[u[18]||(u[18]=e("span",null,"Cycles",-1)),e("span",_r,x(w.cycles||"N/A"),1)]),e("div",wr,[u[19]||(u[19]=e("span",null,"Area",-1)),e("span",zr,x(w.area||"N/A"),1)]),e("div",xr,[u[20]||(u[20]=e("span",null,"Total (with coef.)",-1)),e("span",kr,x(w.points||"N/A"),1)]),e("div",Sr,[u[21]||(u[21]=e("span",{class:"font-bold"},"Points",-1)),e("span",$r,x(w.rank_points)+" pts",1)])])])]))),128))]),e("div",Cr,[e("table",Pr,[u[23]||(u[23]=e("thead",null,[e("tr",null,[e("th",{class:"w-12"},"Rank"),e("th",null,"Player"),e("th",{class:"text-center"},"Cost"),e("th",{class:"text-center"},"Cycles"),e("th",{class:"text-center"},"Area"),e("th",{class:"text-center"},"Total (with coef.)"),e("th",{class:"text-right"},"Points")])],-1)),e("tbody",null,[(f(!0),h(Q,null,ee(g(z.id),(w,p)=>(f(),h("tr",{key:p,class:re({"bg-primary/10":p<3})},[e("td",Lr,[p===0?(f(),h("span",Rr,"🏆")):p===1?(f(),h("span",Er,"🥈")):p===2?(f(),h("span",Or,"🥉")):(f(),h("span",Mr,"#"+x(p+1),1))]),e("td",Nr,x(w.username),1),e("td",Ar,[w.cost?(f(),h("span",Dr,x(w.cost),1)):(f(),h("span",jr,""))]),e("td",Ir,[w.cycles?(f(),h("span",Tr,x(w.cycles),1)):(f(),h("span",qr,""))]),e("td",Fr,[w.area?(f(),h("span",Ur,x(w.area),1)):(f(),h("span",Br,""))]),e("td",Vr,[w.points?(f(),h("span",Gr,x(w.points),1)):(f(),h("span",Wr,""))]),e("td",Hr,x(w.rank_points),1)],2))),128))])])])]))])):A("",!0)]))),128))],512),[[dt,s.value==="byPuzzle"]])])):(f(),h("div",Ga,[...u[11]||(u[11]=[e("p",{class:"text-base-content/70"},"No results available yet",-1)])]))])])])])]))}});function Tt(n,a){return Vt()?(Gt(n,a),!0):!1}const qt=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;function Kr(n,a=1e3,t={}){const{immediate:s=!0,immediateCallback:o=!1}=t;let r=null;const c=Ht(!1);function d(){r&&(clearInterval(r),r=null)}function g(){c.value=!1,d()}function y(){const _=ke(a);_<=0||(c.value=!0,o&&n(),d(),c.value&&(r=setInterval(n,_)))}return s&&qt&&y(),(ve(a)||typeof a=="function")&&Tt($e(a,()=>{c.value&&qt&&y()})),Tt(g),{isActive:ps(c),pause:g,resume:y}}function Yr(n,a){var t,s;const o=Ht(ke(n)),r=Kr(()=>{var _;const P=o.value-1;if(o.value=P<0?0:P,a==null||(_=a.onTick)===null||_===void 0||_.call(a),o.value<=0){var $;r.pause(),a==null||($=a.onComplete)===null||$===void 0||$.call(a)}},(t=a?.interval)!==null&&t!==void 0?t:1e3,{immediate:(s=a?.immediate)!==null&&s!==void 0?s:!1}),c=_=>{var P;o.value=(P=ke(_))!==null&&P!==void 0?P:ke(n)},d=()=>{r.pause(),c()},g=()=>{r.isActive.value||o.value>0&&r.resume()};return{remaining:o,reset:c,stop:d,start:_=>{c(_),r.resume()},pause:r.pause,resume:g,isActive:r.isActive}}const Zr={class:"min-h-screen bg-base-200"},Qr={class:"navbar bg-base-100 shadow-lg"},Xr={class:"container mx-auto w-full flex items-center gap-4"},el={class:"flex items-center gap-4"},tl={key:0,class:"flex items-center gap-2"},sl={class:"text-sm"},nl={class:"font-medium"},ol={key:0,class:"badge badge-warning badge-xs ml-1"},al={key:1,class:"text-sm text-base-content/70"},rl={class:"container mx-auto px-4 py-8"},ll={key:0,class:"flex justify-center"},il={class:"text-center"},cl={class:"mb-6 text-base-content/70"},ul={key:1,class:"flex justify-center items-center min-h-[400px]"},dl={key:2,class:"alert alert-error max-w-2xl mx-auto"},fl={class:"text-sm"},hl={key:3,class:"space-y-8"},vl={class:"mb-8"},ml={class:"card bg-base-100 shadow-lg"},gl={class:"card-body"},pl={class:"card-title text-2xl"},bl={class:"text-base-content/70"},yl={class:"flex flex-wrap gap-4 mt-4"},_l={key:0},wl={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},zl={key:1,class:"text-center py-12"},xl={key:0,class:"modal modal-open"},kl={class:"modal-box max-w-6xl"},Sl={class:"flex justify-between items-center mb-4"},$l=me({__name:"OpusMagnum",props:{collectionTitle:{},collectionUrl:{},collectionDescription:{}},setup(n){const a=n,t=Pe(),s=lt(),{submissions:o,isSubmissionModalOpen:r}=rt(s),{openSubmissionModal:c,loadSubmissions:d,closeSubmissionModal:g}=s,y=j(null),_=j(!0),P=j(""),$=ne(()=>y.value?.is_superuser||!1),u=ne(()=>{const C={};return o.value.forEach(S=>{S.responses.forEach(T=>{C[T.puzzle_id]||(C[T.puzzle_id]=[]),C[T.puzzle_id].push(T)})}),C});async function z(){try{_.value=!0,P.value="",console.log("Starting data load..."),console.log("Loading user info...");const C=await ae.getUserInfo();C.data?(y.value=C.data,console.log("User info loaded:",C.data)):C.error&&console.warn("User info error:",C.error),console.log("Loading puzzles..."),await t.loadPuzzles(),console.log("Puzzles loaded:",t.puzzles.length),console.log("Loading submissions..."),await d(),console.log("Submissions loaded:",o.value.length),console.log("Data load complete!")}catch(C){P.value=Qt.getErrorMessage(C),console.error("Failed to load data:",C)}finally{_.value=!1,console.log("Loading state set to false")}y.value?.is_superuser&&p()}const{remaining:w,start:p}=Yr(60,{onComplete(){z()}});ot(async()=>{await z()});const l=C=>t.findPuzzleByName(C),i=()=>{window.location.reload()},v=()=>{window.location.href="/"};return(C,S)=>(f(),h("div",Zr,[e("div",Qr,[e("div",Xr,[e("button",{onClick:v,class:"btn btn-primary btn-sm"},[...S[3]||(S[3]=[e("i",{class:"mdi mdi-arrow-left"},null,-1),q(" Back ",-1)])]),S[6]||(S[6]=e("h1",{class:"text-xl font-bold"},"Opus Magnum Puzzle Submitter",-1)),S[7]||(S[7]=e("div",{class:"flex-1"},null,-1)),e("div",el,[y.value?.is_authenticated?(f(),h("div",tl,[e("div",sl,[e("span",nl,x(y.value.username),1),y.value.is_superuser?(f(),h("span",ol,"Admin")):A("",!0)])])):(f(),h("div",al,"Not logged in")),S[4]||(S[4]=e("a",{href:"/api/docs",class:"btn btn-xs"},"API docs",-1)),S[5]||(S[5]=e("a",{href:"/admin",class:"btn btn-xs btn-warning"},"Admin panel",-1))])])]),e("div",rl,[y.value?.is_superuser?(f(),h("div",ll,[e("div",il,[e("p",cl,[S[8]||(S[8]=e("span",{class:"loading loading-spinner loading-lg"},null,-1)),q(" Auto reload page in "+x(I(w))+" seconds ... ",1)])])])):A("",!0),_.value?(f(),h("div",ul,[...S[9]||(S[9]=[e("div",{class:"text-center"},[e("span",{class:"loading loading-spinner loading-lg"}),e("p",{class:"mt-4 text-base-content/70"},"Loading puzzles...")],-1)])])):P.value?(f(),h("div",dl,[S[12]||(S[12]=e("i",{class:"mdi mdi-alert-circle text-xl"},null,-1)),e("div",null,[S[10]||(S[10]=e("h3",{class:"font-bold"},"Error Loading Data",-1)),e("div",fl,x(P.value),1)]),e("button",{onClick:i,class:"btn btn-sm btn-outline"},[...S[11]||(S[11]=[e("i",{class:"mdi mdi-refresh mr-1"},null,-1),q(" Retry ",-1)])])])):(f(),h("div",hl,[e("div",vl,[e("div",ml,[e("div",gl,[e("h2",pl,x(a.collectionTitle),1),e("p",bl,x(a.collectionDescription),1),e("div",yl,[e("button",{onClick:S[0]||(S[0]=(...T)=>I(c)&&I(c)(...T)),class:"btn btn-primary"},[...S[13]||(S[13]=[e("i",{class:"mdi mdi-plus mr-2"},null,-1),q(" Submit Solution ",-1)])])])])])]),ze(Jr),$.value?(f(),h("div",_l,[ze(ka)])):A("",!0),e("div",wl,[(f(!0),h(Q,null,ee(I(t).puzzles,T=>(f(),bs(sn,{key:T.id,puzzle:T,responses:u.value[T.id]||[]},null,8,["puzzle","responses"]))),128))]),I(t).puzzles.length===0?(f(),h("div",zl,[...S[14]||(S[14]=[e("div",{class:"text-6xl mb-4"},"🧩",-1),e("h3",{class:"text-xl font-bold mb-2"},"No Puzzles Available",-1),e("p",{class:"text-base-content/70"}," Check back later for new puzzle collections! ",-1)])])):A("",!0)]))]),I(r)?(f(),h("div",xl,[e("div",kl,[e("div",Sl,[S[16]||(S[16]=e("h3",{class:"font-bold text-lg"},"Submit Solution",-1)),e("button",{onClick:S[1]||(S[1]=(...T)=>I(g)&&I(g)(...T)),class:"btn btn-sm btn-circle btn-ghost"},[...S[15]||(S[15]=[e("i",{class:"mdi mdi-close"},null,-1)])])]),ze(No,{puzzles:I(t).puzzles,"find-puzzle-by-name":l},null,8,["puzzles"])]),e("div",{class:"modal-backdrop",onClick:S[2]||(S[2]=(...T)=>I(g)&&I(g)(...T))})])):A("",!0)]))}}),Cl=_s(),ns="#app",Pl=document.querySelector(ns),os=ys($l,{...Pl?.dataset});os.use(Cl);os.mount(ns);