globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="f75fcd3764d3a1a73710cfa9cac88454a450e0d29e090f3339b5f5d853594786";import{aH as A,aI as B,A as E,c as s,b7 as w,dZ as Q,J as C,b4 as g,a8 as I,aa as Y,H as R,bU as M,bT as F,d_ as i,d$ as x,e0 as b,e1 as L,e2 as D,e3 as G,bW as o,au as t,bF as c,b_ as W,b$ as m,dP as n,e4 as e,b3 as h,e5 as S,e6 as j}from"./houseplan-card-DrP8_MdR.js";import{GENERATED_FURNITURE_ART as r}from"./furniture-plan-art.generated-CJAWlM4T.js";const H="hp.pdf.options";class v extends B{constructor(){super(...arguments),this.options=null,this.busy=!1}willUpdate(){!this.options&&this.context?.space&&(this.options=function(){const A={dimensions:!0,roomNames:!0,decor:!1,backdrop:!0};try{const B=JSON.parse(localStorage.getItem(H)||"null");return 1===B?.v?{dimensions:!1!==B.dimensions,roomNames:!1!==B.roomNames,decor:!0===B.decor,backdrop:!1!==B.backdrop}:A}catch{return A}}())}setOption(A,B){this.options={...this.options||{dimensions:!0,roomNames:!0,decor:!1,backdrop:!0},[A]:B},this.requestUpdate()}async save(){if(!this.busy&&this.options){this.busy=!0,this.requestUpdate();try{try{localStorage.setItem(H,JSON.stringify({v:1,...this.options}))}catch{}await this.context.save(this.options),this.context.close()}catch(A){const B=A instanceof Error?A.message:"pdf.failed",E="pdf.too_large"===B||"pdf.asset_failed"===B?B:"pdf.failed";this.context.toast(this.context.t(E))}finally{this.busy=!1,this.requestUpdate()}}}render(){if(!this.context?.space)return E;const A=this.options||{dimensions:!0,roomNames:!0,decor:!1,backdrop:!0},B=(B,E)=>s``;return s`
${B("dimensions",this.context.t("pdf.dimensions"))} ${B("decor",this.context.t("pdf.decor"))} ${B("roomNames",this.context.t("pdf.room_names"))} ${this.context.space.bg?B("backdrop",this.context.t("pdf.backdrop")):E}
`}}v.properties={context:{attribute:!1}},v.styles=A`:host{display:contents;}.body{display:grid;gap:12px;width:100%;max-width:100%;min-width:0;padding:16px 20px;box-sizing:border-box;}label{display:flex;min-width:0;min-height:44px;align-items:center;gap:12px;cursor:pointer;}label span{min-width:0;overflow-wrap:anywhere;}input{width:20px;height:20px;flex:none;accent-color:var(--hp-accent,#d89300);}.row{display:flex;align-items:center;gap:8px;width:100%;max-width:100%;min-width:0;padding:12px 16px;box-sizing:border-box;}.spacer{flex:1;}button{min-width:0;min-height:44px;max-width:100%;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--hp-line,rgb(127 127 127/.3));border-radius:12px;padding:0 18px;box-sizing:border-box;overflow-wrap:anywhere;white-space:normal;background:transparent;color:inherit;font:inherit;cursor:pointer;}button.primary{background:var(--hp-accent,#d89300);color:var(--hp-on-accent,#111);border-color:transparent;}button:disabled{opacity:.55;cursor:default;}ha-icon{flex:none;margin-right:6px;}@media (max-width:360px){.row{display:grid;grid-template-columns:minmax(0,1fr);}.spacer{display:none;}button{width:100%;}}`,customElements.get("hp-pdf-dialog")||customElements.define("hp-pdf-dialog",v);const V=(A,B,E)=>Math.hypot(A[0]-B[0],A[1]-B[1])<=E,U=A=>Number.isFinite(A)&&A>=0?A:0;function l(A){const B=Number(A);return Number.isFinite(B)&&B>0?.1/B:0}const a=(A,B)=>[...new Set([...A,...B])].sort((A,B)=>A-B),P=(A,B)=>{const E=A.points.length;if(E<=1||!V(A.points[E-1],A.points[0],B))return!1;const s=E-2;return A.edgeSources[s]=a(A.edgeSources[s],A.edgeSources[E-1]),A.points.splice(E-1,1),A.edgeSources.splice(E-1,1),!0},y=(A,B)=>{for(let E=0;E+1{let E=!1;for(;A.points.length>1;)if(P(A,B))E=!0;else{if(!y(A,B))break;E=!0}return E},N=(A,B,E)=>{const s=B[0]-A[0],w=B[1]-A[1],C=E[0]-B[0],g=E[1]-B[1],I=Math.hypot(s,w),Y=Math.hypot(C,g);if(!(I>0&&Y>0))return!1;const R=s*C+w*g;if(!(R>0))return!1;const M=s*g-w*C;return Math.abs(M)<=R*Q},K=A=>{const B=A.points.length;if(B<3)return!1;for(let E=0;E{const E=U(B),s=[],w=[];for(let B=0;B[A])};for(;Q.points.length>1;){const A=u(Q,E);if(Q.points.length<3)break;if(!K(Q)&&!A)break}return u(Q,E),Q};function J(A,B){const E=Number(A[0]),s=Number(A[1]),w=Number(B[0]),C=Number(B[1]);if(![E,s,w,C].every(Number.isFinite))return null;const g=w-E,I=C-s,Y=Math.abs(g),R=Math.abs(I),M=Math.max(Y,R),F=Math.min(Y,R);if(!(M>0)||F/M>Q)return null;const i=[(E+w)/2,(s+C)/2];if(Y>=R){return{axis:"horizontal",a:[E,i[1]],b:[w,i[1]],mid:i,projectedLength:Y,tangentInterval:[Math.min(E,w),Math.max(E,w)],normalCoordinate:i[1]}}return{axis:"vertical",a:[i[0],s],b:[i[0],C],mid:i,projectedLength:R,tangentInterval:[Math.min(s,C),Math.max(s,C)],normalCoordinate:i[0]}}function Z(A,B){const E=B.map(A=>[Number(A[0]),Number(A[1])]);if(!E.every(A=>A.every(Number.isFinite)))return!1;if(E.length<3||((A,B)=>{const E=1e-12*Math.max(1,Math.abs(A[0]),Math.abs(A[1]),...B.flatMap(A=>[Math.abs(A[0]),Math.abs(A[1])]));for(let s=0;s0))continue;const Y=(A[0]-w[0])*g-(A[1]-w[1])*C;if(Math.abs(Y)>E*I)continue;const R=(A[0]-w[0])*C+(A[1]-w[1])*g;if(R>=-E&&R<=I*I+E)return!0}return!1})(A,E))return!1;let s=!1;for(let B=0,w=E.length-1;BA[1]==C[1]>A[1])continue;const g=(C[0]-Q[0])*(A[1]-Q[1])/(C[1]-Q[1])+Q[0];A[0]Object.is(A,-0)?0:A,I=[g(-Q/C),g(w/C)],Y=[g(-I[0]),g(-I[1])],R=[(B[0]+E[0])/2,(B[1]+E[1])/2],M=Math.max(1,C,Math.abs(R[0]),Math.abs(R[1])),F=Math.max(1e-9*M,.01*U(s));for(const B of[F,4*F,16*F]){const E=Z([R[0]+I[0]*B,R[1]+I[1]*B],A);if(E!==Z([R[0]+Y[0]*B,R[1]+Y[1]*B],A))return E?I:Y}return sA(A)>=0?I:Y}function f(A,B){let E=180*Math.atan2(B[1]-A[1],B[0]-A[0])/Math.PI;return E>90&&(E-=180),E<=-90&&(E+=180),E}function k(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);return z(d(A,Q),w,E,{...s,epsilon:Q})}const z=(A,B,E,s)=>{if(A.points.length<3)return[];const Q=U(s.epsilon??l(B)),C=Number.isFinite(Number(s.ringIndex))?Number(s.ringIndex):0,g=[];for(let s=0;sQ))continue;const M=[...A.edgeSources[s]||[s]].sort((A,B)=>A-B),F=M[0]??s,i=T(A.points,R.a,R.b,Q),x=("horizontal"===R.axis?i[1]:i[0])<0?-1:1,b=[R.axis,O(R.tangentInterval[0]),String(x),O(C),O(F)].join("|"),L=R.projectedLength*B;g.push({sourceA:[...I],sourceB:[...Y],a:R.a,b:R.b,text:w(L,E),short:L<30,angle:f(R.a,R.b),mid:R.mid,axis:R.axis,projectedLength:R.projectedLength,tangentInterval:R.tangentInterval,normalCoordinate:R.normalCoordinate,inwardNormal:i,normalSign:x,source:{ringIndex:C,edgeIndex:F},sourceEdgeIndices:M,stableKey:b})}return g};function p(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);let C=d(A,Q);if(sA(C.points)<0&&(C=(A=>{const B=A.points.length;return{points:[...A.points].reverse().map(A=>[...A]),edgeSources:A.points.map((E,s)=>[...A.edgeSources[(B-2-s+B)%B]])}})(C)),C.points.length){let A=0;for(let B=1;B({points:[...A.points.slice(B),...A.points.slice(0,B)],edgeSources:[...A.edgeSources.slice(B),...A.edgeSources.slice(0,B)]}))(C,A)}return z(C,w,E,{...s,epsilon:Q})}function X(A,B){const E=U(B),s=[];for(const B of A){const A=s.find(A=>A.axis===B.axis&&A.normalSign===B.normalSign&&Math.abs(A.normalCoordinate-B.normalCoordinate)<=E);A?A.edges.push(B):s.push({axis:B.axis,normalSign:B.normalSign,normalCoordinate:B.normalCoordinate,edges:[B]})}return s.map(A=>A.edges)}const O=A=>Object.is(A,-0)?"0":String(A),q=A=>"horizontal"===A?0:1;function $(A,B){return q(A.axis)-q(B.axis)||A.tangentInterval[0]-B.tangentInterval[0]||A.normalSign-B.normalSign||A.source.ringIndex-B.source.ringIndex||A.source.edgeIndex-B.source.edgeIndex}function _(A,B,E,s){const w=U(s);if(A.axis!==B.axis)return!1;if(A.source.ringIndex!==B.source.ringIndex)return!1;if(A.inwardNormal[0]*B.inwardNormal[0]+A.inwardNormal[1]*B.inwardNormal[1]>=-.5)return!1;if(!((A,B,E)=>Math.abs(A[0]-B[0])<=E&&Math.abs(A[1]-B[1])<=E)(A.tangentInterval,B.tangentInterval,w))return!1;if(Math.abs(A.projectedLength-B.projectedLength)>w)return!1;return Z([(A.mid[0]+B.mid[0])/2,(A.mid[1]+B.mid[1])/2],E)}const AA=(A,B)=>{const E=B?.(A);return{hardCollisions:Number.isFinite(Number(E?.hardCollisions))?Number(E?.hardCollisions):0,normalClearance:Number.isFinite(Number(E?.normalClearance))?Number(E?.normalClearance):0}},BA=(A,B,E)=>{const s=AA(A,E),w=AA(B,E);return s.hardCollisions-w.hardCollisions||w.normalClearance-s.normalClearance||$(A,B)};function EA(A,B){if(A.length<2)return[...A];const E=U(B.epsilon),s=function(A,B=1e-7){return d(A,B).points.map(A=>[...A])}(B.ring,E),w=[];for(let B=0;B{const E=A.separation-B.separation;if(E)return E;const s=$(A.left,A.right)<=0?A.left:A.right,w=s===A.left?A.right:A.left,Q=$(B.left,B.right)<=0?B.left:B.right,C=Q===B.left?B.right:B.left;return $(s,Q)||$(w,C)});const Q=new Set,C=new Set;for(const A of w){if(Q.has(A.left)||Q.has(A.right))continue;Q.add(A.left),Q.add(A.right);const E=BA(A.left,A.right,B.score)<=0?A.left:A.right;C.add(E===A.left?A.right:A.left)}return A.filter(A=>!C.has(A))}function sA(A){let B=0;for(let E=0;E1){const A=Math.sqrt(G);Y*=A,R*=A}const o=Math.max(0,Y*Y*R*R-Y*Y*D*D-R*R*L*L),t=Y*Y*D*D+R*R*L*L||1,c=(Q===C?-1:1)*Math.sqrt(o/t),W=c*Y*D/R,m=c*-R*L/Y,n=F*W-i*m+(A+g)/2,e=i*W+F*m+(B+I)/2;let h=gA(1,0,(L-W)/Y,(D-m)/R),S=gA((L-W)/Y,(D-m)/R,(-L-W)/Y,(-D-m)/R);!C&&S>0&&(S-=2*Math.PI),C&&S<0&&(S+=2*Math.PI);const j=Math.max(1,Math.ceil(Math.abs(S)/(Math.PI/2))),r=S/j,H=A=>[n+F*Y*Math.cos(A)-i*R*Math.sin(A),e+i*Y*Math.cos(A)+F*R*Math.sin(A)],v=A=>[-F*Y*Math.sin(A)-i*R*Math.cos(A),-i*Y*Math.sin(A)+F*R*Math.cos(A)],V=[];for(let A=0;A[B.a*A+B.c*E+B.e,B.b*A+B.d*E+B.f];return function(A){const B=A.match(/[AaCcHhLlMmQqSsTtVvZz]|[-+]?(?:\d*\.\d+|\d+\.?)(?:e[-+]?\d+)?/gi)||[],E=[];let s=0,w="",Q=0,C=0,g=0,I=0,Y=null,R=null;const M=()=>Number(B[s++]);for(;sB.length||QA.test(B[s]))throw new Error(`Invalid SVG path command ${w}`);const x=Array.from({length:i},M),b=A=>A+(F?Q:0),L=A=>A+(F?C:0);if("M"===A||"L"===A)Q=b(x[0]),C=L(x[1]),E.push({op:"M"===A?"M":"L",x:Q,y:C}),"M"===A&&(g=Q,I=C,w=F?"l":"L"),Y=R=null;else if("H"===A)Q=b(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("V"===A)C=L(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("C"===A){const A=b(x[0]),B=L(x[1]),s=b(x[2]),w=L(x[3]);Q=b(x[4]),C=L(x[5]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("S"===A){const A=Y?2*Q-Y[0]:Q,B=Y?2*C-Y[1]:C,s=b(x[0]),w=L(x[1]);Q=b(x[2]),C=L(x[3]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("Q"===A||"T"===A){const B="Q"===A?b(x[0]):R?2*Q-R[0]:Q,s="Q"===A?L(x[1]):R?2*C-R[1]:C,w=b("Q"===A?x[2]:x[0]),g=L("Q"===A?x[3]:x[1]);E.push({op:"C",x1:Q+2/3*(B-Q),y1:C+2/3*(s-C),x2:w+2/3*(B-w),y2:g+2/3*(s-g),x:w,y:g}),Q=w,C=g,R=[B,s],Y=null}else if("A"===A){const A=b(x[5]),B=L(x[6]),s=IA(Q,C,x[0],x[1],x[2],x[3],x[4],A,B);s.length?E.push(...s):E.push({op:"L",x:A,y:B}),Q=A,C=B,Y=R=null}}return E}(A).map(A=>{if("Z"===A.op)return A;if("M"===A.op||"L"===A.op){const[B,s]=E(A.x,A.y);return{op:A.op,x:B,y:s}}if("C"!==A.op)throw new Error("Unsupported PDF vector operation");const[B,s]=E(A.x1,A.y1),[w,Q]=E(A.x2,A.y2),[C,g]=E(A.x,A.y);return{op:"C",x1:B,y1:s,x2:w,y2:Q,x:C,y:g}})}const RA=["M20.82,15.31h0L10.46,9c-.46-.26-1.11.37-.86.84l6.15,10.56,10.56,6.15a.66.66,0,0,0,.84-.86Zm-4,4,3-3,4.55,7.44Z","M18,2A16,16,0,1,0,34,18,16,16,0,0,0,18,2Zm1,29.95V29.53H17v2.42A14,14,0,0,1,4.05,19H6.47V17H4.05A14,14,0,0,1,17,4.05V6.47h2V4.05A14,14,0,0,1,31.95,17H29.53v2h2.42A14,14,0,0,1,19,31.95Z"],MA=A=>Math.abs(A)<1e-12?0:Math.abs(A-1)<1e-12?1:Math.abs(A+1)<1e-12?-1:A;function FA(A){const B=function(A){const{centerX:B,centerY:E,size:s,northDeg:w}=A;if(![B,E,s,w].every(Number.isFinite)||s<=0)throw new RangeError("PDF compass placement must contain finite coordinates and a positive size");const Q=((w%360+360)%360+45)*Math.PI/180,C=s/36,g=MA(Math.cos(Q)),I=MA(Math.sin(Q)),Y=C*g,R=C*I,M=-C*I,F=C*g;return{a:Y,b:R,c:M,d:F,e:B-18*Y-18*M,f:E-18*R-18*F}}(A);return RA.flatMap(A=>YA(A,B))}const iA=1e-8,xA=A=>A.length>=2&&Number.isFinite(A[0])&&Number.isFinite(A[1]),bA=(A,B)=>A[0]>=B.minX-iA&&A[0]<=B.maxX+iA&&A[1]>=B.minY-iA&&A[1]<=B.maxY+iA,LA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,DA=A=>[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]];const GA=(A,B,E)=>(B[0]-A[0])*(E[1]-A[1])-(B[1]-A[1])*(E[0]-A[0]),oA=(A,B,E)=>{const s=E[0]-B[0],w=E[1]-B[1],Q=Math.abs(s)>=Math.abs(w)?s:w;return Math.abs(Q)<=iA?0:(Math.abs(s)>=Math.abs(w)?A[0]-B[0]:A[1]-B[1])/Q},tA=(A,B)=>Math.hypot(B[0]-A[0],B[1]-A[1]);function cA(A,B,E){const s=tA(B,E);if(s<=iA)return tA(A,B)<=iA;if(Math.abs(GA(B,E,A))/s>iA)return!1;const w=oA(A,B,E),Q=iA/s;return w>=-Q&&w<=1+Q}function WA(A,B,E,s){const w=B[0]-A[0],Q=B[1]-A[1],C=s[0]-E[0],g=s[1]-E[1],I=Math.hypot(w,Q),Y=Math.hypot(C,g);if(I<=iA)return cA(A,E,s)?{t:0,endT:0,overlap:!1}:null;if(Y<=iA){if(!cA(E,A,B))return null;const s=Math.max(0,Math.min(1,oA(E,A,B)));return{t:s,endT:s,overlap:!1}}const R=w*g-Q*C,M=E[0]-A[0],F=E[1]-A[1],i=iA*I*Y;if(Math.abs(R)<=i){if(Math.abs(GA(A,B,E))/I>iA||Math.abs(GA(A,B,s))/I>iA)return null;const w=oA(E,A,B),Q=oA(s,A,B),C=Math.max(0,Math.min(w,Q)),g=Math.min(1,Math.max(w,Q));return giA}}const x=(M*g-F*C)/R,b=(M*Q-F*w)/R,L=iA/I,D=iA/Y;if(x<-L||x>1+L||b<-D||b>1+D)return null;const G=Math.max(0,Math.min(1,x));return{t:G,endT:G,overlap:!1}}const mA=A=>A.every(A=>A.length>=2&&A.every(xA));function nA(A,B){for(const E of A){const A=E;for(let E=0;Enull!==WA(A,B,E,s[(w+1)%s.length]))}const hA=2048,SA=2146,jA=[-1825,-555,4188,2163],rA={32:1,33:2,34:3,35:4,36:5,37:6,38:7,39:8,40:9,41:10,42:11,43:12,44:13,45:14,46:15,47:16,48:17,49:18,50:19,51:20,52:21,53:22,54:23,55:24,56:25,57:26,58:27,59:28,60:29,61:30,62:31,63:32,64:33,65:34,66:35,67:36,68:37,69:38,70:39,71:40,72:41,73:42,74:43,75:44,76:45,77:46,78:47,79:48,80:49,81:50,82:51,83:52,84:53,85:54,86:55,87:56,88:57,89:58,90:59,91:60,92:61,93:62,94:63,95:64,96:65,97:66,98:67,99:68,100:69,101:70,102:71,103:72,104:73,105:74,106:75,107:76,108:77,109:78,110:79,111:80,112:81,113:82,114:83,115:84,116:85,117:86,118:87,119:88,120:89,121:90,122:91,123:92,124:93,125:94,126:95,160:596,161:96,162:97,163:98,164:99,165:100,166:101,167:102,168:103,169:104,170:105,171:106,172:107,173:597,174:108,175:109,176:110,177:111,178:112,179:113,180:114,181:115,182:116,183:117,184:118,185:119,186:120,187:121,188:122,189:123,190:124,191:125,192:603,193:604,194:605,195:606,196:607,197:608,198:126,199:609,200:610,201:611,202:612,203:613,204:614,205:615,206:616,207:617,208:599,209:618,210:619,211:620,212:621,213:622,214:623,215:127,216:128,217:624,218:625,219:626,220:627,221:628,222:129,223:130,224:629,225:630,226:631,227:632,228:633,229:634,230:131,231:635,232:636,233:637,234:638,235:639,236:640,237:641,238:642,239:643,240:132,241:644,242:645,243:646,244:647,245:648,246:649,247:133,248:134,249:650,250:651,251:652,252:653,253:654,254:135,255:655,256:656,257:657,258:658,259:659,260:660,261:661,262:662,263:663,264:664,265:665,266:666,267:667,268:668,269:669,270:670,271:671,272:598,273:136,274:672,275:673,276:674,277:675,278:676,279:677,280:678,281:679,282:680,283:681,284:682,285:683,286:684,287:685,288:686,289:687,290:688,291:689,292:690,293:691,294:137,295:600,296:692,297:693,298:694,299:695,300:696,301:697,302:698,303:699,304:700,305:138,306:701,307:702,308:703,309:704,310:705,311:706,312:139,313:707,314:708,315:709,316:710,317:711,318:712,319:713,320:714,321:140,322:141,323:715,324:716,325:717,326:718,327:719,328:720,329:721,330:142,331:143,332:722,333:723,334:724,335:725,336:726,337:727,338:144,339:145,340:728,341:729,342:730,343:731,344:732,345:733,346:734,347:735,348:736,349:737,350:738,351:739,352:742,353:743,354:744,355:745,356:746,357:747,358:601,359:602,360:748,361:749,362:750,363:751,364:752,365:753,366:754,367:755,368:756,369:757,370:758,371:759,372:760,373:761,374:762,375:763,376:764,377:765,378:766,379:767,380:768,381:769,382:770,383:146,1024:897,1025:856,1026:165,1027:857,1028:166,1029:858,1030:859,1031:860,1032:861,1033:167,1034:168,1035:169,1036:863,1037:898,1038:864,1039:170,1040:865,1041:171,1042:866,1043:867,1044:172,1045:868,1046:173,1047:174,1048:175,1049:869,1050:862,1051:176,1052:870,1053:871,1054:872,1055:873,1056:874,1057:875,1058:876,1059:177,1060:178,1061:877,1062:179,1063:180,1064:181,1065:182,1066:183,1067:184,1068:185,1069:186,1070:187,1071:188,1072:878,1073:189,1074:190,1075:191,1076:192,1077:879,1078:193,1079:194,1080:195,1081:880,1082:196,1083:197,1084:198,1085:199,1086:881,1087:200,1088:882,1089:883,1090:201,1091:884,1092:202,1093:885,1094:203,1095:204,1096:205,1097:206,1098:207,1099:208,1100:209,1101:210,1102:211,1103:212,1104:899,1105:886,1106:213,1107:887,1108:214,1109:888,1110:889,1111:890,1112:891,1113:215,1114:216,1115:217,1116:892,1117:900,1118:893,1119:218,1120:219,1121:220,1122:965,1123:221,1124:222,1125:223,1126:224,1127:225,1128:226,1129:227,1130:228,1131:229,1132:230,1133:231,1134:232,1135:233,1136:901,1137:902,1138:234,1139:235,1140:236,1141:237,1142:903,1143:904,1144:906,1145:905,1146:238,1147:239,1148:240,1149:241,1150:242,1151:243,1152:244,1153:245,1154:246,1155:247,1156:248,1157:249,1158:250,1159:251,1160:252,1161:253,1162:254,1163:255,1164:964,1165:256,1166:257,1167:258,1168:259,1169:260,1170:966,1171:967,1172:261,1173:262,1174:263,1175:264,1176:907,1177:908,1178:265,1179:266,1180:267,1181:268,1182:968,1183:969,1184:269,1185:270,1186:271,1187:272,1188:273,1189:274,1190:275,1191:276,1192:277,1193:278,1194:909,1195:910,1196:955,1197:956,1198:911,1199:912,1200:970,1201:971,1202:279,1203:280,1204:281,1205:282,1206:283,1207:284,1208:285,1209:286,1210:287,1211:963,1212:288,1213:289,1214:961,1215:962,1216:913,1217:914,1218:915,1219:290,1220:291,1221:292,1222:293,1223:294,1224:295,1225:296,1226:297,1227:957,1228:958,1229:298,1230:299,1231:916,1232:917,1233:918,1234:919,1235:920,1236:921,1237:922,1238:923,1239:924,1240:300,1241:926,1242:925,1243:927,1244:928,1245:929,1246:930,1247:931,1248:301,1249:302,1250:932,1251:933,1252:934,1253:935,1254:936,1255:937,1256:938,1257:939,1258:940,1259:941,1260:942,1261:943,1262:944,1263:945,1264:946,1265:947,1266:948,1267:949,1268:950,1269:951,1270:959,1271:960,1272:952,1273:953,1274:303,1275:304,1276:305,1277:306,1278:972,1279:973,1280:307,1281:954,1282:308,1283:309,1284:310,1285:311,1286:312,1287:313,1288:314,1289:315,1290:316,1291:317,1292:318,1293:319,1294:320,1295:321,1296:322,1297:974,1298:323,1299:324,1300:325,1301:326,1302:327,1303:328,1304:329,1305:330,1306:982,1307:983,1308:984,1309:985,1310:331,1311:332,1312:333,1313:334,1314:335,1315:336,1316:337,1317:338,1318:339,1319:340,1320:341,1321:342,1322:343,1323:344,1324:345,1325:346,1326:347,1327:348,8192:349,8193:350,8194:351,8195:352,8196:353,8197:354,8198:355,8199:356,8200:357,8201:358,8202:360,8203:361,8204:362,8205:363,8206:364,8207:365,8208:366,8209:367,8210:368,8211:369,8212:370,8213:975,8214:371,8215:372,8216:373,8217:374,8218:375,8219:376,8220:377,8221:378,8222:379,8223:380,8224:381,8225:382,8226:383,8227:384,8228:385,8229:386,8230:387,8231:388,8239:986,8240:389,8241:390,8242:894,8243:895,8244:391,8245:392,8246:393,8247:394,8248:395,8249:396,8250:397,8251:398,8252:896,8253:399,8254:400,8255:401,8256:402,8257:403,8258:404,8259:405,8260:406,8261:407,8262:408,8263:987,8264:988,8265:989,8266:409,8267:410,8268:411,8269:412,8270:413,8271:414,8272:415,8273:416,8274:417,8275:418,8276:419,8277:420,8278:421,8279:422,8280:423,8281:424,8282:425,8283:426,8284:427,8285:428,8286:429,8287:990,8364:430,8381:431,8776:433},HA={1:507,2:527,3:655,4:1261,5:1150,6:1500,7:1273,8:357,9:700,10:712,11:882,12:1161,13:402,14:565,15:539,16:844,17:1150,18:1150,19:1150,20:1150,21:1150,22:1150,23:1150,24:1150,25:1150,26:1150,27:496,28:433,29:1041,30:1124,31:1070,32:967,33:1839,34:1336,35:1275,36:1333,37:1343,38:1164,39:1132,40:1395,41:1460,42:557,43:1130,44:1284,45:1102,46:1788,47:1460,48:1408,49:1292,50:1408,51:1261,52:1215,53:1222,54:1328,55:1303,56:1817,57:1284,58:1230,59:1226,60:543,61:840,62:543,63:856,64:924,65:633,66:1114,67:1149,68:1072,69:1155,70:1085,71:711,72:1149,73:1128,74:497,75:489,76:1038,77:497,78:1795,79:1130,80:1168,81:1149,82:1164,83:693,84:1056,85:669,86:1129,87:992,88:1539,89:1015,90:969,91:1015,92:693,93:499,94:693,95:1393,96:499,97:1120,98:1190,99:1460,100:1075,101:491,102:1256,103:856,104:1609,105:915,106:961,107:1134,108:1610,109:938,110:765,111:1094,112:751,113:751,114:642,115:1160,116:1001,117:534,118:507,119:751,120:931,121:960,122:1500,123:1589,124:1593,125:969,126:1914,127:1092,128:1408,129:1210,130:1218,131:1729,132:1200,133:1169,134:1160,135:1180,136:1223,137:1434,138:506,139:1139,140:1103,141:553,142:1419,143:1160,144:1953,145:1860,146:508,165:1535,166:1380,167:2193,168:2212,169:1666,170:1460,171:1291,172:1540,173:1859,174:1215,175:1460,176:1449,177:1287,178:1580,179:1497,180:1402,181:1927,182:1984,183:1554,184:1771,185:1285,186:1380,187:1831,188:1304,189:1132,190:1170,191:859,192:1236,193:1568,194:1040,195:1182,196:1106,197:1184,198:1519,199:1181,200:1182,201:984,202:1485,203:1213,204:1113,205:1656,206:1694,207:1271,208:1590,209:1112,210:1101,211:1671,212:1124,213:1128,214:1101,215:1737,216:1764,217:1161,218:1182,219:1800,220:1579,221:1110,222:1835,223:1528,224:1234,225:1094,226:1803,227:1547,228:1745,229:1505,230:2308,231:2001,232:1059,233:987,234:1393,235:1163,236:1290,237:1027,238:1393,239:1160,240:1793,241:1572,242:1800,243:1579,244:1330,245:1095,246:1277,247:1024,248:1024,249:1024,250:1024,251:1024,252:1024,253:1024,254:1545,255:1261,256:1110,257:1307,258:1161,259:1123,260:912,261:1243,262:1029,263:1954,264:1633,265:1434,266:1208,267:1289,268:1150,269:1676,270:1411,271:1535,272:1241,273:1999,274:1460,275:2097,276:1780,277:1518,278:1235,279:1304,280:1066,281:1836,282:1372,283:1468,284:1174,285:1391,286:1130,287:1391,288:1583,289:1213,290:1289,291:1114,292:1534,293:1263,294:1458,295:1160,296:1554,297:1260,298:1871,299:1598,300:1415,301:1192,302:1192,303:1207,304:939,305:1326,306:1088,307:1270,308:1684,309:1764,310:1622,311:1323,312:1097,313:1031,314:1985,315:1653,316:2043,317:1697,318:1270,319:1053,320:1453,321:1312,322:1380,323:1538,324:1266,325:1920,326:1549,327:1857,328:1547,329:1926,330:1774,331:1316,332:1106,333:2274,334:1832,335:2300,336:1829,337:1526,338:1242,339:1468,340:1208,341:1539,342:1273,343:2710,344:2238,345:1568,346:1240,347:1515,348:1243,349:1044,350:2089,351:1044,352:2089,353:697,354:522,355:348,356:1151,357:560,358:418,360:209,361:1024,362:1024,363:1024,364:1024,365:1024,366:564,367:564,368:1171,369:1344,370:1599,371:778,372:933,373:409,374:409,375:407,376:409,377:724,378:731,379:705,380:764,381:1129,382:1167,383:690,384:1100,385:511,386:964,387:1370,388:382,389:1962,390:2360,391:1045,392:463,393:757,394:1045,395:803,396:614,397:614,398:1241,399:919,400:952,401:1540,402:1540,403:874,404:1370,405:870,406:931,407:640,408:641,409:907,410:1001,411:1237,412:1237,413:985,414:511,415:1541,416:985,417:931,418:1366,419:1540,420:1172,421:932,422:1333,423:1215,424:1125,425:379,426:1071,427:1162,428:379,429:379,430:1150,431:1359,433:1154,596:507,597:565,598:1373,599:1373,600:1158,601:1222,602:669,603:1336,604:1336,605:1336,606:1336,607:1336,608:1336,609:1333,610:1164,611:1164,612:1164,613:1164,614:557,615:557,616:557,617:557,618:1460,619:1408,620:1408,621:1408,622:1408,623:1408,624:1328,625:1328,626:1328,627:1328,628:1230,629:1114,630:1114,631:1114,632:1114,633:1114,634:1114,635:1072,636:1085,637:1085,638:1085,639:1085,640:506,641:506,642:506,643:506,644:1130,645:1168,646:1168,647:1168,648:1168,649:1168,650:1129,651:1129,652:1129,653:1129,654:969,655:969,656:1336,657:1114,658:1336,659:1114,660:1336,661:1114,662:1333,663:1072,664:1333,665:1072,666:1333,667:1072,668:1333,669:1072,670:1343,671:1305,672:1164,673:1085,674:1164,675:1085,676:1164,677:1085,678:1164,679:1085,680:1164,681:1085,682:1395,683:1149,684:1395,685:1149,686:1395,687:1149,688:1395,689:1149,690:1460,691:1128,692:557,693:506,694:557,695:506,696:557,697:506,698:557,699:497,700:557,701:1687,702:986,703:1130,704:515,705:1284,706:1038,707:1102,708:497,709:1102,710:497,711:1102,712:647,713:1102,714:717,715:1460,716:1130,717:1460,718:1130,719:1460,720:1130,721:1130,722:1408,723:1168,724:1408,725:1168,726:1408,727:1168,728:1261,729:693,730:1261,731:693,732:1261,733:693,734:1215,735:1056,736:1215,737:1056,738:1215,739:1056,742:1215,743:1056,744:1222,745:669,746:1222,747:709,748:1328,749:1129,750:1328,751:1129,752:1328,753:1129,754:1328,755:1129,756:1328,757:1129,758:1328,759:1129,760:1817,761:1539,762:1230,763:969,764:1230,765:1226,766:1015,767:1226,768:1015,769:1226,770:1015,856:1164,857:1139,858:1215,859:557,860:557,861:1130,862:1316,863:1284,864:1287,865:1336,866:1275,867:1139,868:1164,869:1460,870:1788,871:1460,872:1408,873:1461,874:1292,875:1333,876:1222,877:1284,878:1114,879:1085,880:1182,881:1168,882:1149,883:1072,884:969,885:1015,886:1085,887:859,888:1056,889:497,890:506,891:489,892:1106,893:969,894:357,895:655,896:1054,897:1164,898:1460,899:1085,900:1182,901:1417,902:1434,903:1290,904:1027,905:2137,906:2377,907:1215,908:1040,909:1333,910:1072,911:1230,912:1026,913:557,914:1859,915:1568,916:557,917:1336,918:1114,919:1336,920:1114,921:1914,922:1729,923:1164,924:1085,925:1415,926:1079,927:1079,928:1859,929:1568,930:1215,931:1040,932:1460,933:1182,934:1460,935:1182,936:1408,937:1168,938:1393,939:1163,940:1393,941:1163,942:1380,943:1101,944:1287,945:969,946:1287,947:969,948:1287,949:969,950:1402,951:1113,952:1771,953:1590,954:1155,955:1222,956:984,957:1402,958:1113,959:1139,960:859,961:1583,962:1213,963:1128,964:1285,965:1285,966:1139,967:859,968:1336,969:1063,970:1230,971:1026,972:1284,973:1015,974:1104,975:1599,982:1408,983:1164,984:1817,985:1539,986:507,987:1934,988:1494,989:1494,990:507},vA=new TextEncoder,VA=A=>{const B=Math.round(100*A)/100;return Number.isInteger(B)?String(B):B.toFixed(2).replace(/0+$/,"")},UA=A=>{const B=Math.round(1e6*A)/1e6;return Number.isInteger(B)?String(B):B.toFixed(6).replace(/0+$/,"")},lA=A=>A.map(UA).join(" ");function aA(A){let B="",E=0;const s=new Map;for(const w of A){const A=w.codePointAt(0)||0,Q=rA[A]||rA[63];B+=Q.toString(16).padStart(4,"0"),E+=HA[Q]||1024,s.has(Q)||s.set(Q,A||63)}return{hex:B,width:E,unicode:s}}function PA(A,B){return aA(A).width*B/hA}function yA(A,B=PA(A.text,A.size)){const E=A.align||"left",s="center"===E?B/2:"right"===E?B:0,w=(A.angle||0)*Math.PI/180,Q=Math.cos(w),C=Math.sin(w);return{width:B,baselineX:A.x-Q*s,baselineY:A.y+C*s,cos:Q,sin:C}}function uA(A){const B=yA(A),E=-555*A.size/hA,s=SA*A.size/hA,w=[0,B.width].flatMap(A=>[E,s].map(E=>({x:B.baselineX+B.cos*A-B.sin*E,y:B.baselineY-B.sin*A-B.cos*E})));return{minX:Math.min(...w.map(A=>A.x)),minY:Math.min(...w.map(A=>A.y)),maxX:Math.max(...w.map(A=>A.x)),maxY:Math.max(...w.map(A=>A.y))}}function NA(A){const B=A.reduce((A,B)=>A+B.length,0),E=new Uint8Array(B);let s=0;for(const B of A)E.set(B,s),s+=B.length;return E}const KA=A=>vA.encode(A),dA=(A,B)=>NA([KA(`<< ${A} /Length ${B.length} >>\nstream\n`),B,KA("\nendstream")]);function JA(A){const B=function(A){const B=atob(A),E=new Uint8Array(B.length);for(let A=0;A"image"===A.kind&&null!=A.opacity&&A.opacity<1?[Math.max(0,Math.min(1,A.opacity))]:[]))].sort((A,B)=>A-B),s=new Map(E.map((A,B)=>[A,`GS${B+1}`])),w=function(A,B){const E=[],s=new Map,w=B=>A.height-B,Q=(A,...B)=>`${B.map(VA).join(" ")} ${A}`,C=A=>{for(const B of A)if(B.length){E.push(Q("m",B[0][0],w(B[0][1])));for(let A=1;A{let B=!1;for(const s of A)if(!(s.length<2)){B=!0,E.push(Q("m",s[0][0],w(s[0][1])));for(let A=1;A Tj`,"ET")}else{const A=(I.angle||0)*Math.PI/180,s=Math.cos(A),C=Math.sin(A),g=I.x+I.width/2,Y=w(I.y+I.height/2);E.push("q");const R=null==I.opacity?1:Math.max(0,Math.min(1,I.opacity)),M=B.get(R);M&&E.push(`/${M} gs`),E.push(Q("cm",s*I.width,C*I.width,C*I.height,-s*I.height,g-s*I.width/2-C*I.height/2,Y-C*I.width/2+s*I.height/2),`/Im${I.imageId} Do`,"Q")}return{stream:E.join("\n"),unicode:s}}(A,s),Q=Math.max(0,...Object.keys(HA).map(Number)),C=Array.from({length:Q+1},(A,B)=>Math.round(1e3*(HA[B]||1024)/hA)),g=[],I=A=>(g.push("string"==typeof A?KA(A):A),g.length),Y=I(""),R=I(""),M=I(""),F=I(dA(`/Length1 ${B.length}`,B)),i=I(`<< /Type /FontDescriptor /FontName /Roboto /Flags 32 /FontBBox [${jA.join(" ")}] /ItalicAngle 0 /Ascent 2146 /Descent -555 /CapHeight 2146 /StemV 80 /FontFile2 ${F} 0 R >>`),x=I(`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /Roboto /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor ${i} 0 R /W [0 [${C.join(" ")}]] /CIDToGIDMap /Identity >>`),b=KA(function(A){const B=[...A].sort((A,B)=>A[0]-B[0]),E=B.map(([A,B])=>`<${A.toString(16).padStart(4,"0")}> <${B<=65535?B.toString(16).padStart(4,"0"):(()=>{const A=B-65536;return(55296+(A>>10)).toString(16).padStart(4,"0")+(56320+(1023&A)).toString(16).padStart(4,"0")})()}>`);return`/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /HousePlanUnicode def\n/CMapType 2 def\n1 begincodespacerange\n<0000> \nendcodespacerange\n${B.length} beginbfchar\n${E.join("\n")}\nendbfchar\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend`}(w.unicode)),L=I(dA("",b)),D=I(`<< /Type /Font /Subtype /Type0 /BaseFont /Roboto /Encoding /Identity-H /DescendantFonts [${x} 0 R] /ToUnicode ${L} 0 R >>`),G=I(dA("",KA(w.stream))),o=[];for(const B of A.images||[]){const A=I(dA(`/Type /XObject /Subtype /Image /Width ${B.width} /Height ${B.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode`,B.bytes));o.push(`/Im${B.id} ${A} 0 R`)}const t=A.now.toISOString().replace(/[-:T]/g,"").slice(0,14),c=I(`<< /CreationDate (D:${t}Z) /ModDate (D:${t}Z) >>`),W=`<< /Font << /F1 ${D} 0 R >>`+(o.length?` /XObject << ${o.join(" ")} >>`:"")+(E.length?` /ExtGState << ${E.map(A=>`/${s.get(A)} << /ca ${VA(A)} /CA ${VA(A)} >>`).join(" ")} >>`:"")+" >>";g[Y-1]=KA(`<< /Type /Catalog /Pages ${R} 0 R >>`),g[R-1]=KA(`<< /Type /Pages /Kids [${M} 0 R] /Count 1 >>`),g[M-1]=KA(`<< /Type /Page /Parent ${R} 0 R /MediaBox [0 0 ${VA(A.width)} ${VA(A.height)}] /Resources ${W} /Contents ${G} 0 R >>`);const m=KA("%PDF-1.4\n%âãÏÓ\n"),n=[m],e=[0];let h=m.length;g.forEach((A,B)=>{const E=KA(`${B+1} 0 obj\n`),s=KA("\nendobj\n");e.push(h),n.push(E,A,s),h+=E.length+A.length+s.length});const S=h,j=["xref",`0 ${g.length+1}`,"0000000000 65535 f "];for(let A=1;A<=g.length;A++)j.push(`${String(e[A]).padStart(10,"0")} 00000 n `);return j.push(`trailer\n<< /Size ${g.length+1} /Root ${Y} 0 R /Info ${c} 0 R >>`,`startxref\n${S}\n%%EOF\n`),n.push(KA(j.join("\n"))),NA(n)}const ZA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,TA=A=>A.maxX-A.minX,fA=A=>A.maxY-A.minY;function kA(A,B,E,s=0){Number.isFinite(B)&&Number.isFinite(E)&&(A.minX=Math.min(A.minX,B-s),A.minY=Math.min(A.minY,E-s),A.maxX=Math.max(A.maxX,B+s),A.maxY=Math.max(A.maxY,E+s))}function zA(A,B,E,s,w,Q){const C=Q*Math.PI/180,g=Math.cos(C),I=Math.sin(C),Y=B+s/2,R=E+w/2;for(const[B,E]of[[-s/2,-w/2],[s/2,-w/2],[s/2,w/2],[-s/2,w/2]])kA(A,Y+g*B-I*E,R+I*B+g*E)}function pA(A,B,E){for(const s of B)"M"===s.op||"L"===s.op?kA(A,s.x,s.y,E):"C"===s.op&&(kA(A,s.x1,s.y1,E),kA(A,s.x2,s.y2,E),kA(A,s.x,s.y,E))}function XA(A){const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)if("path"===E.kind){const A=E.stroke?(E.width||.5)/2:0;for(const s of E.rings)for(const[E,w]of s)kA(B,E,w,A)}else if("line"===E.kind)for(const[A,s]of E.points)kA(B,A,s,E.width/2);else if("vector"===E.kind)pA(B,E.ops,E.width/2);else if("text"===E.kind){const A=uA(E);kA(B,A.minX,A.minY),kA(B,A.maxX,A.maxY)}else zA(B,E.x,E.y,E.width,E.height,E.angle||0);return B}function OA(A,B,E){return!!ZA(A)&&(TA(A)<=TA(B)+E&&fA(A)<=fA(B)+E)}function qA(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`}const $A=72/25.4,_A=5.25,AB=[.08,.08,.08],BB=[127/255,127/255,127/255],EB=[.72,.72,.72],sB=(A,B)=>A.minXB.minX&&A.minYB.minY;function wB(A,B,E,s,w=0,Q="left"){return uA({x:A,y:B,text:E,size:s,angle:w,align:Q})}function QB(A,B,E,s,w){const Q=Math.min(...[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]].map(([A,w])=>(A-B)*s[0]+(w-E)*s[1]));return Math.max(0,w-Q)}const CB=(A,B)=>`${A.axis}:${B[0]<-.5||B[1]<-.5?-1:1}`,gB=(A,B)=>{A.minX=Math.min(A.minX,B[0]),A.minY=Math.min(A.minY,B[1]),A.maxX=Math.max(A.maxX,B[0]),A.maxY=Math.max(A.maxY,B[1])},IB=A=>{const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)for(const A of E)gB(B,A);return B};function YB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return Array.from({length:48},(A,B)=>{const w=B/48*Math.PI*2,Q=Math.cos(w)*E/2,R=Math.sin(w)*s/2;return[I+C*Q-g*R,Y+g*Q+C*R]})}function RB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return[[-E/2,-s/2],[E/2,-s/2],[E/2,s/2],[-E/2,s/2]].map(([A,B])=>[I+C*A-g*B,Y+g*A+C*B])}function MB(A,B,E){if("passage"===A.type)return[];const s=A.rlen/2,w=B>0?B/E*Y/2:2,Q=[];if("window"===A.type)Q.push([[-s,-w],[s,-w]],[[-s,w],[s,w]],[[-s,-w],[-s,w]],[[s,-w],[s,w]]);else if("gate"===A.type){const B=10*(A.flip_v?-1:1)*Math.PI/180,E=[[[-s,0],[-s+Math.cos(B)*s,Math.sin(B)*s]],[[s,0],[s-Math.cos(B)*s,Math.sin(-B)*s]]];Q.push(...E);for(const A of E){const B=A[1][0]-A[0][0],E=A[1][1]-A[0][1],s=Math.hypot(B,E)||1,C=-E/s,g=B/s,I=Math.min(.08*s,Math.max(1,.7*w));for(const s of[.3,.5,.7]){const w=A[0][0]+B*s,Y=A[0][1]+E*s;Q.push([[w-C*I,Y-g*I],[w+C*I,Y+g*I]])}}}else{const B=A.flip_v?1:-1,E=A.flip_h?s:-s,w=[E,B*A.rlen];Q.push([[E,0],w]);const C=[];for(let s=0;s<=16;s++){const w=B*s/16*Math.PI/2,Q=A.flip_h?-1:1;C.push([E+Q*Math.cos(w)*A.rlen,Math.sin(w)*A.rlen])}Q.push(C)}const C=A.angle*Math.PI/180,g=Math.cos(C),I=Math.sin(C);return Q.map(B=>B.map(([B,E])=>[A.rx+B*g-E*I,A.ry+B*I+E*g]))}function FB(A,B){const E=IB([A]);return B.filter(A=>{const B=IB([A]);return B.maxX>=E.minX&&B.minX<=E.maxX&&B.maxY>=E.minY&&B.minY<=E.maxY})}function iB(A){const B=function(A){const{rawSpace:B,space:E}=A,s=Number(B.cell_cm)>0?Number(B.cell_cm):5,w=Array.isArray(B.walls)?B.walls:[],Q=c(B,E,I,.02*Y),C=W(B,E,s,Y,I),g=m(C),M=n(E,s,Y,2e-4*Y,g).all,F=e(C,E,w,Q.contour,R,s,Y,I);return{cellCm:s,walls:w,zero:Q,openings:C,extras:M,geometry:A.sharedWallGeometry||h(E.rooms,w,Q.contour,F,R,s,Y,I,M)}}(A),E=new Map;if(A.options.dimensions)for(const s of A.space.rooms){const w=C(s);if(!w)continue;const Q=s.id?A.resolveInnerContour?.(s.id):void 0;E.set(s,s.id&&(void 0===Q?g(A.space.rooms,s.id,B.walls,B.zero.contour,R,B.cellCm,Y,I,B.geometry.roomGeom,B.geometry.multiWallNodes):Q)||w)}const s=new Map;if(A.options.dimensions)for(const w of A.space.rooms){const Q=C(w);if(!Q)continue;const g=E.get(w)||Q,I=w.id?A.resolveRoomArea?.(w.id,g):void 0,Y=Number.isFinite(I)?[]:FB(g,B.extras),R=Y.length?M(g,Y):null,i=Number.isFinite(I)&&I>=0?I:R?F(R):Math.abs(g.reduce((A,B,E)=>{const s=g[(E+1)%g.length];return A+B[0]*s[1]-s[0]*B[1]},0)/2);s.set(w,i)}const w=[..."failed-core"===B.geometry.status?A.space.rooms.map(A=>C(A)||[]).filter(A=>A.length):B.geometry.components.flatMap(A=>i(A.geom)),...B.zero.lines.map(A=>[[A[0],A[1]],[A[2],A[3]]])];A.options.decor&&w.push(...function(A){const B=[];for(const E of A.decor||[])"line"===E.kind?B.push([[E.x1*I,E.y1*I],[E.x2*I,E.y2*I]]):"text"!==E.kind?B.push(L(E).map(([A,B])=>[A*I,B*I])):B.push([[E.x*I,E.y*I]]);return B}(A.rawSpace));for(const B of A.rasters||[])w.push(RB(B.x,B.y,B.drawWidth,B.drawHeight,B.angle));let Q=IB(w);var x;[(x=Q).minX,x.minY,x.maxX,x.maxY].every(Number.isFinite)&&x.maxX>x.minX&&x.maxY>x.minY||(Q={minX:0,minY:0,maxX:I,maxY:I});return{built:B,dimensionContours:E,roomAreas:s,bounds:Q,cmPerUnit:B.cellCm/Y}}function xB(A,B,E,s){const{built:w,dimensionContours:Q,roomAreas:g,bounds:M,cmPerUnit:F}=B,c=(s?297:210)*$A,W=(s?210:297)*$A,m=12*$A,n=18*$A,e=24*$A,h=F*(10*$A)/E,j=(M.maxX-M.minX)*h,H=(M.maxY-M.minY)*h,v=m+n,V=W-v-m-e,U=c-2*m,a=A=>[0+(A[0]-M.minX)*h,0+(A[1]-M.minY)*h],P=(A,B)=>[M.minX+(A-0)/h,M.minY+(B-0)/h],y=A=>{const B=P(A.minX,A.minY),E=P(A.maxX,A.maxY);return{minX:B[0],minY:B[1],maxX:E[0],maxY:E[1]}},u=w.geometry.components.flatMap(A=>i(A.geom)),N=A=>w.geometry.components.some(B=>S([...A],B.geom)),K=A=>function(A,B,E){if(!LA(A)||!mA(B))return!0;const s=DA(A);return!!s.some(E)||!!B.some(B=>B.some(B=>xA(B)&&bA(B,A)))||nA(B,(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(function(A,B){const E=Number.isFinite(B)&&B>=0?B:0;return{minX:A.minX-E,minY:A.minY-E,maxX:A.maxX+E,maxY:A.maxY+E}}(A,$A-1e-6)),u,N),d=(A,B)=>function(A,B,E){if(!LA(A)||!mA([B]))return!1;const s=DA(A);return!!s.every(E)&&!nA([B],(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(A),B,A=>Z([...A],B)),J=(A,B,E={})=>function(A,B,E,s,w={}){if(!xA(A)||!xA(B)||!mA(E))return!0;if(w.allowStartExit){const w=tA(A,B);if(w<=iA)return!0;const Q=nA(E,(B,E)=>cA(A,B,E));if(!Q)return!0;const C=[];nA(E,(E,s)=>{const w=WA(A,B,E,s);return w&&C.push(w),!1});const g=iA/w,I=[0,1,...C.flatMap(A=>[A.t,A.endT])].sort((A,B)=>A-B).filter((A,B,E)=>0===B||A-E[B-1]>g),Y=E=>[A[0]+(B[0]-A[0])*E,A[1]+(B[1]-A[1])*E],R=A=>C.some(B=>B.overlap&&A>B.t+g&&AA.t>M+g||A.endT>M+g)}const Q=[(A[0]+B[0])/2,(A[1]+B[1])/2],C=nA(E,(B,E)=>cA(A,B,E));return!((!s(A)||w.allowStartBoundary&&C)&&!s(Q)&&!s(B))||nA(E,(E,s)=>{const Q=WA(A,B,E,s);return!!Q&&(Q.overlap||!w.allowStartBoundary||!C||Q.t*tA(A,B)>iA)})}(P(A[0],A[1]),P(B[0],B[1]),u,N,E),T=(A,B,E)=>{const s=A.x*I,w=A.y*I,Q=A.w*I,C=A.h*I,g=s+Q/2,Y=w+C/2,R=s+(A.flip_h?Q:0),F=w+(A.flip_v?C:0),i=(A.flip_h?-1:1)*Q/B,x=(A.flip_v?-1:1)*C/E,b=(Number(A.angle)||0)*Math.PI/180,L=Math.cos(b),D=Math.sin(b),G=Y+D*(R-g)+L*(F-Y);return{a:h*L*i,b:h*D*i,c:-h*D*x,d:h*L*x,e:0+(g+L*(R-g)-D*(F-Y)-M.minX)*h,f:0+(G-M.minY)*h}};let f=[];const z=[],O=function(A,B){const E=3*$A*Math.SQRT2,s=[];for(let w=-B;w<=A+E;w+=E)s.push([[w,0],[w+B,B]]);return s}(c,W);for(const B of A.rasters||[])f.push({kind:"image",imageId:B.id,...a([B.x,B.y]).reduce((A,B,E)=>({...A,[E?"y":"x"]:B}),{}),width:B.drawWidth*h,height:B.drawHeight*h,angle:B.angle,opacity:B.opacity});for(const A of w.geometry.components)f.push({kind:"path",rings:i(A.geom).map(A=>A.map(a)),fill:BB,stroke:AB,width:.25*$A,hatch:{lines:O,stroke:AB,width:.18*$A}});if("failed-core"===w.geometry.status)for(const B of A.space.rooms){const A=C(B);A&&f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}for(const A of w.zero.lines)f.push({kind:"line",points:[a([A[0],A[1]]),a([A[2],A[3]])],stroke:AB,width:.35*$A,dash:[3*$A,2*$A]});const q=w.geometry.openingIndex;for(const B of w.openings){const E=B.partitionHost?{cm:B.partitionHost.partition.cm}:q?x(A.space.rooms,B,w.walls,R,w.cellCm,Y,I,w.zero.contour):{cm:0};for(const A of MB(B,E.cm,w.cellCm))f.push({kind:"line",points:A.map(a),stroke:AB,width:.3*$A})}if(A.options.decor)for(const B of A.rawSpace.decor||[])if("image"!==B.kind)if("line"===B.kind)f.push({kind:"line",points:[a([B.x1*I,B.y1*I]),a([B.x2*I,B.y2*I])],stroke:AB,width:Math.max(.2*$A,10*Number(B.width_cm||1)*$A/E),dash:"dashed"===B.line_style?[3*$A,2*$A]:void 0});else if("text"===B.kind)f.push({kind:"text",...(()=>{const[A,E]=a([B.x*I,B.y*I]);return{x:A,y:E}})(),text:B.text,size:Math.max(6,10*Number(B.size_cm||20)*$A/E),angle:Number(B.angle)||0});else if("furniture"===B.kind){const A=r[B.symbol];A?f.push({kind:"vector",ops:YA(A.d,T(B,A.viewW,A.viewH)),stroke:AB,width:Math.max(.2*$A,10*b(B,w.cellCm,Y)*$A/E)}):f.push({kind:"path",rings:[L(B).map(([A,B])=>a([A*I,B*I]))],stroke:AB,width:.25*$A})}else{const A="ellipse"===B.kind?YB(B.x*I,B.y*I,B.w*I,B.h*I,Number(B.angle)||0):L(B).map(([A,B])=>[A*I,B*I]);f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}if(A.options.dimensions&&w.geometry.roomGeom)for(const[B,E]of D(w.geometry.roomGeom).entries()){const s=l(F),w=(A,B,E)=>{const s=a(A.sourceA),w=a(A.sourceB),Q=a(A.a),C=a(A.b),g=(6+E)*$A,I=[Q[0]+B[0]*g,Q[1]+B[1]*g],Y=[C[0]+B[0]*g,C[1]+B[1]*g],R=[(I[0]+Y[0])/2,(I[1]+Y[1])/2],M=PA(A.text,7)+2*$A>Math.hypot(Y[0]-I[0],Y[1]-I[1]),F=QB(wB(R[0],R[1],A.text,7,A.angle,"center"),R[0],R[1],B,$A),i=[R[0]+B[0]*F,R[1]+B[1]*F];return{edge:A,a:s,b:w,oa:I,ob:Y,middle:R,label:i,box:wB(i[0],i[1],A.text,7,A.angle,"center"),needsShelf:M}},Q=A=>{const B=[{start:A.oa,end:A.ob},{start:A.a,end:A.oa,allowStartExit:!0},{start:A.b,end:A.ob,allowStartExit:!0}];return A.needsShelf&&B.push({start:A.middle,end:A.label,mayEnterOwnLabel:!0}),B},C=A=>K(A.box)||Q(A).some(A=>J(A.start,A.end,{allowStartBoundary:A.allowStartBoundary,allowStartExit:A.allowStartExit})),g=EA(k(E,F,A.imperial,{ringIndex:B,epsilon:s}),{ring:E,epsilon:s,score:A=>{const B=[-A.inwardNormal[0],-A.inwardNormal[1]],E=a(A.mid),s=Array.from({length:21},(A,B)=>4*B).find(E=>!C(w(A,B,E))),Q=E[0]+(U-j)/2,g=E[1]+(V-H)/2;return{hardCollisions:void 0===s?21:s/4,normalClearance:Math.abs(B[0])>.5?B[0]>0?U-Q:Q:B[1]>0?V-g:g}}});for(const A of X(g,s)){const B=A.map(A=>({edge:A,outward:[-A.inwardNormal[0],-A.inwardNormal[1]]})),E=A=>B.map(({edge:B,outward:E})=>w(B,E,A));let s=null;for(let A=0;A<=80&&!s;A+=4){const B=E(A),w=B.some((A,E)=>B.slice(0,E).some(B=>sB(A.box,B.box))),g=B.some(A=>C(A)||z.some(B=>sB(A.box,B))),I=B.some((A,E)=>Q(A).some(A=>z.some(B=>eA(A.start,A.end,B))||B.some((B,s)=>(!A.mayEnterOwnLabel||s!==E)&&eA(A.start,A.end,B.box))));w||g||I||(s=B)}if(s)for(const A of s)f.push({kind:"line",points:[A.oa,A.ob],stroke:AB,width:.2*$A},{kind:"line",points:[A.a,A.oa],stroke:AB,width:.15*$A},{kind:"line",points:[A.b,A.ob],stroke:AB,width:.15*$A}),A.needsShelf&&f.push({kind:"line",points:[A.middle,A.label],stroke:AB,width:.15*$A}),f.push({kind:"text",x:A.label[0],y:A.label[1],text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}const $=[...A.space.rooms].sort((A,B)=>String(A.id||"").localeCompare(String(B.id||"")));for(const[B,E]of $.entries()){const s=C(E);if(!s)continue;const w=Q.get(E)||s,I=g.get(E)||0,Y=G(E,A.space.id,A.layout,A.config),[R,M]=a([Y.x,Y.y]),i=w.map(a),x=IB([i]);let b=!1;if(A.options.roomNames&&E.name){const A=Math.max(0,x.maxX-x.minX-4*$A),B=PA(E.name,6.75)<=A?6.75:PA(E.name,5.25)<=A?5.25:0;B&&(f.push({kind:"text",x:R,y:M-2,text:E.name,size:B,align:"center"}),z.push(wB(R,M-2,E.name,B,0,"center")),b=!0)}if(A.options.dimensions){const B=o(I*F*F/1e4,A.imperial),E=M+(b?8:0);f.push({kind:"text",x:R,y:E,text:B,size:6,align:"center"}),z.push(wB(R,E,B,8,0,"center"))}if(A.options.dimensions){const E=l(F),s=EA(p(w,F,A.imperial,{ringIndex:B,epsilon:E}),{ring:w,epsilon:E,score:A=>{const B=a(A.mid),E=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,$A),s=wB(B[0]+A.inwardNormal[0]*E,B[1]+A.inwardNormal[1]*E,A.text,7,A.angle,"center"),w="horizontal"===A.axis?A.inwardNormal[1]>0?x.maxY-B[1]:B[1]-x.minY:A.inwardNormal[0]>0?x.maxX-B[0]:B[0]-x.minX;return{hardCollisions:Number(K(s))+z.reduce((A,B)=>A+Number(sB(s,B)),0),normalClearance:w}}});for(const A of s.filter(A=>A.short)){const B=A.inwardNormal,E=a(A.a),s=a(A.b),w=(E[0]+s[0])/2,Q=(E[1]+s[1])/2;f.push({kind:"line",points:[[w-1.5*B[0]*$A,Q-1.5*B[1]*$A],[w+1.5*B[0]*$A,Q+1.5*B[1]*$A]],stroke:AB,width:.2*$A})}const Q=new Map;for(const A of s.filter(A=>!A.short)){const B=CB(A,A.inwardNormal),E=Q.get(B)||[];E.push(A),Q.set(B,E)}for(const A of Q.values()){let B=null;for(let E=0;E<=30&&!B;E+=3){const s=A.map(A=>{const B=a(A.mid),s=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,(1+E)*$A),w=B[0]+A.inwardNormal[0]*s,Q=B[1]+A.inwardNormal[1]*s;return{edge:A,x:w,y:Q,box:wB(w,Q,A.text,_A,A.angle,"center")}}),Q=s.some((A,B)=>s.slice(0,B).some(B=>sB(A.box,B.box))),C=s.some(A=>K(A.box)||z.some(B=>sB(A.box,B))),g=s.every(A=>d(A.box,w));Q||C||!g||(B=s)}if(B)for(const A of B)f.push({kind:"text",x:A.x,y:A.y,text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}}const _={minX:m,minY:v,maxX:c-m,maxY:v+V},AA=XA(f),BA=OA(AA,{minX:0,minY:0,maxX:U,maxY:V},.5*$A),sA=function(A,B){const E=XA(A);if(!ZA(E))return{commands:[...A],bounds:E,dx:0,dy:0};const s=(B.minX+B.maxX-E.minX-E.maxX)/2,w=(B.minY+B.maxY-E.minY-E.maxY)/2,Q=function(A,B,E){return A.map(A=>"path"===A.kind?{...A,rings:A.rings.map(A=>A.map(([A,s])=>[A+B,s+E]))}:"line"===A.kind?{...A,points:A.points.map(([A,s])=>[A+B,s+E])}:"vector"===A.kind?{...A,ops:A.ops.map(A=>((A,B,E)=>"M"===A.op||"L"===A.op?{...A,x:A.x+B,y:A.y+E}:"C"===A.op?{...A,x1:A.x1+B,y1:A.y1+E,x2:A.x2+B,y2:A.y2+E,x:A.x+B,y:A.y+E}:A)(A,B,E))}:{...A,x:A.x+B,y:A.y+E})}(A,s,w);return{commands:Q,bounds:{minX:E.minX+s,minY:E.minY+w,maxX:E.maxX+s,maxY:E.maxY+w},dx:s,dy:w}}(f,_);f=sA.commands,f.push({kind:"text",x:m,y:m+10,text:A.space.title,size:14}),A.cardTitle&&f.push({kind:"text",x:c-m,y:m+10,text:A.cardTitle,size:10,align:"right"});const wA=W-m-13*$A;f.push({kind:"line",points:[[m,wA-4*$A],[c-m,wA-4*$A]],stroke:EB,width:.2*$A}),f.push({kind:"text",x:m,y:wA,text:A.t("pdf.scale",{n:E}),size:8});const QA=10*(A.imperial?152.4:100)*$A/E,CA=wA+8;f.push({kind:"line",points:[[m,CA],[m+QA,CA]],stroke:AB,width:.4*$A});for(let A=0;A<=4;A++){const B=m+QA*A/4;f.push({kind:"line",points:[[B,CA-2],[B,CA+2]],stroke:AB,width:.25*$A})}f.push({kind:"text",x:m+QA/2,y:wA+17,text:A.imperial?"5 ft":"1 m",size:7,align:"center"});const gA=t(A.config.settings,A.rawSpace.settings||{});if(null!==gA){const B=c/2,E=wA+5.5*$A;f.push({kind:"vector",ops:FA({centerX:B,centerY:E,size:11*$A,northDeg:gA}),fill:AB,width:0,fillRule:"evenodd"}),f.push({kind:"text",x:B,y:wA,text:A.t("pdf.north"),size:7,align:"center"})}f.push({kind:"text",x:c-m,y:wA+12,text:`${qA(A.now)} · House Plan v${A.version}`,size:7,align:"right"});const IA={width:c,height:W,commands:f,images:(A.rasters||[]).map(({id:A,bytes:B,width:E,height:s})=>({id:A,bytes:B,width:E,height:s})),now:A.now,scale:E,sceneBounds:sA.bounds,planField:_},RA=Math.max(0,TA(AA))*Math.max(0,fA(AA)),MA=U*V;return{page:IA,sceneBounds:sA.bounds,field:_,fits:BA,fillRatio:MA>0?RA/MA:0,landscape:s}}function bB(A,B){return A.fillRatio!==B.fillRatio?A.fillRatio>B.fillRatio?A:B:A.landscape?B:A}function LB(A,B,E){const s=12*$A,w=(E?297:210)*$A-2*s,Q=(E?210:297)*$A-2*s-18*$A-24*$A,C=A.cmPerUnit*(10*$A)/B;return(A.bounds.maxX-A.bounds.minX)*C<=w+.5*$A&&(A.bounds.maxY-A.bounds.minY)*C<=Q+.5*$A}function DB(A){let B=0;for(const E of A)if(B+=Math.max(0,Number(E)||0),B>26214400)throw new Error("pdf.too_large")}const GB="f75fcd3764d3a1a73710cfa9cac88454a450e0d29e090f3339b5f5d853594786";async function oB(A,B){if(!A)throw new Error("pdf.asset_failed");const E=await fetch(A,{credentials:"same-origin"});if(!E.ok)throw new Error("pdf.asset_failed");const s=await E.blob();let w;try{w=await createImageBitmap(s)}catch{throw new Error("pdf.asset_failed")}try{if("image/jpeg"===s.type)return{id:B,bytes:new Uint8Array(await s.arrayBuffer()),width:w.width,height:w.height};const A=document.createElement("canvas");A.width=w.width,A.height=w.height;const E=A.getContext("2d");if(!E)throw new Error("pdf.asset_failed");E.fillStyle="#fff",E.fillRect(0,0,A.width,A.height),E.drawImage(w,0,0);const Q=await new Promise(B=>A.toBlob(B,"image/jpeg",.85));if(!Q)throw new Error("pdf.asset_failed");return{id:B,bytes:new Uint8Array(await Q.arrayBuffer()),width:w.width,height:w.height}}finally{w.close()}}async function tB(A,B,E){const s=await async function(A,B){const E=[];if(B.backdrop&&A.space.bg){const B=await oB(A.backdropUrl,"backdrop");E.push({...B,x:A.space.bg.x,y:A.space.bg.y,drawWidth:A.space.bg.w,drawHeight:A.space.bg.h,angle:A.space.bg.angle,opacity:.6})}if(B.decor){let B=0;for(const s of A.rawSpace.decor||[]){if("image"!==s.kind)continue;const w=A.decorAssets.get(s.asset_id),Q=j(s,I,I);if(!w||!Q)throw new Error("pdf.asset_failed");const C=await oB(w.url,"decor"+B++);E.push({...C,x:Q[0],y:Q[1],drawWidth:Q[2],drawHeight:Q[3],opacity:Q[4],angle:Number(s.angle)||0})}}return DB(E.map(A=>A.bytes.byteLength)),E}(A,B),w=JA(function(A){const B=iB(A);let E=[];for(const s of wA){const w=[!1,!0].filter(A=>LB(B,s,A)).map(E=>xB(A,B,s,E));if(!w.length)continue;const Q=w.filter(A=>A.fits);if(Q.length)return Q.reduce(bB).page;E=w}E.length||(E=[!1,!0].map(E=>xB(A,B,500,E)));const s=E.filter(A=>A.fits);if(s.length)return s.reduce(bB).page;const w=Math.min(...E.map(A=>Math.max(TA(A.sceneBounds)/TA(A.field),fA(A.sceneBounds)/fA(A.field)))),Q=50,C=1e6,g=Number.isFinite(w)?Math.ceil(Math.min(C,500*Math.max(1,w))/Q)*Q:C;let I=500,Y=0,R=[],M=Math.max(550,g);for(;M<=C;){const E=[!1,!0].map(E=>xB(A,B,M,E)).filter(A=>A.fits);if(E.length){Y=M,R=E;break}if(I=M,M===C)break;M=Math.min(C,Math.ceil(2*M/Q)*Q)}if(!Y)throw new Error("pdf.failed");let F=Math.floor(I/Q),i=Math.floor(Y/Q);for(;i-F>1;){const E=Math.floor((F+i)/2),s=[!1,!0].map(s=>xB(A,B,E*Q,s)).filter(A=>A.fits);s.length?(i=E,R=s):F=E}const x=R.reduce(bB).page;if(!OA(x.sceneBounds,x.planField,.5*$A))throw new Error("pdf.failed");return x}({...A,options:B,now:E,rasters:s,t:A.t})),Q=new Blob([w],{type:"application/pdf"}),C=URL.createObjectURL(Q);try{const B=document.createElement("a");B.href=C,B.download=`houseplan-${g=A.space.title,g.normalize("NFKD").replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"").toLowerCase()||"space"}-${qA(E)}.pdf`,B.style.display="none",document.body.append(B),B.click(),B.remove()}finally{setTimeout(()=>URL.revokeObjectURL(C),0)}var g;return w}class cB{assertRasterBudget(A){DB(A)}render(A){let B;return B={...A,save:async E=>{await tB(A,E,B.now||new Date)}},s``}}export{GB as PDF_EXPORT_FINGERPRINT,cB as PdfExportRuntime,tB as exportSpacePdf};