// ==UserScript== // @name BLUEPRINT // @namespace https://github.com/shmidtqq65/blueprint // @version 1.0.0 // @description Turn any website into a blueprint. Press Alt+Shift+P to draw the page, Esc to put it back. Nothing leaves your browser. // @author shmidtqq // @license MIT // @homepageURL https://github.com/shmidtqq65/blueprint // @downloadURL https://raw.githubusercontent.com/shmidtqq65/blueprint/main/userscript/blueprint.user.js // @updateURL https://raw.githubusercontent.com/shmidtqq65/blueprint/main/userscript/blueprint.user.js // @match *://*/* // @grant none // @run-at document-idle // @noframes // ==/UserScript== (function () { 'use strict'; function run() { (()=>{'use strict';const t=window,e=document,o=e.documentElement,n=t.__blueprint;if(n&&n.alive)return void n.toggle();if(!(o&&e.body&&e.body instanceof HTMLElement))return;const i=Object.assign({motion:!0,credit:!0,ui:!0,grid:!0,dims:!0},t.__BP_OPTIONS||{}),l=!!t.__BP_MANUAL,r=!1!==i.motion&&!(t.matchMedia&&t.matchMedia('(prefers-reduced-motion: reduce)').matches),a=()=>performance.now(),s=(t,e,o)=>to?o:t,d=t=>1-Math.pow(1-t,3),c=Math.round,h='#1b4b8f',f=t=>'rgba(238,245,255,'+t+')',p='#ffd35c',m=t=>'rgba(255,211,92,'+t+')',g='ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace',u=t=>{if(!t||'transparent'===t)return 0;const e=t.match(/\/\s*([\d.]+)(%?)\s*\)$/)||t.match(/^rgba\([^,]+,[^,]+,[^,]+,\s*([\d.]+)(%?)\s*\)$/);return e?e[2]?parseFloat(e[1])/100:parseFloat(e[1]):1},x=t=>parseFloat(t)||0,b=(location.hostname||'this page').replace(/^www\./,''),y=(t,e)=>t.length>e?t.slice(0,e-1)+'\u2026':t,v=()=>(e.title||(e.querySelector('h1')||{}).textContent||b).replace(/\s+/g,' ').trim(),T=()=>{const t=new Date;return String(t.getDate()).padStart(2,'0')+'.'+String(t.getMonth()+1).padStart(2,'0')+'.'+t.getFullYear()},w=t=>(t.split(',')[0]||'').replace(/["']/g,'').trim(),S=t=>`\nhtml{background-color:${h}!important;${t?`background-image:linear-gradient(${f(.13)} 1px,transparent 1px),linear-gradient(90deg,${f(.13)} 1px,transparent 1px),linear-gradient(${f(.05)} 1px,transparent 1px),linear-gradient(90deg,${f(.05)} 1px,transparent 1px)!important;background-size:100px 100px,100px 100px,20px 20px,20px 20px!important;background-position:-1px -1px!important;`:'background-image:none!important;'}color-scheme:dark!important}\nbody{background-color:transparent!important;background-image:none!important}\n*,*::before,*::after{background-color:transparent!important;background-image:none!important;border-color:${f(.5)}!important;color:${f(.93)}!important;-webkit-text-fill-color:currentcolor!important;text-shadow:none!important;box-shadow:none!important;outline-color:${f(.5)}!important;text-decoration-color:${f(.55)}!important;caret-color:${p}!important;filter:none!important;-webkit-backdrop-filter:none!important;backdrop-filter:none!important;mix-blend-mode:normal!important;cursor:crosshair!important}\n::selection{background-color:${m(.35)}!important;color:#fff!important}\n::placeholder{color:${f(.45)}!important}\n:is(p,li,dd,td,blockquote,figcaption) a{text-decoration-line:underline!important;text-decoration-style:dotted!important}\nimg,picture,video,canvas,iframe,embed,object,image{filter:grayscale(1) contrast(1.15) brightness(.82)!important;mix-blend-mode:screen!important}\nsvg{color:${f(.9)}!important}\nsvg :is(path,circle,rect,ellipse,line,polyline,polygon){fill:none!important;stroke:${f(.85)}!important;stroke-width:1px!important;vector-effect:non-scaling-stroke!important}\nsvg text{fill:${f(.9)}!important;stroke:none!important}\n`,k=t=>{const e=new CSSStyleSheet;return e.replaceSync(t),e};if(!('adoptedStyleSheets'in e)||'function'!=typeof CSSStyleSheet||!('replaceSync'in CSSStyleSheet.prototype))return void console.warn('BLUEPRINT needs constructable stylesheets (Chrome 73+, Firefox 101+, Safari 16.4+).');let M=!1!==i.grid,E=!1!==i.dims;const R=k(S(M)),L=k('');let C=!1;const P=k('::view-transition-group(root),::view-transition-old(root),::view-transition-new(root){animation:none;mix-blend-mode:normal}\n::view-transition-new(root){animation:bp-scan 1.15s cubic-bezier(.65,0,.35,1) both}\n@keyframes bp-scan{from{clip-path:inset(0 0 100% 0)}to{clip-path:inset(0 0 0 0)}}'),W=new Set,A=new Map,$=(t,e)=>{A.has(t)||A.set(t,t.adoptedStyleSheets.slice()),t.adoptedStyleSheets=[...t.adoptedStyleSheets,e]},B=(t,e)=>{try{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(t=>t!==e)}catch(t){}},D=new Set(['script','style','noscript','template','head','meta','link','title','br','wbr','source','track','param','area','map','datalist','option','optgroup','blueprint-overlay']),N=new Set(['img','video','canvas','iframe','embed','object','svg']),F=new Set(['input','textarea','select','button','progress','meter']),_=new Set(['header','nav','main','aside','footer','article','section','form','figure','table','dialog']),I=new WeakMap;let O=[],z=[],H=[],U=[],q=0,j=0,X=0,Y=!0,G=new WeakMap;function V(t,e,o,n){const i=t.localName;if(N.has(i))return'svg'===i&&(o.width<32||o.height<32)?null:{kind:'media',label:'img'===i?'IMG':'svg'===i?'SVG':i.toUpperCase()};if('hr'===i)return{kind:'rule'};const l=[x(e.borderTopWidth),x(e.borderRightWidth),x(e.borderBottomWidth),x(e.borderLeftWidth)],r=[e.borderTopColor,e.borderRightColor,e.borderBottomColor,e.borderLeftColor],a=[e.borderTopStyle,e.borderRightStyle,e.borderBottomStyle,e.borderLeftStyle];let s=0;for(let t=0;t<4;t++)l[t]>=.5&&'none'!==a[t]&&'hidden'!==a[t]&&u(r[t])>.08&&(s|=1<.06&&d!==n||'none'!==h&&!f),m=Y&&e.boxShadow&&'none'!==e.boxShadow,g=F.has(i)||'button'===t.getAttribute('role'),b=_.has(i)&&o.width>=120&&o.height>=40?i.toUpperCase():'';return f&&o.width>=32&&o.height>=32?{kind:'media',label:'BG'}:g&&o.width>=6&&o.height>=6?{kind:'field',sides:15,solid:p}:(p||m)&&o.width>=10&&o.height>=10?{kind:'box',sides:15,label:b,solid:p}:s&&o.width>=4&&o.height>=4?{kind:'box',sides:s,label:b}:!Y&&x(e.borderTopLeftRadius)>2&&x(e.paddingTop)>2&&o.width>=40&&o.height>=24&&/block|flex|grid/.test(e.display)?{kind:'box',sides:15}:b?{kind:'frame',sides:15,label:b}:null}const J=t=>{const e=[];for(let n=t;n!==o;n=n.parentNode){if(!n||1!==n.nodeType)return null;let t=1;for(let e=n.previousElementSibling;e;e=e.previousElementSibling)t++;e.unshift(CSS.escape(n.localName)+':nth-child('+t+')')}return':root>'+e.join('>')};let K=0,Q=new WeakMap;const Z=(t,e)=>t.xe.x&&t.ye.y,tt=(t,e)=>{const o=Math.max(t.x,e.x),n=Math.max(t.y,e.y);return{x:o,y:n,w:Math.max(0,Math.min(t.x+t.w,e.x+e.w)-o),h:Math.max(0,Math.min(t.y+t.h,e.y+e.h)-n),live:t.live}};function et(){const n=a(),i=t.scrollX,l=t.scrollY,r=o.clientWidth||t.innerWidth,s=[],d=[],h=new Map;for(const t of O)h.set(t.el,t.born);let f=0;G=new WeakMap,Q=new WeakMap;const p=(t,e,o,n,r,a)=>{for(let m=t.firstElementChild;m;m=m.nextElementSibling){const t=m.localName;if(D.has(t)||m===it)continue;let g;try{g=getComputedStyle(m)}catch(t){continue}if('none'===g.display)continue;if(f++,'contents'===g.display){p(m,e,o,n,r+1,a);continue}const b=g.position,y=e||'fixed'===b||'sticky'===b,v=o||'fixed'===b;y&&G.set(m,v?'fixed':'sticky');const T=m.getBoundingClientRect(),S='visible'!==g.visibility||+g.opacity<.05,k={x:T.left+(y?0:i),y:T.top+(y?0:l),w:T.width,h:T.height,live:y};a&&Q.set(m,a);const M=a&&a.live===y&&!Z(k,a);let E=I.get(m);if(void 0===E&&!S&&T.width>0&&T.height>0&&(E=V(m,g,T,n),I.set(m,E)),E&&!S&&!M&&T.width>0&&T.height>0&&s.length<12e3){const t=[x(g.borderTopLeftRadius),x(g.borderTopRightRadius),x(g.borderBottomRightRadius),x(g.borderBottomLeftRadius)];s.push({el:m,kind:E.kind,label:E.label||'',sides:E.sides||15,solid:!!E.solid,rad:t.map(t=>Math.min(t,T.width/2,T.height/2)),x:k.x,y:k.y,w:T.width,h:T.height,live:y,fixed:v,clip:a&&a.live===y?a:null,depth:r,lx:0,born:h.has(m)?h.get(m):-1})}if(!S&&!M&&/^h[1-3]$/.test(t)&&T.width>0&&T.height>0&&d.length<40&&d.push({el:m,tag:t.toUpperCase(),x:T.left+(y?0:i),y:T.top+(y?0:l),w:T.width,h:T.height,live:y,fixed:v,note:w(g.fontFamily)+' '+g.fontWeight+' '+c(x(g.fontSize))+'/'+('normal'===g.lineHeight?'n':c(x(g.lineHeight))),born:-1}),N.has(t))continue;const L=u(g.backgroundColor)>.06?g.backgroundColor:n;let P=a;if('visible'===g.overflowX&&'visible'===g.overflowY||(P=a&&a.live===y?tt(a,k):k),p(m,y,v,L,r+1,P),m.shadowRoot&&'open'===m.shadowRoot.mode){if(!W.has(m.shadowRoot)&&(W.add(m.shadowRoot),C))try{$(m.shadowRoot,R)}catch(t){}p(m.shadowRoot,y,v,L,r+1,P)}}};p(e.body,!1,!1,getComputedStyle(e.body).backgroundColor,0,null),Y=!1,X=f,O=(t=>{const e=(t,e)=>Math.abs(t.x-e.x)<3&&Math.abs(t.y-e.y)<3&&Math.abs(t.w-e.w)<3&&Math.abs(t.h-e.h)<3,o=t.filter(t=>'frame'!==t.kind),n=[],i=t.filter(t=>'frame'!==t.kind||!o.some(o=>e(o,t))&&!n.some(o=>e(o,t))&&(n.push(t),!0)),l=[];for(const t of i){if(!t.label||'media'===t.kind||t.fixed)continue;const e=6*t.label.length+14;let o=t.y+8;for(let n=0;n<8;n++){const n=l.find(n=>Math.abs(n.x-t.x)<8&&on.y0);if(!n)break;o=n.y1}o+e>t.y+t.h?t.label='':(t.lx=o-t.y,l.push({x:t.x,y0:o,y1:o+e}))}return i})(s),U=d,q=Math.max(o.scrollWidth,e.body.scrollWidth,r),j=Math.max(o.scrollHeight,e.body.scrollHeight,t.innerHeight),(e=>{const o=O.filter(t=>'rule'!==t.kind&&!t.live&&t.w>=Math.min(260,.22*e)&&t.w<=.92*e&&t.h>=56).sort((t,e)=>e.w*e.h-t.w*t.h),n=[];for(const i of o){if(n.length>=9)break;if(i.w>.985*e&&i.h>1.5*t.innerHeight)continue;let o=!1;for(const t of n){if(Math.abs(i.x-t.x)<4&&Math.abs(i.y-t.y)<4&&Math.abs(i.w-t.w)<4){o=!0;break}const e=Math.max(0,Math.min(i.x+i.w,t.x+t.w)-Math.max(i.x,t.x)),n=Math.max(0,Math.min(i.y+i.h,t.y+t.h)-Math.max(i.y,t.y)),l=i.w*i.h,r=t.w*t.h;if(e*n>.55*Math.min(l,r)&&Math.min(l,r)>.5*Math.max(l,r)){o=!0;break}}o||n.push(i)}z=n,ot=O.filter(t=>t.live&&'frame'!==t.kind);const i=[];for(const t of n.slice(0,4))if(!t.live)for(const e of[t.x,t.x+t.w])i.some(t=>Math.abs(t-e)<6)||i.push(e);H=i})(r);const m=[];for(const t of ot){if(!t.solid)continue;const e=J(t.el);e&&m.push(e+'{background-color:rgba(27,75,143,.94)!important}')}try{L.replaceSync(m.join('\n'))}catch(t){}K=a()-n}let ot=[];const nt=(t,e,o)=>ot.some(n=>n!==o&&t>=n.x&&t<=n.x+n.w&&e>=n.y-4&&e<=n.y+n.h+4);let it,lt,rt,at,st,dt,ct=0,ht=0,ft=1,pt=null;const mt=`\n:host{all:initial}\n.w{position:fixed;inset:0;pointer-events:none;z-index:2147483646;font:11px/1.35 ${g};color:${f(.92)};-webkit-font-smoothing:antialiased;text-align:left;direction:ltr}\ncanvas{position:absolute;inset:0;width:100%;height:100%}\n.tb{position:absolute;right:16px;bottom:16px;width:360px;max-width:calc(100vw - 32px);pointer-events:auto;cursor:default;background:rgba(20,62,122,.82);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);border:1.5px solid ${f(.85)};box-shadow:0 0 0 4px rgba(20,62,122,.55),0 0 0 5px ${f(.35)};opacity:0;transform:translateY(8px);transition:opacity .45s ease,transform .45s ease}\n.tb.on{opacity:1;transform:none}\n.row{display:grid;grid-template-columns:96px 1fr;border-top:1px solid ${f(.55)}}\n.row:first-child{border-top:0}\n.k,.v{padding:5px 8px;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}\n.k{border-right:1px solid ${f(.55)};color:${f(.6)};font-size:9.5px;letter-spacing:.06em;text-transform:uppercase;padding-top:6.5px}\n.v{font-size:11.5px}\n.hd{display:flex;align-items:baseline;justify-content:space-between;padding:7px 8px 6px}\n.hd b{font:700 15px/1 ${g};letter-spacing:.14em}\n.hd span{color:${f(.6)};font-size:9.5px;letter-spacing:.06em}\n.bar{display:flex;border-top:1px solid ${f(.55)}}\n.bar button{all:unset;flex:1;text-align:center;padding:7px 0;font:600 10px/1 ${g};letter-spacing:.08em;color:${f(.9)};cursor:pointer;border-left:1px solid ${f(.55)}}\n.bar button:first-child{border-left:0}\n.bar button:hover{background:${f(.1)}}\n.bar button:focus-visible{outline:2px solid ${p};outline-offset:-2px}\n.bar button[aria-pressed=false]{color:${f(.45)}}\n.ft{border-top:1px solid ${f(.55)};padding:5px 8px;display:flex;justify-content:space-between;color:${f(.6)};font-size:9.5px}\n.ft a{color:${p};text-decoration:none;pointer-events:auto}\n.toast{position:absolute;left:50%;top:22px;transform:translateX(-50%);background:rgba(20,62,122,.92);border:1px solid ${f(.7)};padding:6px 12px;font-size:11px;opacity:0;transition:opacity .3s}\n.toast.on{opacity:1}\n@media (max-width:640px){.tb{left:8px;right:8px;bottom:8px;width:auto}.row{grid-template-columns:78px 1fr}.hide-s{display:none}}\n`,gt={};let ut=0;const xt=t=>{dt&&(dt.textContent=t,dt.classList.add('on'),clearTimeout(ut),ut=setTimeout(()=>dt&&dt.classList.remove('on'),2200))};function bt(){ct=o.clientWidth||t.innerWidth,ht=t.innerHeight,ft=Math.min(2,t.devicePixelRatio||1),rt&&(rt.width=Math.round(ct*ft),rt.height=Math.round(ht*ft)),pt&&(()=>{const t=Math.min(ft,1.5);pt.width=Math.round(ct*t),pt.height=Math.round(ht*t);const o=pt.getContext('2d');o.setTransform(t,0,0,t,0,0),o.fillStyle=o.createPattern((()=>{const t=e.createElement('canvas');t.width=t.height=160;const o=t.getContext('2d'),n=o.createImageData(160,160);let i=1234567;for(let t=0;t128?255:0,n.data[t+3]=(i>>8)%23;return o.putImageData(n,0,0),t})(),'repeat'),o.fillRect(0,0,ct,ht);const n=o.createRadialGradient(ct/2,ht/2,.35*Math.min(ct,ht),ct/2,ht/2,.62*Math.hypot(ct,ht));n.addColorStop(0,'rgba(8,24,56,0)'),n.addColorStop(1,'rgba(8,24,56,.32)'),o.fillStyle=n,o.fillRect(0,0,ct,ht)})()}let yt=0,vt=0,Tt=0,wt=!1,St=!1,kt='in',Mt={x:-1,y:-1,on:!1},Et=null,Rt=[];const Lt=t=>2*(t.w+t.h);function Ct(t,e,o,n,i,l){t.beginPath(),t.roundRect&&(l[0]||l[1]||l[2]||l[3])?t.roundRect(e,o,n,i,l):t.rect(e,o,n,i)}function Pt(t,e,o){return t.live?{x:t.x,y:t.y}:{x:t.x-e,y:t.y-o}}function Wt(t){if(!t.live)return;const e=t.el.getBoundingClientRect();t.x=e.left,t.y=e.top,t.w=e.width,t.h=e.height}function At(t,e,o,n,i,l,r){if(o-e<26)return;t.strokeStyle=r,t.fillStyle=r,t.lineWidth=1,t.beginPath();const a=i>0?-4:4;t.moveTo(e+.5,n+i),t.lineTo(e+.5,n+a),t.moveTo(o-.5,n+i),t.lineTo(o-.5,n+a),t.stroke();const s=t.measureText(l).width+10,d=(e+o)/2;t.beginPath(),s0?-4:4;t.moveTo(n+i,e+.5),t.lineTo(n+a,e+.5),t.moveTo(n+i,o-.5),t.lineTo(n+a,o-.5),t.stroke();const s=t.measureText(l).width+10,d=(e+o)/2;t.beginPath(),sht+40||l.y+e.h<-40||l.x>ct+40||l.x+e.w<-40)return;if(e.born<0){if(wt&&l.y>i)return;e.born=yt+(r?(wt||'in'===kt?.02:.06+.25*Math.random())+.08*Math.random():-9)}const a=r?s((yt-e.born)/(.3+Math.min(.55,Lt(e)/5e3)),0,1):1;if(!(a<=0))if(e.clip){const i=e.clip;t.save(),t.beginPath(),t.rect(i.live?i.x:i.x-o,i.live?i.y:i.y-n,i.w,i.h),t.clip(),Ft(t,e,l,d(a),a),t.restore()}else Ft(t,e,l,d(a),a)}function Nt(t,e,o,n,i){Wt(e);const l=Pt(e,o,n);if(l.y>ht||l.y+e.h<0)return;if(e.born<0){if(wt&&l.y>i)return;e.born=yt+(r?.5:-9)}const a=r?s((yt-e.born)/.5,0,1):1;a<=0||l.y<(ct>700?34:14)||(t.globalAlpha=.85*a,t.font='10px '+g,t.fillStyle=f(.75),t.strokeStyle=f(.5),t.lineWidth=1,t.textAlign='left',t.textBaseline='alphabetic',t.beginPath(),t.moveTo(l.x,l.y-3.5),t.lineTo(l.x+6,l.y-3.5),t.stroke(),t.fillText(e.tag+' \xb7 '+e.note,l.x+9,l.y-1),t.globalAlpha=1)}function Ft(t,e,o,n,i){const l=Math.round(o.x)+.5,r=Math.round(o.y)+.5,a=Math.max(1,Math.round(e.w)-1),d=Math.max(1,Math.round(e.h)-1);if('frame'===e.kind)return t.globalAlpha=n,t.strokeStyle=f(.3),t.lineWidth=1,t.setLineDash([6,4]),t.strokeRect(l,r,a,d),t.setLineDash([]),_t(t,e,l,r),void(t.globalAlpha=1);if(t.lineWidth='field'===e.kind?1.25:1,t.strokeStyle=f('media'===e.kind?.7:.82),'rule'===e.kind)return t.beginPath(),t.moveTo(l,r),t.lineTo(l+a*n,r),void t.stroke();const h=Lt(e);if(15===e.sides?(Ct(t,l,r,a,d,e.rad),n<1&&(t.setLineDash([h*n,h+10]),t.lineDashOffset=0),t.stroke(),t.setLineDash([])):(t.beginPath(),1&e.sides&&(t.moveTo(l,r),t.lineTo(l+a*n,r)),2&e.sides&&(t.moveTo(l+a,r),t.lineTo(l+a,r+d*n)),4&e.sides&&(t.moveTo(l+a,r+d),t.lineTo(l+a-a*n,r+d)),8&e.sides&&(t.moveTo(l,r+d),t.lineTo(l,r+d-d*n)),t.stroke()),e.w>=140&&e.h>=60&&15===e.sides&&n>.9){const e=7,o=4;t.strokeStyle=f(.45*(n-.9)*10),t.beginPath(),t.moveTo(l-o-e,r),t.lineTo(l-o,r),t.moveTo(l,r-o-e),t.lineTo(l,r-o),t.moveTo(l+a+o,r),t.lineTo(l+a+o+e,r),t.moveTo(l+a,r-o-e),t.lineTo(l+a,r-o),t.moveTo(l-o-e,r+d),t.lineTo(l-o,r+d),t.moveTo(l,r+d+o),t.lineTo(l,r+d+o+e),t.moveTo(l+a+o,r+d),t.lineTo(l+a+o+e,r+d),t.moveTo(l+a,r+d+o),t.lineTo(l+a,r+d+o+e),t.stroke()}if(e.label&&'box'===e.kind&&n>.6&&(t.globalAlpha=(n-.6)/.4,_t(t,e,l,r),t.globalAlpha=1),'media'===e.kind&&i>.55&&e.w>=28&&e.h>=28){const o=s((i-.55)/.45,0,1);if(t.strokeStyle=f(.38*o),t.beginPath(),t.moveTo(l,r),t.lineTo(l+a*o,r+d*o),t.moveTo(l+a,r),t.lineTo(l+a-a*o,r+d*o),t.stroke(),e.w>=70&&e.h>=36){t.font='10px '+g;const n=e.label+' '+c(e.w)+'\xd7'+c(e.h),i=t.measureText(n).width;t.fillStyle='rgba(20,62,122,'+.85*o+')',t.fillRect(l+4,r+4,i+8,15),t.fillStyle=f(.9*o),t.textAlign='left',t.textBaseline='middle',t.fillText(n,l+8,r+12)}}}function _t(t,e,o,n){e.label&&(t.font='9px '+g,t.save(),t.translate(o<18?o+(ct>700?27:9):o-8,n+e.lx),t.rotate(Math.PI/2),t.fillStyle=f(.62),t.textAlign='left',t.textBaseline='middle',t.fillText(e.label,0,0),t.restore())}function It(t,e,o,n,i){if(!e.isConnected)return;const l=e.getBoundingClientRect();if(l.width<1||l.height<1||l.bottom<0||l.top>ht)return;let r;try{r=getComputedStyle(e)}catch(t){return}const a=[x(r.marginTop),x(r.marginRight),x(r.marginBottom),x(r.marginLeft)],s=[x(r.paddingTop),x(r.paddingRight),x(r.paddingBottom),x(r.paddingLeft)],d=l.left,h=l.top,u=l.width,b=l.height;t.save(),Ht(t,d-a[3],h-a[0],u+a[1]+a[3],b+a[0]+a[2],d,h,u,b,m(i?.22:.3));const v=x(r.borderLeftWidth),T=x(r.borderTopWidth),S=x(r.borderRightWidth),k=x(r.borderBottomWidth);Ht(t,d+v,h+T,u-v-S,b-T-k,d+v+s[3],h+T+s[0],u-v-S-s[1]-s[3],b-T-k-s[0]-s[2],f(i?.16:.22)),t.strokeStyle=p,t.lineWidth=1.5,t.strokeRect(c(d)+.5,c(h)+.5,c(u)-1,c(b)-1),t.font='10.5px '+g;const M=h-16>24?h-16:h+b+16;At(t,d,d+u,M,M24?d-16:d+u+16;if($t(t,h,h+b,E,Et.measureText(e).width))+16,d=15*o.length+10;let h=Mt.x+22,g=Mt.y+22;h+l>ct-8&&(h=Mt.x-22-l),g+d>ht-8&&(g=Mt.y-22-d),t.strokeStyle=m(.8),t.lineWidth=1,t.beginPath(),t.moveTo(Mt.x,Mt.y),t.lineTo(h{t.fillStyle=0===o?p:f(.92),t.fillText(e,h+8,g+12+15*o)})}t.restore()}function Ot(t,e,o,n,i){t.strokeStyle=m(.7),t.setLineDash([3,3]),t.beginPath(),t.moveTo(e+.5,o+.5),t.lineTo(n+.5,i+.5),t.stroke(),t.setLineDash([])}function zt(t,e,o,n,i){const l=Math.round(Math.abs(n-e)+Math.abs(i-o));if(l<1)return;const r=o===i;t.strokeStyle=p,t.fillStyle=p,t.beginPath(),t.moveTo(Math.round(e)+.5,Math.round(o)+.5),t.lineTo(Math.round(n)+.5,Math.round(i)+.5),r?(t.moveTo(Math.round(e)+.5,o-4),t.lineTo(Math.round(e)+.5,o+5),t.moveTo(Math.round(n)+.5,i-4),t.lineTo(Math.round(n)+.5,i+5)):(t.moveTo(e-4,Math.round(o)+.5),t.lineTo(e+5,Math.round(o)+.5),t.moveTo(n-4,Math.round(i)+.5),t.lineTo(n+5,Math.round(i)+.5)),t.stroke();const a=String(l),s=t.measureText(a).width+8,d=(e+n)/2,c=(o+i)/2,f=r?d-s/2:d+6,m=r?c+5:c-7;t.fillRect(f,m,s,14),t.fillStyle=h,t.textAlign='left',t.textBaseline='middle',t.fillText(a,f+4,m+7.5)}function Ht(t,e,o,n,i,l,r,a,s,d){if(!(n<=0||i<=0||l<=e+.5&&r<=o+.5&&l+a>=e+n-.5&&r+s>=o+i-.5)){t.save(),t.beginPath(),t.rect(e,o,n,i),a>0&&s>0&&t.rect(l+a,r,-a,s),t.clip('evenodd'),t.strokeStyle=d,t.lineWidth=1,t.beginPath();for(let l=-i;lsetTimeout(t,30)));const n=Math.max(q,320),l=Math.max(j,200),r=Math.min(1,1600/n),a=Math.min(l,Math.floor(12e3/r/1.5)),s=Math.round(n*r)+80,d=Math.round(a*r)+80+190,m=Math.min(1.5,Math.sqrt(26e6/(s*d))),u=e.createElement('canvas');u.width=Math.round(s*m),u.height=Math.round(d*m);const y=u.getContext('2d');y.setTransform(m,0,0,m,0,0);const w=t.scrollX,S=t.scrollY,k=0!==w||0!==S,M=(e,o)=>{try{t.scrollTo({left:e,top:o,behavior:'instant'})}catch(n){t.scrollTo(e,o)}},E=()=>{for(const t of O)Wt(t);for(const t of U)Wt(t)};k&&M(0,0);try{E(),((o,n,l,r,a,s,d,m,u)=>{o.fillStyle=h,o.fillRect(0,0,n,l),o.lineWidth=1;for(let t=0;t<=n;t+=20)o.strokeStyle=f(t%100==0?.12:.05),o.beginPath(),o.moveTo(t+.5,0),o.lineTo(t+.5,l),o.stroke();for(let t=0;t<=l;t+=20)o.strokeStyle=f(t%100==0?.12:.05),o.beginPath(),o.moveTo(0,t+.5),o.lineTo(n,t+.5),o.stroke();o.strokeStyle=f(.9),o.lineWidth=2,o.strokeRect(14,14,n-28,l-28),o.lineWidth=1,o.strokeRect(20,20,n-40,l-40),o.save(),o.beginPath(),o.rect(40,40,d*s,u*s),o.clip(),o.translate(40,40),o.scale(s,s);for(const t of O)t.fixed||t.y>u||(t.clip?(o.save(),o.beginPath(),o.rect(t.clip.x,t.clip.y,t.clip.w,t.clip.h),o.clip(),qt(o,t,s),o.restore()):qt(o,t,s));o.strokeStyle=f(.13),o.setLineDash([22/s,5/s,3/s,5/s]),o.beginPath();for(const t of H)o.moveTo(t,0),o.lineTo(t,u);o.stroke(),o.setLineDash([]),o.font=9/s+'px '+g,o.fillStyle=f(.62),o.textAlign='left',o.textBaseline='middle';for(const t of O)!t.label||t.fixed||'media'===t.kind||t.y>u||(o.save(),o.translate(t.x<18?t.x+9/s:t.x-8/s,t.y+t.lx),o.rotate(Math.PI/2),o.fillText(t.label,0,0),o.restore());o.font=10/s+'px '+g,o.fillStyle=f(.7),o.strokeStyle=f(.5),o.textBaseline='alphabetic';for(const t of U)t.fixed||t.y>u||t.y<14||(o.fillText(t.tag+' \xb7 '+t.note,t.x+9/s,t.y-1/s),o.beginPath(),o.moveTo(t.x,t.y-3.5/s),o.lineTo(t.x+6/s,t.y-3.5/s),o.stroke());((t,o,n,i)=>{const l=e.createRange();let r=0,a=null,s='',d='',c=o,h=n,p=!1,m=null;t.fillStyle=f(.92),t.textAlign='left',t.textBaseline='alphabetic';const g=f=>{const g=e.createTreeWalker(f,NodeFilter.SHOW_TEXT,{acceptNode:t=>{const e=t.parentElement;return!e||!/\S/.test(t.data)||D.has(e.localName)||e.closest('blueprint-overlay,svg')?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});for(let e=g.nextNode();e&&r<2e4;e=g.nextNode()){const f=e.parentElement;if(f!==a){a=f;const t=getComputedStyle(f),e=G.get(f);p='fixed'===e||'visible'!==t.visibility||+t.opacity<.05,c='sticky'===e?0:o,h='sticky'===e?0:n,s=t.fontStyle+' '+t.fontWeight+' '+t.fontSize+' '+t.fontFamily,m=Q.get(f)||null,m&&m.live!==('sticky'===e)&&(m=null)}if(p)continue;const g=/\S+/g;let u;for(;(u=g.exec(e.data))&&r<2e4;){l.setStart(e,u.index),l.setEnd(e,u.index+u[0].length);const o=l.getClientRects();if(!o.length)continue;const n=o[0];if(n.width<.5)continue;const a=n.left+c,f=n.top+h;if(f>i)continue;if(m){const t=a+n.width/2,e=f+n.height/2;if(tm.x+m.w||em.y+m.h)continue}s!==d&&(t.font=s,d=s);const p=t.measureText(u[0]),g=p.width>0?n.width/p.width:1,x=f+(n.height+(p.fontBoundingBoxAscent||0)-(p.fontBoundingBoxDescent||0))/2;g>.8&&g<1.25&&Math.abs(g-1)>.01?(t.save(),t.translate(a,x),t.scale(g,1),t.fillText(u[0],0,0),t.restore()):t.fillText(u[0],a,x),r++}}};g(e.body);for(const t of W)g(t)})(o,t.scrollX,t.scrollY,u),((t,e)=>{for(const o of O){if('field'!==o.kind||o.fixed||o.y>e)continue;const n=o.el,i=n.localName,l=String(n.type||'').toLowerCase();let r='',a=!1;if('select'===i?r=n.options&&n.selectedIndex>=0&&n.options[n.selectedIndex]?n.options[n.selectedIndex].text:'':'input'===i&&/^(button|submit|reset)$/.test(l)?r=n.value||'':('input'===i&&/^(text|search|email|url|tel|number|password)$/.test(l)||'textarea'===i)&&(r=n.placeholder||'',a=!0),!r||!/\S/.test(r))continue;const s=getComputedStyle(n),d=x(s.paddingLeft)+x(s.borderLeftWidth),c=x(s.paddingRight)+x(s.borderRightWidth);t.save(),t.beginPath(),t.rect(o.x,o.y,o.w,o.h),t.clip(),t.font=s.fontStyle+' '+s.fontWeight+' '+s.fontSize+' '+s.fontFamily,t.fillStyle=f(a?.45:.92),t.textAlign='left',t.textBaseline='middle';const h='textarea'===i?o.y+x(s.paddingTop)+x(s.borderTopWidth)+.65*x(s.fontSize):o.y+o.h/2;t.fillText(jt(t,r.replace(/\s+/g,' ').trim(),o.w-d-c),o.x+d,h),t.restore()}})(o,u),o.font=10/s+'px '+g,o.lineWidth=1/s;for(const t of z){const e={x:t.x,y:t.y};if(e.y>u||t.fixed)continue;const n=e.y-14/s>0&&!nt(e.x+t.w/2,e.y-14/s,t)?e.y-14/s:e.y+16/s;Xt(o,e.x,e.x+t.w,n,String(c(t.w)),s)}o.restore();const y=l-190-6+24,w=n-20-470;o.strokeStyle=f(.9),o.lineWidth=1.5,o.strokeRect(w,y,450,146),o.lineWidth=1;const S=[['PROJECT',b],['DRAWING',v()],['SCALE','1:'+(1/s).toFixed(2).replace(/\.?0+$/,'')],['ELEMENTS',String(O.length)],['DATE',T()]];o.font='700 18px '+g,o.fillStyle=f(.95),o.textAlign='left',o.textBaseline='middle',o.fillText('BLUEPRINT',w+12,y+20),o.font='10px '+g,o.textAlign='right',o.fillStyle=f(.65),o.fillText(u{const i=y+40+n*k;o.strokeStyle=f(.55),o.beginPath(),o.moveTo(w,i+.5),o.lineTo(w+450,i+.5),o.stroke(),o.beginPath(),o.moveTo(w+100.5,i),o.lineTo(w+100.5,i+k),o.stroke(),o.textAlign='left',o.fillStyle=f(.62),o.font='10px '+g,o.fillText(t,w+10,i+k/2),o.fillStyle=f(.95),o.font='13px '+g,o.fillText(jt(o,e,326),w+112,i+k/2)}),o.textAlign='left',o.fillStyle=f(.92),o.font='700 30px '+g,o.fillText(jt(o,b.toUpperCase(),w-80),40,y+28),o.font='12px '+g,o.fillStyle=f(.65),o.fillText(c(d)+' \xd7 '+c(m)+' px \xb7 '+O.length+' outlined elements \xb7 drawn '+T(),40,y+62),!1!==i.credit&&(o.fillStyle=p,o.fillText('drawn with BLUEPRINT \xb7 github.com/shmidtqq65/blueprint \xb7 @shmidtqq',40,y+86))})(y,s,d,0,0,r,n,l,a)}finally{k&&M(w,S),E()}const R=await new Promise(t=>u.toBlob(t,'image/png'));if(o&&R){const t=e.createElement('a');t.href=URL.createObjectURL(R),t.download=b.replace(/[^\w.-]+/g,'-')+'-blueprint.png',t.style.display='none',(lt||e.body).appendChild(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(t.href),4e3),xt('Saved '+t.download)}return{blob:R,width:u.width,height:u.height}}function qt(t,e,o){const n={x:e.x,y:e.y};return t.lineWidth=1/o,t.strokeStyle=f('media'===e.kind?.7:.85),'rule'===e.kind?(t.beginPath(),t.moveTo(n.x,n.y),t.lineTo(n.x+e.w,n.y),void t.stroke()):'frame'===e.kind?(t.strokeStyle=f(.32),t.setLineDash([6/o,4/o]),t.strokeRect(n.x,n.y,e.w,e.h),void t.setLineDash([])):(15===e.sides?(Ct(t,n.x,n.y,e.w,e.h,e.rad),t.stroke()):(t.beginPath(),1&e.sides&&(t.moveTo(n.x,n.y),t.lineTo(n.x+e.w,n.y)),2&e.sides&&(t.moveTo(n.x+e.w,n.y),t.lineTo(n.x+e.w,n.y+e.h)),4&e.sides&&(t.moveTo(n.x,n.y+e.h),t.lineTo(n.x+e.w,n.y+e.h)),8&e.sides&&(t.moveTo(n.x,n.y),t.lineTo(n.x,n.y+e.h)),t.stroke()),void('media'===e.kind&&e.w>=28&&e.h>=28&&(t.strokeStyle=f(.35),t.beginPath(),t.moveTo(n.x,n.y),t.lineTo(n.x+e.w,n.y+e.h),t.moveTo(n.x+e.w,n.y),t.lineTo(n.x,n.y+e.h),t.stroke(),e.w*o>70&&(t.font=10/o+'px '+g,t.fillStyle=f(.85),t.textAlign='left',t.textBaseline='top',t.fillText(e.label+' '+c(e.w)+'\xd7'+c(e.h),n.x+5/o,n.y+5/o)))))}const jt=(t,e,o)=>{if(t.measureText(e).width<=o)return e;for(;e.length>1&&t.measureText(e+'\u2026').width>o;)e=e.slice(0,-1);return e.trimEnd()+'\u2026'};function Xt(t,e,o,n,i,l){(o-e)*l<30||(t.strokeStyle=f(.75),t.fillStyle=f(.85),t.beginPath(),t.moveTo(e,n),t.lineTo(o,n),t.moveTo(e,n-4/l),t.lineTo(e,n+8/l),t.moveTo(o,n-4/l),t.lineTo(o,n+8/l),t.stroke(),t.textAlign='center',t.textBaseline='bottom',t.fillText(i,(e+o)/2,n-2/l))}let Yt=!0,Gt=0,Vt=0,Jt=null,Kt=!1;function Qt(t){if(!r||!e.startViewTransition||'visible'!==e.visibilityState)return t(),null;let o;e.adoptedStyleSheets.indexOf(P)<0&&(e.adoptedStyleSheets=[...e.adoptedStyleSheets,P]);try{o=e.startViewTransition(t)}catch(o){return B(e,P),t(),null}Jt=o,Kt=!0,St=!0,Tt=Date.now();const n=()=>Jt===o;o.ready.then(()=>{n()&&(St=!1,l&&Zt())},()=>{n()&&(St=!1)});const i=()=>{n()&&(Jt=null,B(e,P))};return o.finished.then(i,i),o}function Zt(){const t=1e3*Math.min(1.15,vt);for(const o of e.getAnimations?e.getAnimations().filter(t=>{const e=t.effect&&t.effect.pseudoElement;return e&&e.indexOf('view-transition')>=0}):[])try{o.pause(),o.currentTime=t}catch(t){}}function te(){if(Jt)try{Jt.skipTransition()}catch(t){}}function ee(){C=!1,B(e,R),B(e,L);for(const t of W)B(t,R)}function oe(){te(),'in'===kt?(kt='on',st&&st.classList.add('on')):'out'===kt&&ie()}function ne(){'out'!==kt&&Yt&&(kt='out',Et=null,Rt=[],st&&st.classList.remove('on'),pt&&(pt.style.display='none'),wt=!0,vt=0,Qt(ee)||ie())}function ie(){Yt&&(Yt=!1,te(),t.removeEventListener('mousemove',ae,{capture:!0}),e.removeEventListener('mouseleave',se,!0),t.removeEventListener('click',he,!0),t.removeEventListener('mousedown',fe,!0),t.removeEventListener('mouseup',fe,!0),t.removeEventListener('auxclick',fe,!0),t.removeEventListener('keydown',pe,!0),t.removeEventListener('resize',xe),e.removeEventListener('scroll',be,!0),ge&&ge.disconnect(),clearTimeout(me),clearTimeout(ue),clearTimeout(ut),cancelAnimationFrame(Gt),ee(),B(e,P),it&&it.remove(),it=lt=rt=at=pt=st=dt=null,t.__blueprint===ve&&delete t.__blueprint)}function le(e){try{(e=>{if(yt+=e,!at)return;const o=t.scrollX,n=t.scrollY,i=at;i.setTransform(ft,0,0,ft,0,0),i.clearRect(0,0,ct,ht);let l=ht+999;if(wt){St&&Date.now()-Tt>1500&&(St=!1),St||(vt+=e);const t=s(vt/1.15,0,1);l=(r?(t=>{return(e=t)<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;var e})(t):1)*ht,t>=1&&(wt=!1,oe())}if('in'===kt||'on'===kt){const t=[];for(const e of ot)Wt(e),e.solid&&e.born>=0&&t.push(e);i.save();for(const e of t)i.beginPath(),i.rect(0,0,ct,ht),i.rect(e.x+e.w,e.y,-e.w,e.h),i.clip();if(E&&H.length){i.strokeStyle=f(.13),i.lineWidth=1,i.setLineDash([22,5,3,5]),i.beginPath();for(const t of H){const e=Math.round(t-o)+.5;e<0||e>ct||(i.moveTo(e,0),i.lineTo(e,wt&&'in'===kt?l:ht))}i.stroke(),i.setLineDash([])}i.lineJoin='round';for(const t of O)t.live||Dt(i,t,o,n,l);for(const t of U)t.live||Nt(i,t,o,n,l);if(E){i.font='10.5px '+g;for(const t of z){const e=Pt(t,o,n);if(e.y>ht||e.y+t.h<0||t.born<0)continue;const l=r?s((yt-t.born-.55)/.45,0,1):1;if(l<=0)continue;i.globalAlpha=l;const a=ct>700?28:8,d=e.x+t.w/2,h=e.y-14,p=e.y+t.h+14,m=h>a&&!nt(d,h,t)?h:pa?e.x-14:e.x+t.w+14e.x+t.w)&&g{t.save(),t.lineWidth=1,t.font='600 10.5px '+g;const n=o.left>=e.left&&o.right<=e.right&&o.top>=e.top&&o.bottom<=e.bottom;if(n||e.left>=o.left&&e.right<=o.right&&e.top>=o.top&&e.bottom<=o.bottom){const i=n?e:o,l=n?o:e,r=(l.left+l.right)/2,a=(l.top+l.bottom)/2;zt(t,i.left,a,l.left,a),zt(t,l.right,a,i.right,a),zt(t,r,i.top,r,l.top),zt(t,r,l.bottom,r,i.bottom)}else{if(o.left>=e.right||e.left>=o.right){const n=o.left>=e.right?e:o,i=n===e?o:e,l=Math.max(e.top,o.top),r=Math.min(e.bottom,o.bottom),a=ln.bottom)&&Ot(t,n.right,a=e.bottom||e.top>=o.bottom){const n=o.top>=e.bottom?e:o,i=n===e?o:e,l=Math.max(e.left,o.left),r=Math.min(e.right,o.right),a=ln.right)&&Ot(t,a700&&'on'===kt&&((t,e,o)=>{const n=18;t.fillStyle='rgba(18,56,110,.5)',t.fillRect(0,0,ct,n),t.fillRect(0,n,n,ht-n),t.strokeStyle=f(.55),t.fillStyle=f(.7),t.lineWidth=1,t.font='9px '+g,t.textBaseline='top',t.textAlign='left',t.beginPath(),t.moveTo(0,18.5),t.lineTo(ct,18.5),t.moveTo(18.5,n),t.lineTo(18.5,ht);for(let o=10*Math.floor(e/10);o22&&t.fillText(String(o),n+3,2)}t.save(),t.rotate(-Math.PI/2);for(let e=100*Math.ceil(o/100);e22&&t.fillText(String(e),3-n,2)}t.restore(),Mt.on&&(t.fillStyle=p,t.fillRect(Mt.x-.5,0,1,n),t.fillRect(0,Mt.y-.5,n,1)),t.fillStyle='rgba(18,56,110,.8)',t.fillRect(0,0,n,n)})(i,o,n)}if(wt&&r){const t=Math.min(l,ht-1),e=i.createLinearGradient(0,t-90,0,t+2);e.addColorStop(0,'rgba(160,210,255,0)'),e.addColorStop(.8,'rgba(190,225,255,.16)'),e.addColorStop(1,'rgba(235,248,255,.55)'),i.fillStyle=e,i.fillRect(0,t-90,ct,92),i.fillStyle='rgba(255,255,255,.95)',i.fillRect(0,t-1.5,ct,2)}})(e)}catch(t){throw ie(),t}}const re=(t,n)=>{let i=e.elementFromPoint(t,n);for(;i&&i.shadowRoot&&i.shadowRoot.elementFromPoint;){const e=i.shadowRoot.elementFromPoint(t,n);if(!e||e===i)break;i=e}return!i||i===o||i===e.body||i===it||it&&it.contains(i)?null:i},ae=t=>{Mt.x=t.clientX,Mt.y=t.clientY,Mt.on=!0,'on'===kt&&(Et=re(t.clientX,t.clientY))},se=()=>{Mt.on=!1,Et=null},de=t=>it&&t.composedPath&&t.composedPath().indexOf(it)>=0,ce=t=>!!(t.target&&t.target.closest&&t.target.closest('[data-blueprint-ignore]')),he=t=>{if('on'!==kt||de(t)||0!==t.button||ce(t))return;t.preventDefault(),t.stopPropagation();const e=re(t.clientX,t.clientY);if(!e)return;const o=Rt.indexOf(e);o>=0?Rt.splice(o,1):(Rt.push(e),Rt.length>24&&Rt.shift())},fe=t=>{'on'!==kt||de(t)||ce(t)||0!==t.button||(t.preventDefault(),t.stopPropagation())},pe=t=>{if(!Yt||t.ctrlKey||t.metaKey||t.altKey)return;const e=t.target;if(e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName))&&'Escape'!==t.key)return;const o=t.key;let n=!0;'Escape'===o?ye('close'):'s'===o||'S'===o?ye('save'):'g'===o||'G'===o?ye('grid'):'d'===o||'D'===o?ye('dims'):'p'===o||'P'===o?Rt=[]:n=!1,n&&(t.preventDefault(),t.stopPropagation())};let me=0,ge=null,ue=0;const xe=()=>{bt(),clearTimeout(me),me=setTimeout(()=>{Yt&&'out'!==kt&&et()},220)},be=t=>{t.target!==e&&t.target!==o&&(clearTimeout(me),me=setTimeout(()=>{Yt&&'on'===kt&&et()},160))};function ye(t){Yt&&('close'===t?ne():'save'===t?Ut().catch(t=>xt('Could not draw the sheet: '+(t&&t.message))):'grid'===t?(M=!M,R.replaceSync(S(M)),gt.grid&>.grid.setAttribute('aria-pressed',String(M))):'dims'===t&&(E=!E,gt.dims&>.dims.setAttribute('aria-pressed',String(E))))}const ve={version:'1.0.0',get alive(){return Yt},toggle:ne,close:ne,stop:ie,save:t=>Ut(t),step:t=>{Yt&&(le(t),l&&Jt&&Yt&&Zt())},hover:(t,e)=>(Mt.x=t,Mt.y=e,Mt.on=!0,Et='on'===kt?re(t,e):null,Et?Et.localName:null),pin:(t,e)=>{const o=re(t,e);return o&&Rt.indexOf(o)<0&&Rt.push(o),Rt.length},state:()=>({phase:kt,items:O.length,keys:z.length,headings:U.length,elements:X,pins:Rt.length,hover:Et?Et.localName:null,grid:M,dims:E,transition:Kt,holding:wt&&St})};t.__blueprint=ve,et(),(()=>{it=e.createElement('blueprint-overlay'),it.setAttribute('data-blueprint',''),it.style.cssText='position:fixed!important;inset:0!important;z-index:2147483646!important;pointer-events:none!important;display:none!important;background:none!important;border:0!important;margin:0!important;padding:0!important',lt=it.attachShadow({mode:'open'}),lt.adoptedStyleSheets=[k(mt)];const t=e.createElement('div');t.className='w',pt=e.createElement('canvas'),t.appendChild(pt),rt=e.createElement('canvas'),t.appendChild(rt),at=rt.getContext('2d'),!1!==i.ui&&t.appendChild((()=>{st=e.createElement('div'),st.className='tb';const t=(t,o,n,i)=>{const l=e.createElement(t);return o&&(l.className=o),null!=i&&(l.textContent=i),n&&n.appendChild(l),l},o=t('div','hd',st);t('b','',o,'BLUEPRINT'),t('span','',o,'SHEET 1 OF 1');const n=(e,o)=>{const n=t('div','row',st);return t('div','k',n,e),t('div','v',n,o)};n('Project',b),n('Drawing',y(v(),60)),st.__scale=n('Scale','1:1'),st.__els=n('Elements',''),n('Date',T());const l=t('div','bar',st),r=(e,o,n,i)=>{const r=t('button','grid'===e||'dims'===e?'hide-s':'',l,o);r.type='button',r.dataset.act=n,null!=i&&r.setAttribute('aria-pressed',String(i)),gt[e]=r};r('save','SAVE PNG','save'),r('grid','GRID','grid',M),r('dims','DIMS','dims',E),r('close','CLOSE','close');const a=t('div','ft',st);if(t('span','hide-s',a,'hover to measure \xb7 click to pin \xb7 S save'),!1!==i.credit){const e=t('a','',a,'drawn by @shmidtqq');e.href='https://github.com/shmidtqq65/blueprint',e.target='_blank',e.rel='noopener'}return st.addEventListener('click',t=>{const e=t.target.closest&&t.target.closest('button');e&&(t.preventDefault(),ye(e.dataset.act))}),st})()),dt=e.createElement('div'),dt.className='toast',t.appendChild(dt),lt.appendChild(t),e.documentElement.appendChild(it),bt()})(),st&&st.__els&&(st.__els.textContent=O.length+' outlined \xb7 '+X+' total'),kt='in',wt=!0,vt=0,Qt(()=>{C=!0,$(e,R),$(e,L);for(const t of W)try{$(t,R)}catch(t){}it.style.setProperty('display','block','important')}),r||(wt=!1,oe()),t.addEventListener('mousemove',ae,{passive:!0,capture:!0}),e.addEventListener('mouseleave',se,!0),t.addEventListener('click',he,!0),t.addEventListener('mousedown',fe,!0),t.addEventListener('mouseup',fe,!0),t.addEventListener('auxclick',fe,!0),t.addEventListener('keydown',pe,!0),t.addEventListener('resize',xe),e.addEventListener('scroll',be,!0),t.MutationObserver&&(ge=new MutationObserver(t=>{t.every(t=>it&&(t.target===it||it.contains(t.target)||[...t.addedNodes,...t.removedNodes].every(t=>t===it)))||(clearTimeout(ue),ue=setTimeout(()=>{Yt&&'on'===kt&&et()},Math.max(400,8*K)))}),ge.observe(e.body,{childList:!0,subtree:!0})),l||(Vt=a(),Gt=requestAnimationFrame(function t(e){if(!Yt)return;const o=Math.min(.05,Math.max(0,(e-Vt)/1e3));Vt=e,le(o),Gt=requestAnimationFrame(t)}))})(); } window.addEventListener('keydown', function (e) { if (!e.altKey || !e.shiftKey || e.ctrlKey || e.metaKey || e.repeat || e.code !== 'KeyP') return; var t = e.target; if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return; e.preventDefault(); run(); }, true); })();